objectjsf-2nestednested-properties

How to use nested objects in JSF 2.0


<h:outputLabel value="#{bundle.CreateCustomerLabel_email}" for="email" /> 
<h:inputText id="email" value="#{customerController.selected.email}" title="#{bundle.CreateCustomerTitle_email}" /> 

<h:outputLabel value="Address:" for="addressId.address" /> 
<h:inputText size="30" id="address" value="#{customerController.selected.addressId.address}" title="Address" >
</h:inputText>

In Cutomer Entity bean I've got:

@JoinColumn(name = "address_id", referencedColumnName = "address_id")
@ManyToOne(optional = true, cascade={CascadeType.ALL})
private Address addressId;

In Address Entity bean I've got:

Basic(optional = true)
@NotNull
@Size(min = 1, max = 50)
@Column(name = "address")
private String address;

QUESTION: How can I use nested properties in JSF 2.0 forms? Should I implement nested forms or how?

Thanks in advance! Sami


Solution

  • Do you have get methods for addressId and address? The for attribute in the second Label must be for="address".