mihaela
mihaela

Reputation: 219

How to get the ui:param value in Javabean

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:

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.

Upvotes: 1

Views: 1265

Answers (1)

Arthur Ronald
Arthur Ronald

Reputation: 33785

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>

Upvotes: 1

Related Questions