myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Monshausen" <>
Subject AW: update values on checkbox click
Date Tue, 29 Jun 2010 07:48:44 GMT
Thanks Cédric,
I'll try it.
Thanks alot,


Von: Cédric Durmont []
Gesendet: Di 29.06.2010 09:15
An: MyFaces Discussion
Betreff: Re: update values on checkbox click

Hi Martin,

This seems to be the normal JSF behavior. Let me explain :
- first,  your boolean ra.kmt is false, inputText is present and
inputTextArea is not.
- after a click on your checkbox, ra.kmt is changed and becomes true.
So in the component tree, the inputText component is NOT present
(rendered=false). That's why it doesn't get the new value. I think it
might work if the checkbox was after the inputText, but I wouldn't
recommend you to expect this to always work in all cases.

However, the inputText should get a ValueChangeEvent, so if you add a
valueChangeListener, you should get the new value. You may want to
copy it yourself in ra.debitnote.

If it's possible for your project, another solution would be to work
with a jsf library such as Apache Trinidad. In Trinidad you have a
tr:inputText component that does inputText AND inputTextarea,
all-in-one, depending on the number of rows you set. Thus it would be
the very same component whether the checkbox is checked or not.

Your code with Trinidad would look like :

<tr:selectBooleanCheckBox value="#{ra.kmt}" autoSubmit="true" id="chooseSize"/>
<tr:inputText value="#{ra.debitnote}" rows="#{ra.kmt ? 4 : 1}"

Hope this helps,
Cedric Durmont

2010/6/28 Martin Monshausen <>:
> Hi community,
> would you mind taking a short look to the following problem, please?
> Depending on the value of a checkbox I want to show either an inputText-element or an
inputTextarea-element - as shown below. The default is, that the checkbox is disabled and
therefore the inputText will be shown. If the user enters some text to the textbox, I want
to transfer it to the inputTextArea.
> If I trigger some actions located on the page after text was entered and before checkbox
is clicked (communication with server took place) everything is working fine.
> If I click the checkbox right after entering the text only the changed value of the checkbox
is considered as changed (setter-method for DebitNote will not be called) and nothing is transferred
(assuming nothing was enter to the inputText before).
> What's wrong? Did I missed something? Is there any other solution you would suggest?
> //checkbox clicking on button in order to transfer state to server
> <h:selectBooleanCheckbox value="#{ra.kmt}" onclick="document.getElementById('updateButton').click();"
> //shown on startup; value should be transferred
> <h:inputText value="#{ra.debitnote}" rendered="#{!ra.kmt}" size="53" maxlength="50"
tabindex="1"  />
> //shown if checkbox is checked; value of inputText should be displayed
> <h:inputTextarea value="#{ra.debitnote}" rendered="#{ra.kmt}" rows="4" cols="42" tabindex="1"
> //just repaint site (only transfer state to server)
> <t:commandButton action="repaint" style="visibility:hidden;" forceId="true" id="updateButton"
> Thanks alot,
> Martin

  • Unnamed multipart/mixed (inline, None, 0 bytes)
View raw message