• Post Reply Bookmark Topic Watch Topic
  • New Topic

composite component with backing bean  RSS feed

 
Tony David
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,

I have a parent backing bean with its associated xhtml file PersonBean with Person.xhtml.
In person.xhtml, I want to use a composite component address

I want to get all values of my address composite component in PersonBean after clicking on a Person.xhtml's button.



address implementation is like that :



So, I am wondering if I must associate a bean with my address component and try to get it in PersonBean or if a simpler way exists to handle all address values
when I validate my Person with the method personBean.validate
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a little unusual to name an action method "validate", since a lot of the validation in JSF is done automatically before the action method is even invoked. However, that's just an observation.

If you wish to capture or display data using a JSF value= attribute, the value needs to specify an EL expression that references a bean property. Otherwise JSF has no idea where to put the data it receives.

For a composite object, you can use either direct references or parameter-based references but ultimately the references must resolve to bean properties.
 
Tony David
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a little unusual to name an action method "validate", since a lot of the validation in JSF is done automatically before the action method is even invoked. However, that's just an observation.


I used the key word validate in this example to keep simple code but not in my real case.

For a composite object, you can use either direct references or parameter-based references but ultimately the references must resolve to bean properties.


Yes, I agree, I created an Address Oject then I instanciate it in my ParentBean. With this way I can handle personBean.address.addressField directly in my address composite component.

I wanted to avoid to create all my address fields in each bean which would be a container of address. By using a dedicated Address Object in each container bean, I can use my composite component with this way.

Thanks for your help and sorry my late reply
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!