aspose file tools
The moose likes JSF and the fly likes ValueChangeListener complex objects Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "ValueChangeListener complex objects" Watch "ValueChangeListener complex objects" New topic
Author

ValueChangeListener complex objects

Ralph Hoch
Greenhorn

Joined: Jun 04, 2011
Posts: 4
Hi,

Is it possible to pass objects (beside from Strings, Ints...) via the ValueChangeEvent from JSF.
For example if a site calls a valueChangeListener I can access the new value via: event.getNewValue(). Is it possible to pass objects to this method?

Thank you...
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 14456
    
    7

The HTTP client (browser) is a text-based application. So you cannot directly send binary objects (class objects) to the client and get anything useful out of the effort. You can translate the object to a serial text format to get around that. for example, by using MIME encoding.

However, it's simpler/safer/more portable to keep the object on the server and just send/receive a text "handle" to the object. This could be, for example, a HashMap key that accesses the object. Which is what things like HTTPSession are doing. For simple non-text items such as ints, JSF's converters are automatically translating the binary (number) object to text and back again.

ValueChangeListener is not "called" by application code. It's an event handler that JSF fires off internally for controls that have valueChangeListeners attached to them when JSF discovers that an incoming HTTP form has a changed value for that control. All the standard JSF controls are sending/receiving text, so there's no class objects involved there. The RichFaces Shuttle control does work with complex objects. It's not part of Core JSF, however. And it does translate them into text references so that they can be sent/received as web page text. You have to supply your own converters for the objects being used.


Customer surveys are for companies who didn't pay proper attention to begin with.
Ralph Hoch
Greenhorn

Joined: Jun 04, 2011
Posts: 4
yes, after I thought that this might be the only solution (after I started thinking about it for while). However I thought that there might be a workaround or something, thus the question.
Serialize the object might be an idea, but, you're probably right, using an ID/Hash seems to be the better solution.

I'll have a look at Richfaces Shuttle Control as well.

Thank you for your thoughts on this...
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: ValueChangeListener complex objects
 
Similar Threads
HttpSessions in non-servlets
JavaScript Arrays
Need to retrieve only perticular attributes from table
selectOneMenu ValueChangeListener not Firing
Passing objects w/ JNI