开发者

how to get http get request params in jsf 2.0 bakcing bean?

I having trouble with passing http get parameters to jsf 2.0 backing bean. User will invoke URl with some params containing id of some entity, which is later used to persist some other entity in db.

whole process can be summarized by fallowing: 1. user open 开发者_运维技巧page http://www.somhost.com/JsfApp/step-one.xhtml?sid=1 2. user fills some data and goes to next page 3. user fills some more data and then entity is saved to db with sid param from step one.

I have session scoped backing bean that hold data from all the pages (steps), but I cant pass param to bean property..

any ideas?


That's only possible if the bean is request scoped since it's a request parameter. Create a request scoped bean and make the current session scoped bean a managed property of it as well.

@ManagedBean
@RequestScoped
public class Step {

    @ManagedProperty(value="#{param.sid}")
    private Long sid;

    @ManagedProperty(value="#{data}")
    private Data data; // #{data} is a @SessionScoped @ManagedBean

    public String submitStep1() {
        // ...
    }

    public String submitStep2() {
        // ...
    }

    // ...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜