You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jon Pearson <Jo...@sixnet.com> on 2009/06/17 15:57:36 UTC

RE: Option transfer select (WORKAROUND FOUND)

Well, I think something may be wrong with the Struts2 javascript code.
But I was able to make it work anyway by writing this function:

117 function selectAndSubmit() {
118 var list = document.getElementById("update_chosenColumns");
119 for (var i = 0; i < list.options.length; i++) {
120 list.options[i].selected = true;
121 }
122
123 var form = document.getElementById("update");
124 form.submit();
125 }

Which I call in the onclick="" handler for my form submission.

> -----Original Message-----
> From: Jon Pearson 
> Sent: Wednesday, June 17, 2009 9:10 AM
> To: Struts Users Mailing List
> Subject: Option transfer select
> 
> I am trying to get an option transfer select control to work, but I'm
> having difficulty getting the results back out of it.
> 
> It looks like the control passes values in the two lists back to the
> server by selecting all items in each list and then letting 
> the standard
> form submission mechanism do its normal job of passing all selected
> items, but the select-all code does not appear to run (according to
> FireBug).
> 
> Here's the section of code that Struts2 inserted (the line numbers are
> from FireBug):
> 
> 311<script type="text/javascript">
> 312 var containingForm = document.getElementById("update");
> 313 StrutsUtils.addEventListener(containingForm, "submit",
> 314 function(evt) {
> 315 var selectObj = document.getElementById("update_");
> 316 selectAllOptionsExceptSome(selectObj, "key", "");
> 317 }, true);
> 318 var containingForm = document.getElementById("update");
> 319 StrutsUtils.addEventListener(containingForm, "submit",
> 320 function(evt) {
> 321 var selectObj = document.getElementById("update_chosenColumns");
> 322 selectAllOptionsExceptSome(selectObj, "key", "");
> 323 }, true);
> 324
> 325
> 326</script>
> 
> I'm not interested in the left list (as is shown by line 315; I'm not
> setting listName, so it just has the form name there and 
> doesn't end up
> getting used). But I am interested in the right list (line 321).
> 
> The form submit event listener seems to register (at least,
> StrutsUtils.addEventListener() executes), but when I submit the form,
> the event listener does not actually run and select the list 
> items. As a
> result, the chosen values are not passed back to the server.
> 
> Has anyone else gotten this control to work? Is there any property I
> might be missing?
> 
> Browser is Firefox 3, using FireBug to investigate.
> 	
> 
> Jonathan P. Pearson - Software Engineer
> -------------------------------------------------- 
> SIXNET - Solutions for Your Industrial Networking Challenges
> 331 Ushers Road, Ballston Lake, NY 12019
> Tel: 1.518.877.5173, Fax: 1.518.877.8346
> www.sixnet.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org