开发者

JSF how add a control on the first url

I have to implement a new feature in my existing JSF application. As it is now, there is a feature for searching a objects. The normal flow is: fill in some 开发者_StackOverflow中文版form parameters and see the detailed object page after submitting the form. Now I have to find a way to go to the detailed object page via a link which arrives through an email. In the link there are some parameters, useful to find the object, but if the object doesn't exist I would to forward the user to a courtesy page. How could I manage this thing? thank you very much


Do the job in constructor or @PostConstruct method of the bean which is associated with the view and use the rendered attribute to render page fragment/include conditionally.

@PostConstruct
public void init() {
    someObject = someDAO.find(someParam);
}

with

<h:panelGroup rendered="#{bean.someObject != null}">
    Found
</h:panelGroup>
<h:panelGroup rendered="#{bean.someObject == null}">
    Not gound
</h:panelGroup>

Or use ExternalContext#redirect() to redirect to another view.

@PostConstruct
public void init() {
    someObject = someDAO.find(someParam);
    if (someObject == null) {
        FacesContext.getCurrentInstance().getExternalContext().redirect("notfound.jsf");
    }
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜