• Post Reply Bookmark Topic Watch Topic
  • New Topic

Javascript getElementById equivalent in JSF ????  RSS feed

 
Patricio Hervas
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

I was wondering if i can access the properties of a regular html element from a JSF bean. What i want is to change the value of a DIV's css class property from a managed bean.

ej:

<div id="thisDiv" class="normal">
<t:inputText id="user" binding="#{bean.user}" required="true" />
</div>

So, during submit, if the inputText reports an error, i want to change
the DIV's class to "error" (for example), so that it would but a border or
do something around the inputText.
I know I could put something like
<div id="thisDiv" class="<t: outputText value="#{bean.user.isValid ? 'normal': 'error'}" />">
but i want to do it dinamically


Thanks a lot
[ March 29, 2006: Message edited by: Patricio Hervas ]
 
Sergey Smirnov
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If using <div> is important for you:
You will be able to do so in the comming JSF 1.2.
Currently, you can use JSF1.1+Facelets to reach the same right now.
Most likely you might be able to have it using JSP 2.0 EL . I.e. ${} syntax.

If you just want to have the same look-n-feel, you can use something like this:

<h: panelGroup style="display:block" id="likeThisDiv" class="#{bean.user.isValid ? 'normal': 'error'}">
....
</h: panelGroup>

--
Sergey : http://jsfTutorials.net
[ March 29, 2006: Message edited by: Sergey Smirnov ]
 
Patricio Hervas
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, i hope JSF 1.2 arrives soon.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!