JSF传递参数并重定向到视图范围 [英] JSF Passing parameter and redirecting to view scope
问题描述
我正在尝试将参数传递给另一页.我有一个图像类别,该列表在会话范围内,在我的标题模板中为此类别中的每个类别都创建了一个链接.
I'm trying to pass a parameter to an other page. I have a category of images and that list is in a session scope, a link is created for each of this category in my header template.
我想重定向到新页面,并传递所选的类别.
I would like to redirect to a new page, and pass the selected category.
<h:dataTable id="categoryMenu" value="#{menuBean.listCategory}" var="category">
<h:column>
<h:link value="#{category.name}"
outcome="/image/imageList.xhtml" >
</h:link>
</h:column>
</h:dataTable>
但是现在我希望与ImageListBean.java关联的页面imageList.xhtml获得选定的类别.
But now I would like that my page imageList.xhtml associated with a ImageListBean.java get the selected category.
我通过使用f:param请求GET参数尝试了很多事情,但是因为我的ImageListBean.java必须处于视图范围内,所以它不起作用.
I tried a lot of things by requesting GET parameters with f:param, but because my ImageListBean.java must be as view scoped it does not work.
推荐答案
您的ViewScoped
bean应该没有问题.使用以下代码:
Your ViewScoped
bean shouldn't be problem. With this code:
<h:link value="#{category.name}" outcome="/image/imageList.xhtml">
<f:param name="categoryName" value="#{category.name}"/>
</h:link>
您应该可以使用以下方法在后备Bean中访问此参数:
you should be able to access this parameter in your backing bean with this:
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("categoryName")
这篇关于JSF传递参数并重定向到视图范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!