开发者

How do i append query string from managed bean to url? JSF

Can this method work?

public String sayHello(){
    r开发者_如何学JAVAeturn "Hello.jsp?name=" + "laala";
}

I am unable to access, query string using the above method. I tried ${param.name} as well as request.getParameter("name"). They both return null. Please help!


Either fire a redirect..

public void sayHello(){
    ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
    externalContext.redirect("/Hello.jsp?name=" + "laala");
}

.. or if you're already on JSF2, then just define them in navigation case:

<to-view-id>/Hello.jsp?name=#{bean.property}</to-view-id>

(although the .jsp file extension less or more hints that you're not on JSF2 yet)

When using the JSF2 navigation case, if you want the new URL get reflected in the browser address bar, you need to add a <redirect/> entry, else it will just do a forward.


maybe this would help you. check out f:param with h:commandLink

http://balusc.blogspot.com/2006/06/communication-in-jsf.html

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜