• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF updating class object variables

 
Rob Brownsell
Greenhorn
Posts: 5
Firefox Browser Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I hope the subject isn't too ambiguous but does anyone know if it is possible for the attributes in a member object of a backing bean to be updated automatically in the JSF? Basically, I have a backing bean which has an object (Contact) and I am displaying the variables in the contact in the following way:
<af:inputText label = "Forename" value = "#{contactsManagedBean.contact.forename}" />
Which seems to be fine for display. However, when I submit a form (unlike if attribute belonged to the managed bean, e.g. contactsManagedBean.forename) the attributes in the object are not being updated.

Does anyone know why this might be or if there is an component similar to a table which allows the component to be cast back to the object from where they were derived? (as in table rows)

Hope this makes sense.
 
Tim Holloway
Bartender
Posts: 18417
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I'm reading this correctly, you have a backing bean object with contains another object and you wish to display and update properties of that object.

I do this all the time, both in JSF and in Struts. Under the rules of the Unified Expression Language, it's quite legal.

EL is usually only dealt with in passing, but it's worth studying in its own right. There's an entire independent subsystem in the jakarta project just for EL. It provides the EL services for Struts and Tomcat, among other things.
 
Rob Brownsell
Greenhorn
Posts: 5
Firefox Browser Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim, nice to know I'm not doing anything too out of the ordinary! I've now realised where I was going wrong, basically I was using an ADF component panelForm which didn't seem to like updating the bean attributes (probably not using it in the correct way). I've since moved to a standard form and everything seems to be working fine. BTW I've started to make a lot of my backing beans (ones for display) as session scope. When doing things like refreshing the page or going back, objects such as tables were being nullified. If I'm only doing this for display areas, does this seem ok? (Business logic is being handled by Spring).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!