webtier@glassfish.java.net

Setting the class attribute of a h:inputHidden component

From: <webtier_at_javadesktop.org>
Date: Tue, 03 Nov 2009 02:06:44 PST

I would like to set the class attribute of a h:inputHidden component so that I may manipulate it using javascript. Currently, I'm unable to do this since the h:inputHidden does not have a styleClass attribute. Is there some other way to set the class attribute of this component?

An example usage for this is clearing a form value:

[code]
<div id="container">
  <h:inputHidden class="x-value" value="#{bean.value}">
  <input type="button" onclick="clear()" value="clear"/>
</div>

<div id="container2">
  <h:inputHidden class="x-value" value="#{bean2.value}">
  <input type="button" onclick="clear()" value="clear"/>
</div>
[/code]

The following script would then clear the hidden element in the contained in the same div as the button.

[code]
  function clear(event) {
    $(event.target).parent().children(".x-value").val("");
  }
[/code]

So how can I set the class attribute of a input hidden element?

Thanks
[Message sent by forum member 'janderssn' (janderssn_at_gmail.com)]

http://forums.java.net/jive/thread.jspa?messageID=370292