6 Replies Latest reply on Jan 10, 2008 9:56 PM by nathan dennis

    Scriptaculous Sortable List Integration with Seam Remoting

    nathan dennis Expert

      Trying to get Sortable List working with Seam 2.0.... im a little stumped on the connection between seam remoting and handling the Sortable.serialize('id_of_list'). quick example. for a php call we might use something like

      Sortable.create('item_list', {constraint:'vertical', onUpdate : updateOrder});
      ....
      function updateOrder(){
       var options = {
       method : 'post',
       parameters : Sortable.serialize('item_list')
       };
      new Ajax.Request('sort.php', options);
      }
      

      from scriptaculous lib, i realize that serialization creates an array in the form of [0]=>{id}, [1]=>{id}, [2]=>{id} by striping off the first part of the ids (ex "label_" ).
      has anyone successfully integrated this with seam using remoting? could you point me in the right direction? should i try to capture this using webremote somehow and try to parse it in a session bean to come up with a server side array i can work with?


      saw this already.. nothing much happening there
      http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3943273#3943273

      apparently gavin and shane were working on it. any examples?

        • 1. Re: Scriptaculous Sortable List Integration with Seam Remoti
          Pete Muir Master

          I don't think this went anywhere, sorry.

          • 2. Re: Scriptaculous Sortable List Integration with Seam Remoti
            Shane Bryzak Master

            I don't really understand what you are trying to do, but can't you just sort your list server-side?

            • 3. Re: Scriptaculous Sortable List Integration with Seam Remoti
              nathan dennis Expert

              it took me a bit, but after i stopped trying to make theirs serialization work,, and used my head,,, i came up with a workaround.
              what i was trying to do was get the graphically ordered list to the server so i could sort it in an array and persist any changes.


              created session bean with a string field and use seam remote.

              Sortable.create('list',{onUpdate:function(){
               var orderLayerList = '';
               var orderedNodes = document.getElementById('list').getElementsByTagName('li');
               for (var i = 0; i < orderedNodes.length; i++) {
               orderLayerList += orderedNodes
               .getAttribute('id') + ', ';
               }
               Seam.Component.getInstance('someAction').parseLayerList(orderLayerList);
               var ef = new Effect.Highlight('list',{});}});
              

              parse the string with a tokenizer.

               StringTokenizer line = new StringTokenizer(list,", ", false);
               int tokencount = line.countTokens();
               log.info("token count" + tokencount);
               List<String> layerarray = new ArrayList<String>();
               for (int dem=0; dem < tokencount ; dem++){
               layerarray.add(line.nextToken());
               log.info(layerarray.get(dem).toString());
               }
              

              then i got distracted and i havent finished the rest. but now it is in an array and should be no problem.

              was that a good approach? seemed to work.

              thanks for the response though.

              • 4. Re: Scriptaculous Sortable List Integration with Seam Remoti
                nathan dennis Expert

                the one question i do have is.
                how can i cause an existing container generated by a4j:outputPanel to reRender from the java script?
                i thinking something like

                A4J.AJAX.Submit('_viewRoot','form_name',event,{'parameters':{'form_name:refresh':'form_name:refresh'} ,'actionUrl':'/url/topage.seam'} );return false;
                


                got that from creating a refresh button for the panel i wanted to rerender.. and looking at the generated html. the parameters are wrong for executing it from js. im not sure where the link to the div im rerendering is. ive been looking for some documentation on the structure of the A4J.AJAX.Submit( method with no luck.

                any pointers? looking back at my own post im not sure that made any sense. maybe nonsense.

                • 5. Re: Scriptaculous Sortable List Integration with Seam Remoti
                  Shane Bryzak Master

                  It might be best to ask this in the Ajax4JSF forum.

                  • 6. Re: Scriptaculous Sortable List Integration with Seam Remoti
                    nathan dennis Expert

                    looking back... that might have been a stupid question. i promise the read the documentation more closely next time. kudos for a well constructed javascript interface. i guess the concept of a response just seem too complicated yesterday... let alone actually do something with it. what really helped was capturing some packets and seeing what was going over the line.
                    im learning. it makes more sense now.
                    thanks for your patience.