Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can't get innerHTML from inputText

 
J Miller
Ranch Hand
Posts: 80
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 80
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
figured this out. Just in case anybody else comes across this, instead of using:



use:

 
Tim Holloway
Saloon Keeper
Pie
Posts: 17626
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
J Miller
Ranch Hand
Posts: 80
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 17626
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 80
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic