*
The moose likes JSF and the fly likes Example to make JSF work with DWR Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Example to make JSF work with DWR" Watch "Example to make JSF work with DWR" New topic
Author

Example to make JSF work with DWR

Vijay Bala
Greenhorn

Joined: Oct 25, 2001
Posts: 25
Hi,

I have been trying to get JSF to work with DWR.I keep getting a javascript error on the onblur where I call the Serverside JavascriptBasic HTMl code works fine but it sarts failing as soon as I introduce JSF JSP tags. I have read the DWR links on JSF Integration.

I am trying to populate the city and state based on the zip from a DB.I have dwr.xml setup along with web.xml. As i said, the example works fine with plain old HTML but when i try to introduce JSF , it doesn't like the
DWR tags to get the value in the onblur.
Any help or any example showing some code example is appreciated.

I am not able to post my code.Tried a few times and changed the < etc.

TIA,
Vijay
Gerardo Tasistro
Ranch Hand

Joined: Feb 08, 2005
Posts: 362
I've noticed that JSF checks the value in the posted form versus the selectItems on the server side. So if for example :



Say for example that stateItems returns as the list of Mexican states. Then through Ajax I change that list to US states. JSF will once again rebuild stateItems, realize that the posted state ID isn't in the select list and create a validation error. You have to tell your managed bean that the list changed too.

So what I do is use the verbatim tag to place a facade HTML code on the page with some javascript that copies those values to a hidden field. I have a state select which isn't linked to any JSF component and a hidden field with the state value. On page load the list is populated with the state values and the hidden state value is set. The user can work all he wants with Ajax. On submit the select value is copied to the hidden field and posted.

It isn't real JSF / AJAX integration, but it has two benefits. One it is simple. Two it lets me test AJAX independent of JSF. Kinda like a view inside a view. Once your done working with those values, they get copied to the hidden fields and posted.
 
 
subject: Example to make JSF work with DWR
 
Similar Threads
Use of Javascript with struts custom tag <html:button> and <html:submit>
Struts 1.1 and DWR or Ajax
Can't access dwr.util in Jspx page of Spring MVC application
Pass values from pop up window to parent window using jsf
onblur attribute is not working