1 Reply Latest reply on Jan 6, 2009 7:30 PM by Georges Berscheid

    Change values in backing bean before setting new value

    Martin Noname Newbie

      Hi,


      I have a Seam application with a list of checkboxes:



      <a4j:outputPanel id="auswahl1" layout="block">
        <ul>
          <a4j:repeat value="#{fd.subTree1}" var="item">
            <li>
              <span>
                <h:selectBooleanCheckbox value="#{fd.selectedGroupMap1[item]}">
                  <a4j:support event="onclick" reRender="auswahl1"/>
                </h:selectBooleanCheckbox>
                <h:outputText value="#{item.name}" />
              </span>
            </li>
          </a4j:repeat>
        </ul>
      </a4j:outputPanel>
      



      What I want to do:
      If the user clicks on one of the checkboxes, all other checkboxes shall be unchecked first (under a special condition - business logic, so I can't use radio buttons).


      The selectBooleanCheckbox uses a Map in my bean (fd) for saving all selected items:


      private Map<Item, Boolean> selectedGroupMap1;



      So there is no setter where I can clean the map before setting a new value.


      How can I do this? I tried an actionListener in the a4j:support element. But it is called after setting the newly checked item. So I have no selected items at all after calling the listener.


      Any ideas? Thanks in advance!


      Martin

        • 1. Re: Change values in backing bean before setting new value
          Georges Berscheid Newbie

          Unchecking the other checkboxes is probably something you want to do using JavaScript. When the form is submitted, the appliction has no way of knowing which checkbox was just clicked, unless you keep a previous state in the context and compare both states. That sounds awfully complicated though.
          You could also try using the ajaxSingle attribute in a4j:support which will only send this one particular event to the server instead of submitting the entire form. However, I've never actually used that, so I'm not exactly sure how it behaves.


          Good luck.
          Georges