There is a reasonably good demo on the Scriptaculous site: http://demo.script.aculo.us/ajax/sortable_elements
The view source shows an example of view/controller. It's in Ruby, but the same should hold for Java. The idea seems to be that you use request.getParameterValues(key) which returns an array of the ids in the order in which they appear on the screen. Mike. On 8/30/07, JBlythe <[EMAIL PROTECTED]> wrote: > > > Okay! I think your first suggestion (i.e. Using Ajax) is the way forward. > As > I mentioned in my original post, the script.aculo.us documentation > (http://wiki.script.aculo.us/scriptaculous/show/Sortable.serialize) > mentions > that the final list can be "serialized" and then used to submit (HTTP > POST) > the order of the Sortable via an Ajax call. > > I see that each <li> element can be given a unique 'id' in the form > id="string_id", which presumably is keyed off of to determine the new > order. > > The documentation also mentions: > poststring = Sortable.serialize('id_of_container',[options]); > > ...which populates poststring with an '&' delimited key/value pair Set. I > presume it is this poststring value that is to be HTTP POSTed back to the > Action/Manager on submit. > > Ever tried this out? Any suggestions for doing this? Do you know any good > resources I can review to help me? > > Thanks!! > > JB > > > > mraible wrote: > > > > You can get your information back to your application from the client > > in two ways: > > > > 1. Using Ajax - maybe use DWR or Prototype to call an Action/Manager > > and persist the value. > > > > 2. Put the value in a hidden field. When you submit the form, you can > > grab the value of the hidden field in your Action and do what you need > > to with it. > > > > Does that help? > > > > Matt > > > > On 8/29/07, JBlythe <[EMAIL PROTECTED]> wrote: > >> > >> Jeez, I'm grateful for your fast reply, but am confused. Perhaps I > should > >> restate the issue briefly. > >> > >> I retrieve an ordered list from the database that I can easily display > on > >> screen. No problems displaying the list in correct order. With a little > >> script.aculo.us magic, I can move the <li> elements around, and thus > >> change > >> (on-screen only) their order. > >> > >> How do I get that new order back into the application from the web > page? > >> > >> Does a hidden field really help? I don't see how... > >> > >> Cheers! > >> > >> JB > >> > >> > >> > >> mraible wrote: > >> > > >> > Yes, there's two things - one is persisting the order, the 2nd is > >> > using that persisted value to arrange the values on the UI. Maybe you > >> > can re-arrange the elements in your action before displaying them? > >> > > >> > Matt > >> > > >> > On 8/29/07, JBlythe <[EMAIL PROTECTED]> wrote: > >> >> > >> >> Matt!! > >> >> > >> >> Thanks for the prompt reply. AppFuse totally rocks. You're my hero. > >> Many > >> >> thanks for the great work. =^D =) > >> >> > >> >> I haven't tried your suggestion, but... how would a hidden field > >> return > >> >> the > >> >> "edit" made by rearranging a set of values in an on-screen list? I > can > >> >> see > >> >> that the ordering might be preserved, but the changes made by the > user > >> is > >> >> the critical thing that must be returned and committed to the > >> database. > >> >> Are > >> >> you suggesting a hidden element AND a little script that somehow > >> mirrors > >> >> the > >> >> changes to a hidden element? Or did I misunderstand your > >> suggestion...? > >> >> > >> >> :working: JB :working: > >> >> > >> >> > >> >> > >> >> mraible wrote: > >> >> > > >> >> > Have you tried putting the value in a hidden field? There's a > >> >> > createFormElement method you can use to create a hidden field > >> >> > on-the-fly. For example: > >> >> > > >> >> > createFormElement("input", "hidden", "encryptPass", > >> >> > "encryptPass", > >> >> > "true", passwordField.form); > >> >> > > >> >> > Matt > >> >> > > >> >> > On 8/29/07, John Blythe <[EMAIL PROTECTED]> wrote: > >> >> >> > >> >> >> > >> >> >> Hey Folks: > >> >> >> > >> >> >> I have a question regarding AppFuse, script.aculo.us, and AJAX. > >> >> >> > >> >> >> script.aculo.us includes a REALLY useful and slick feature of > >> >> "Sortable" > >> >> >> lists, that allow users to drag and drop items around the screen, > >> >> >> arranging > >> >> >> the items as they like. (See demo here: > >> >> >> > >> >> > >> > http://wiki.script.aculo.us/scriptaculous/page/print/GhostlySortableDemo) > >> >> >> > >> >> >> According to the script.aculo.us documentation > >> >> >> > >> (http://wiki.script.aculo.us/scriptaculous/show/Sortable.serialize), > >> >> >> the final list can be "serialized" and then used to submit (HTTP > >> POST) > >> >> >> the > >> >> >> order of the Sortable via an Ajax call. > >> >> >> > >> >> >> ________________________________ > >> >> >> > >> >> >> I am currently running AppFuse 1.9.4 with WebWork (though I am > >> >> >> considering > >> >> >> moving to 2.0 with Struts 2 real soon - looks great). I'm using > >> Tomcat > >> >> >> 5.5.23, MySQL 5.0.45, and Linux (Ubuntu). Typically, I use > FireFox > >> >> >> 2.0.0.6 > >> >> >> as my browser. > >> >> >> > >> >> >> In my application, each user can have their own set of favorite > >> >> items, > >> >> >> and > >> >> >> order them as they please. Currently, I am implementing this with > a > >> >> >> 'select' > >> >> >> and using the moveOptionUp()/moveOptionDown() scripts that Matt > >> Raible > >> >> >> bundled in the selectbox.js file. No probs. > >> >> >> > >> >> >> Nonetheless, I thought this "Sortable" feature would be a > >> super-duper > >> >> UI > >> >> >> to > >> >> >> enable a quick, easy, sexy drag-and-drop user experience for > >> arranging > >> >> a > >> >> >> list of favorites. So I gave it a try. > >> >> >> > >> >> >> I can render the favorites list on the screen easily using a > >> WebWork > >> >> >> iterator: > >> >> >> > >> >> >> > >> >> >> > >> >> >> <ul id="userFavoritesList"> > >> >> >> <ww:iterator value="user.favoritesList"> > >> >> >> <li><ww:property value="id"/>: <ww:property > >> value="favorite"/></li> > >> >> >> </ww:iterator> > >> >> >> </ul> > >> >> >> > >> >> >> <script type="text/javascript"> > >> >> >> > >> Sortable.create('userFavoritesList',{ghosting:true,constraint:false}) > >> >> >> </script> > >> >> >> > >> >> >> The "Sortable" works great, allowing me to arrange the items > >> >> >> willy-nilly. I > >> >> >> love it! Just the kind of sexy user experience I was hoping for. > >> >> >> > >> >> >> ________________________________ > >> >> >> > >> >> >> HERE'S MY PROBLEM: > >> >> >> Once I have re-arranged this list on screen, how do I > >> submit/commit > >> >> this > >> >> >> newly ordered list back to the application/database? Has anyone > >> tried > >> >> >> this? > >> >> >> I guess I serialize the list, as mentioned in the script.aculo.us > >> >> >> documentation mentioned above. How exactly do I capture this > >> >> serialized > >> >> >> object in the Java application? Once I get that rearranged list > >> back > >> >> into > >> >> >> the Action as a List object (or other native Java Collection) I > am > >> >> >> confident > >> >> >> I can take things form there.... but exactly how? > >> >> >> > >> >> >> > >> >> >> Hopefully, someone has tried this within the framework of > AppFuse, > >> >> and > >> >> >> will > >> >> >> be able to give a short reply, but I would also love to hear from > >> folk > >> >> >> who > >> >> >> haven't tried it, and are also interested. Likewise, if someone > >> thinks > >> >> >> I'm > >> >> >> asking a dopey question, then go ahead and say so. Or perhaps > >> redirect > >> >> me > >> >> >> to > >> >> >> another website that spells this sort of thing out. It's all > good. > >> >> >> > >> >> >> Thanks in advance! > >> >> >> > >> >> >> JB > >> >> >> > >> >> >> > >> >> >> ________________________________ > >> >> >> View this message in context: AppFuse: script.aculo.us Sortable > >> Lists > >> >> >> Question > >> >> >> Sent from the AppFuse - User mailing list archive at Nabble.com. > >> >> >> > >> >> > > >> >> > > >> >> > -- > >> >> > http://raibledesigns.com > >> >> > > >> >> > > >> --------------------------------------------------------------------- > >> >> > To unsubscribe, e-mail: [EMAIL PROTECTED] > >> >> > For additional commands, e-mail: [EMAIL PROTECTED] > >> >> > > >> >> > > >> >> > > >> >> > >> >> -- > >> >> View this message in context: > >> >> > >> > http://www.nabble.com/AppFuse%3A-script.aculo.us-Sortable-Lists-Question-tf4351829s2369.html#a12400364 > >> >> > >> >> Sent from the AppFuse - User mailing list archive at Nabble.com. > >> >> > >> >> > --------------------------------------------------------------------- > >> >> To unsubscribe, e-mail: [EMAIL PROTECTED] > >> >> For additional commands, e-mail: [EMAIL PROTECTED] > >> >> > >> >> > >> > > >> > > >> > -- > >> > http://raibledesigns.com > >> > > >> > --------------------------------------------------------------------- > >> > To unsubscribe, e-mail: [EMAIL PROTECTED] > >> > For additional commands, e-mail: [EMAIL PROTECTED] > >> > > >> > > >> > > >> > >> -- > >> View this message in context: > >> > http://www.nabble.com/AppFuse%3A-script.aculo.us-Sortable-Lists-Question-tf4351829s2369.html#a12400514 > >> > >> Sent from the AppFuse - User mailing list archive at Nabble.com. > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: [EMAIL PROTECTED] > >> For additional commands, e-mail: [EMAIL PROTECTED] > >> > >> > > > > > > -- > > http://raibledesigns.com > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > -- > View this message in context: > http://www.nabble.com/AppFuse%3A-script.aculo.us-Sortable-Lists-Question-tf4351829s2369.html#a12400689 > Sent from the AppFuse - User mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
