• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.!
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could think of two other approches
1. Implementing the javascript logic inside ManagedBeans
2. Writing Custom Converters
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic