Forums Register Login

ValueChangeListener complex objects

+Pie Number of slices to send: Send
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...
1
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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...
Danger, 10,000 volts, very electic .... tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1383 times.
Similar Threads
JavaScript Arrays
Passing objects w/ JNI
HttpSessions in non-servlets
selectOneMenu ValueChangeListener not Firing
Need to retrieve only perticular attributes from table
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 07:45:59.