jsf params conservation
I tried to create a an link - image that changes the language of a page. But I encountered an issue开发者_如何学运维, that the GET url params got lost after the ajax call, so not only the language changed, but also the content changed because of no params. The solution I found is to write down every single param that I use accross the whole website and try put it into the command link. But, I hope that this is not a neatest solution. Can you think of one?
<h:commandLink id="language" actionListener="#{userBean.changeLanguage}">
<f:param name="itemId" value="#{param.itemId}" />
<f:param name="categoryId" value="#{param.categoryId}" />
<f:ajax render="@all" />
</h:commandLink>
Yes, my site is not a huge one, there are just two params, but I want to learn for future.
Make them properties of a @ViewScoped
bean.
@ManagedBean
@ViewScoped
public class Bean {
@ManagedProperty(value="#{param.itemId}")
private Long itemId;
@ManagedProperty(value="#{param.categoryId}")
private Long categoryId;
// ...
}
And they'll be there as long as the view-to-view conversation lasts.
精彩评论