aspose file tools*
The moose likes JSF and the fly likes Can't get innerHTML from inputText Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Can Watch "Can New topic
Author

Can't get innerHTML from inputText

J Miller
Ranch Hand

Joined: Oct 21, 2010
Posts: 67
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.
J Miller
Ranch Hand

Joined: Oct 21, 2010
Posts: 67
figured this out. Just in case anybody else comes across this, instead of using:



use:

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16222
    
  21

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.


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

Joined: Oct 21, 2010
Posts: 67
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.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16222
    
  21

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.
J Miller
Ranch Hand

Joined: Oct 21, 2010
Posts: 67
I didn't know that. I'm gonna try that out today, because that's definitely easier than how I'm doing it. I'll let you know how it works!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can't get innerHTML from inputText