JSF 2.X在两个xhtml页面之间传递参数 [英] JSF 2.X Passing parameter between two xhtml pages

查看:88
本文介绍了JSF 2.X在两个xhtml页面之间传递参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在两个页面之间传递参数.我的 User.xhtml 页面具有 ui:repeat (显示用户).我可以访问用户ID .我想单击用户,然后转到他们的详细信息页面.我有 userDetails.xhtml ,目前为空白.

I am trying to pass parameter between two pages.my User.xhtml page has ui:repeat which displays user.I have access to the user Id as well. I want to click on the user and go to their details page. I have userDetails.xhtml which is blank at the moment.

我也有一个豆子.

当前,我正在使用 h:link 将一个页面导航到另一页面.而且有效.

Currently I am using h:link to navigate one page to another. And it works.

我的任务是:单击用户并获取他们的详细信息.

My mission is : Click on the user and get their details.

请帮助,我在JSF中还很新

Please help, I am pretty new in JSF

谢谢

推荐答案

您可以尝试使用<f:param>:

<ui:repeat value="#{userBean.users}" var="u">
    ...
    <h:link outcome="userDetails" value="Details">
        <f:param name="userID" value="#{u.id}" />
    </h:link>
    ...
</ui:repeat>

然后您将获得如下所示的ID:

then you can get the id like this:

@ManagedBean
@RequestScoped
public class UserDetailsBean {

    @ManagedProperty(value = "#{param.userID}")
    private String userID;

    // Getters and Setters
}

这篇关于JSF 2.X在两个xhtml页面之间传递参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆