This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can we access a variable in <h:outputText> tag?

 
Nagendra Shastry
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Can we access a variable inside a rich model panel's <h: output Text > tag's value attribute? I need to display something like <h:output Text value ="This will affect '+VARIABLE+' records"> . I have to calculate the value of variable from a java script code. Please help me out.!
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18092
48
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No you cannot do that. Because the outputText text is rendered BEFORE the page is sent to the client, and therefore before the JavaScript runs.

What you can do is have JavaScript alter the text of that control AFTER the page is rendered as a standard DOM modification process. You can even use jQuery to do the job, since jQuery is automatically included as part of RichFaces.

Don't forget, however, that when using jQuery in JSF that the "$()" expression form should be avoided (use the "jQuery()" form) and that the ID of the outputText control that the will be the element's low-level ID, and not the simple "id=" value in the JSF control.
 
Balaji Manoharan Bm
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could think of two other approches
1. Implementing the javascript logic inside ManagedBeans
2. Writing Custom Converters
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic