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?
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.
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...
Post by:autobot
Danger, 10,000 volts, very electic .... tiny ad:
a bit of art, as a gift, the permaculture playing cards