如何获取Javabean中的ui:param值

发布于 2024-08-26 10:24:03 字数 599 浏览 4 评论 0原文

我正在学习facelets和Seam,我面临以下问题:我有2个xhtml文件,一个包含另一个,每个文件都有自己的Seam组件作为支持bean。我想发送对象并发送对象到包含的 Facelet,并在与包含的 Facelet 相对应的支持 bean 中获取该对象。我将举一个例子来更好地解释这种情况:

  • registration.xhtml,以 Seam 组件作为支持 bean Registration.java。在这个类中,我有一个 Person address.html 类型的对象,
  • 其中 Seam 组件作为支持 bean Address.java。在此类中,我想从注册组件获取 Person 对象并设置地址。
  • Registration.xhtml 包含 address.xhtml 并使用

How to acquire this object in Address bean? 传递一个对象注册 bean 中的对象引用是否相同? ui:param 是传递该对象的解决方案还是有其他解决方案? (也许是f:attribute,但即使在这种情况下,我如何获取bean中的对象)

这个例子很简单,不一定现实,但我有类似的问题,我不知道如何解决它。

提前致谢。

I am learning facelets and Seam and I'm facing the following problem: I have 2 xhtml files, one includes the other and each one has its own Seam component as backing bean. I want to send and object to the included facelet and obtain that object in the backing bean corresponding to the included facelet. I'll take an example to explain better the situation:

  • registration.xhtml with Seam component as backing bean Registration.java. In this class I have an object of type Person
  • address.html with Seam component as backing bean Address.java. In this class i want to obtain the Person object from the Registration component and set the address.
  • registration.xhtml includes the address.xhtml and passes an object using

How to obtain this object in Address bean? Will be the same reference of the object from the Registration bean? ui:param is the solution of passing this object or there is another solution for that? (maybe f:attribute, but even in this case how do I obtain the object in bean)

This example is simple and not necessarily realistic but I have a similar problem and I don't know how to solve it.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云淡月浅 2024-09-02 10:24:03

您可以使用页面操作来连接您的 bean

<page view-id="/registration.xhtml">
    <action execute="#{registrationBackingBean.wire}"/>
</page>

...

@Name("registrationBackingBean")
public class RegistrationBackingBean {

    @In(required=false)
    private Person person;

    @In(required=false)
    private Address address;

    public void wire() {
        person.setAddress(address);
    }

}

如果您想在初始请求 (GET) 期间进行连接,请执行以下操作

<page view-id="/registration.xhtml">
    <action execute="#{registrationBackingBean.wire}" if="#{empty param['javax.faces.ViewState']}"/>
</page>

You could use a Page action to wire your bean

<page view-id="/registration.xhtml">
    <action execute="#{registrationBackingBean.wire}"/>
</page>

...

@Name("registrationBackingBean")
public class RegistrationBackingBean {

    @In(required=false)
    private Person person;

    @In(required=false)
    private Address address;

    public void wire() {
        person.setAddress(address);
    }

}

If you want to wire during an initial request (GET), do as follows

<page view-id="/registration.xhtml">
    <action execute="#{registrationBackingBean.wire}" if="#{empty param['javax.faces.ViewState']}"/>
</page>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文