3 Replies Latest reply on Sep 5, 2008 1:48 PM by nbelaevski

    Disable some records of listShuttle

    evguen

      Hello,

      I am wondering if it is possible to disable some records of a listShuttle.

      Let's say I have 20 elements in the left column. They are of two categories : fruits and vegetables. I wawnt the user to be able to move ONLY fruits to the right column. And if he tries to move a vegetable, then display an error message or do nothing.


      I found a solution with a4j:support, but I have a trouble with this :

      <t:div id="marketSelection">
       <rich:listShuttle
       sourceValue="#{market.selection.freeItems}"
       targetValue="#{market.selection.items}"
       ... >
       <rich:column>
       <h:graphicImage value="#{items.iconURI}" />
       </rich:column>
       <rich:column width="500">
       <h:outputText value="#{items.label}" />
       </rich:column>
       <a4j:support event="onlistchanged" reRender="marketSeletion"
       action="#{market.checkSelection}" />
       </rich:listShuttle>
      <t:/div>
      



      The method checkSelection checks that the right column does not contain vegetable, and if so moves it back to the left column. Then I enable an error message.

      The problem is that at each list update (event="onlistchanged") if there is a scrollbar in the left column, it goes back to the top of the list. I found this quite confusing for the user, because he must scroll down back to the last position to continue his job.

      Is there a way to make an "autoscroll" when the list is updated ?
      Or is there a way to check the type of the record in javascript before the list is updated to cancel the update if it is a vegetable ? I mean I can put a tag in the ID of each object to distinguish vegetable from fruits. So how could I check the ID(s) of the selected elemnt(s) ?
      Is there another way to deal with this ?

      Thanks in advance for your help

      Regards