4 Replies Latest reply on Sep 29, 2008 4:26 AM by Martin Höller

    Rerendering input elements without loosing input

    Martin Höller Newbie

      Hi all!

      I'm using a4j to enable/disable some calendar input field based on the value of a selection box. I do this by using the following code (simplified)

      <h:selectOneListbox size="1" value="#{mybean.variant}">
       <f:selectItems value="#{mybean.allVariants}"/>
       <a4j:support event="onchange" action="#{mybean.doSomething()}" reRender="date2disabler,date2" />
      </h:selectOneListbox>
      ...
      <rich:calendar id="date2" value="#{mybean.date2}" disabled="#{not mybean.timeRange}"/>
      <h:selectBooleanCheckbox id="date2disabler" value="#{mybean.timeRange}" disabled="#{mybean.variant == 'V1'}">
       <a4j:support event="onchange" reRender="date2"/>
      </h:selectBooleanCheckbox>

      The problem I have is the following: if a user enters some date in the calendar input date2 and afterwards changes the selectOneListbox, date2 is to be rerendered (and eventually disabled). However, the input entered by the user is lost because of this rerendering.

      Is there some easy way to not loose the values?

      many thanks in advance,
      - martin