This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JSF and the fly likes send json object to jsf backing bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "send json object to jsf backing bean " Watch "send json object to jsf backing bean " New topic
Author

send json object to jsf backing bean

pradeep gamage
Ranch Hand

Joined: Aug 03, 2009
Posts: 85

I am creating multi step registration. when first step next button click i want to send those data to jsf backing bean so i wroje jquery script. but i am not sure how to add URL here. this is my jquery code.


and how i can access json data object from jsf backing bean?
Thanks in advance...

Software Engineer(BSC):SCJP 1.5
(Knowledge is power when applied)
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15632
    
  15

HTTP is all about text, and JSON is a way to encode one or more client-side objects in an easily-parsed text sequence. So the first step is to provide a "set" method on your backing bean to accept the JSON data as a String.

The backing bean's "set" method can then use one of the ready-made JSON parsers to break down the string into usable java objects. There are a number of J2EE-compatible JSON format/parse libraries available, including one from json.org, another from SourceForge (net.sf.json), and one from Google.


Customer surveys are for companies who didn't pay proper attention to begin with.
pradeep gamage
Ranch Hand

Joined: Aug 03, 2009
Posts: 85

Thanks Tim Holloway, this is my jsf backing bean getter setter for string variable


but how i can assign value to this variable. How i can give URL in jquery

give me example.
Thanks in advance
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15632
    
  15

Don't use the "$" convention when doing jQuery in JSF. The EL processor will get confused and think you coded an EL expression. So instead of "$ajax", code "jQuery.ajax".

Your your sample expression is valid (except for the "$" part), but the important thing to note is that the EL expression "#{registerBean.jsonmsg}" is not dynamic. The JSF view processor will compile and evaluate the EL expression before that portion of the webpage is sent to the client, so effectively, the expression becomes a constant value that is equal to whatever value the jsonmsg property had when that part of the page was rendered. To update it, you'd have to re-render that section of the webpage.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: send json object to jsf backing bean
 
Similar Threads
Pass JSON object from server to jQuery and loop on the object
json object send to JSF backing bean to xhtml page
JSON response to populate listbox
Sending a jason object via Post
Spring MVC and JSON array