2 Replies Latest reply on Apr 16, 2010 12:51 PM by bleah

    rich:listShuttle how to deny item remove based on item data

      Hi,

       

      I'm new to Richfaces and also to JSF so I'm hoping that you guys could give me some direction how I could solve my problem.

       

      I have a need for functionality where based on item data in listShuttle, item is not allowed to be removed from target list. Item that can not be removed could be handled as disabled option in list so user can not even select it or then error message is displayed if user tries to remove item that shouldn't be removed.

       

      What is the best way to implement this kind of functionality?

        • 1. Re: rich:listShuttle how to deny item remove based on item data
          nbelaevski

          Hi Tero,

           

          There's "onlistchange" cancelable event that you can use to prevent list changes on the client-side + you'll need validator on the server-side (for the case of users bypassing client-side checks).

          • 2. Re: rich:listShuttle how to deny item remove based on item data

            Hi,

             

            Thanks for your answer Nick.

             

            I have tried now to find out  how can I get the selected items in onlistchange event but I can't figure it out.

             

            Let say if my list shuttle would be like following:

             

             

            <rich:listShuttle id="myShuttle" sourceValue="#{myBean.sourceItems}" converter="itemConverter"targetValue="#{myBean.targetItems}" var="myItem" onlistchange="#{rich:component('myShuttle')};">
            <rich:column>
              <h:outputText value="#{myItem.someVariable}"></h:outputText>
            </rich:column>
            </rich:listShuttle>

             

            Am I trying to get the myShuttle component in correct way? If yes how can I get the selected values?