I'm trying to set up a a web page so that, when the user hits the Tab key to exit an inputText field, it saves that value to the backing bean. The application uses JSF 1.2, Richfaces 3.3.3, and the dojo JS framework. Here's a snippet of my code:
The problem is that the javascript function getting called isn't getting what I enter into the box. When I show it on the console, it's just blank. I've double-checked using FireBug to make sure that the ID I'm using in the dojo.byId statement is correct, and the syntax of the dojo.byId is correct. Any help would be great.
You are a glutton for punishment. I used dojo/dijit on a system about 18 months ago, blew a lot of time, and ended up having to work for free for several weeks. It didn't help any that dojo had temporarily fallen out of favor so help was rather scarce.
Personally, I've had better look with jQuery, but YMMV.
In any event, raw javascript is the hard way here, even when assisted by frameworks like dojo. JSF 1.2 supports AJAX. Instead of coding it all up by hand, doing an AJAX update of the selected property should be simpler.
thanks for the info. I'm not the biggest fan of dojo either, but we're already using the ArcGIS mapping system, which comes with dojo packaged in, so I figured it's better to try and use that than import another framework. I've never used JQuery more than just playing around with it, but it does seem superior. Hoping I can use it on our next project.
You may be interested to know that you're already using jQuery! I see in your example that you've got a4j (RichFaces) jsFunction. RichFaces uses jQuery to do its AJAX functions. It's not the absolute latest version of jQuery, but it's enough to get by. You don't even have to explicitly request it. The only caveat is that you can't use the "$" notation, since that confuses JSF's EL processor (use the "jQuery." form instead).
Incidentally, using RichFaces, this will update a backing bean property without any javascript on your part at all:
Live production code will often also include reRender options and an action method to be fired when the property updates.