*
The moose likes JSF and the fly likes Saving the value of a bean property in a hidden field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Saving the value of a bean property in a hidden field" Watch "Saving the value of a bean property in a hidden field" New topic
Author

Saving the value of a bean property in a hidden field

Khaled Mahmoud
Ranch Hand

Joined: Jul 15, 2006
Posts: 361
Hi all,

I have request scoped JSF managed bean. This bean has a property named answers of type Hashtable. How can I save this property state in a hidden field in an html form.

I get a conversion error when I try to do so.

Any ideas are appreciated.

Thanks in advance.

[ May 03, 2008: Message edited by: Khaled Mahmoud ]

[ May 03, 2008: Message edited by: Khaled Mahmoud ]
[ May 04, 2008: Message edited by: Khaled Mahmoud ]

SCJP, SCJD,SCWCD,SCDJWS,SCEA 5 MCP-C#, MCP-ASP.NET - http://www.khaledinho.com/
Life is the biggest school
Tom Fulton
Ranch Hand

Joined: Mar 30, 2006
Posts: 94
Could you explain what you plan to do with the hidden field?

JSF is designed in such a fashion that directly saving and manipulating hidden fields is often unnecessary. The state of a component is automatically saved on the server, or automatically saved in a hidden field if you specify the state saving strategy as "client".

If you explain what you need it for, I might be able to give you a couple of options that will be easier.
Khaled Mahmoud
Ranch Hand

Joined: Jul 15, 2006
Posts: 361
I am studying the feasibility of implementing an exam engine on JSF instead of developing using pure servlets and jsps.

For example, the add multiple choice question allow the user to specify question text in a text field and possible choices.

I imagine the page containing a text field for question and an add choice button that when the user clicks will add to the page a row containing text field (for choice text) and check box for whether this is a correct choice or not.

Can such a page be created in JSF and what is the approach or components used in creating it ??

I developed such a page using pure a combination of javascript and jsp and servlets. When the user clicks on the add button, i use javascript to dynamically create a row which contains checkbox and an input of type text.

Any ideas on how such a page can be implemented in JSF ??
KRK Gowda
Ranch Hand

Joined: Nov 02, 2004
Posts: 132
Hi,
I am facing similar situation. I have a hidden field for storing label, on which table needs to sorted.
Sorting is taken care in DB calls.
Based on the value of hidden field, i want to switch queries.

Regards,
Khaled Mahmoud
Ranch Hand

Joined: Jul 15, 2006
Posts: 361
Hello,

I have written a custom converter class that can save any serializable
object into a hidden field.

The idea is to convert the binary representation of
a Java object to base64 and vice versa.

Here is the code :



After you compile this class and include it in your project class path, you add an entry to this converter in the faces-confing.xml file like the following :



And finllay in the JSF page, you have the following :



For the base64 libraries used in the converter, they can be download from the below URL :

http://ostermiller.org/utils/download.html

Hope this helps

[ May 06, 2008: Message edited by: Khaled Mahmoud ]
[ May 06, 2008: Message edited by: Khaled Mahmoud ]
 
 
subject: Saving the value of a bean property in a hidden field
 
Similar Threads
Pre submission check
Problem running RMI on Netbeans 5.0
Passed SCWCD
Complete SCEA 5 Exam Survey /Free exam voucher $200 US Value
Passed with 387/400