The moose likes JSF and the fly likes JSF updating class object variables Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » JSF
Reply Bookmark "JSF updating class object variables" Watch "JSF updating class object variables" New topic
Author

JSF updating class object variables

Rob Brownsell
Greenhorn

Joined: Dec 16, 2004
Posts: 5

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
Saloon Keeper

Joined: Jun 25, 2001
Posts: 11740

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.


A lot the of modern-day software development platforms are designed to permit parcelling out work to those with the best aptitude for it. A lot of modern-day business is predicated on making one person do all the work, regardless of aptitude.
Rob Brownsell
Greenhorn

Joined: Dec 16, 2004
Posts: 5

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).
 
 
subject: JSF updating class object variables
 
developer file tools