You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Claudio Tasso <ta...@libero.it> on 2006/02/19 19:24:31 UTC
Question about javascript Listeners
Hi,
I'm looking at Javascript components (such as jsValueSet or
jsValueChangeListener) and I'm wandering if they suit my needs.
One of the most common use case in my application is the following:
there are a selectBooleanCheckbox and an inputText. When the checkbox is
selected, the inputText is enabled; if the checkbox is not selected,
then the inputText is disabled.
The JSP fragment is something like this:
<h:selectBooleanCheckbox onclick="this.form.submit();"
value="#{myBean.booleanValue}"/>
<h:inputText disabled="#{!myBean.booleanValue}"
value="#{myBean.textValue}" />
This technique implies a post to the server.
My goal is obtaining the same result without reloading the page.
But using jsValueChangeListener does not solve this problem. Look at the
following code:
<h:selectBooleanCheckbox>
<t:jsValueChangeListener for="text1" property="disabled"
expressionValue="($srcElem.checked?)'disabled':''"/>
</h:selectBooleanCheckbox>
<h:inputText disabled="#{!myBean.booleanValue}" id="text1"
value="#{myBean.textValue}"/>
The inputText in the page appears enabled when the user selects the
checkbox (so he can insert some text inside it), but the problem is
that the model in not updated when the form is submitted (i.e.
myBean.textValue is still empty). In fact, according to the JSF View
the inputText is still disabled and its value is not decoded.
Does any Tomahawk component which solve this problem exist?
Thank you very much for your help.
RE: Question about javascript Listeners
Posted by Frank Felix Debatin <ff...@gmx.net>.
Hi Claudio,
this is how it works with ADF - very intuitively, but use with care, we
found the feature to be a bit fragile.
<af:selectOneRadio
autoSubmit="true"
id="radioButtons"
value="#{some_boolean_value}">
...
</af:selectOneRadio>
<af:inputText
partialTriggers="radioButtons"
disabled="#{some_boolean_value}"
value="....">
...
</af:inputText>
Should certainly work the same with checkboxes.
Regards
Frank Felix
-----Original Message-----
From: Claudio Tasso [mailto:tassoc@libero.it]
Sent: Sunday, February 19, 2006 7:25 PM
To: MyFaces Discussion
Subject: Question about javascript Listeners
Hi,
I'm looking at Javascript components (such as jsValueSet or
jsValueChangeListener) and I'm wandering if they suit my needs.
One of the most common use case in my application is the following:
there are a selectBooleanCheckbox and an inputText. When the checkbox is
selected, the inputText is enabled; if the checkbox is not selected, then
the inputText is disabled.
The JSP fragment is something like this:
<h:selectBooleanCheckbox onclick="this.form.submit();"
value="#{myBean.booleanValue}"/>
<h:inputText disabled="#{!myBean.booleanValue}"
value="#{myBean.textValue}" />
This technique implies a post to the server.
My goal is obtaining the same result without reloading the page.
But using jsValueChangeListener does not solve this problem. Look at the
following code:
<h:selectBooleanCheckbox>
<t:jsValueChangeListener for="text1" property="disabled"
expressionValue="($srcElem.checked?)'disabled':''"/>
</h:selectBooleanCheckbox>
<h:inputText disabled="#{!myBean.booleanValue}" id="text1"
value="#{myBean.textValue}"/>
The inputText in the page appears enabled when the user selects the checkbox
(so he can insert some text inside it), but the problem is that the model in
not updated when the form is submitted (i.e.
myBean.textValue is still empty). In fact, according to the JSF View the
inputText is still disabled and its value is not decoded.
Does any Tomahawk component which solve this problem exist?
Thank you very much for your help.