Discussion:
Struts 2.5 S:Select tag with Multiple True
Kiran Kongala
7 years ago
Permalink
Hi Guys,

We are using Struts 2.5.13 in our Enterprise Java Application and one of
the jsp page has many Struts Select tags with multiple=true(s:select
multiple=true) .

I know that for selecting/deselecting multiple items in the list, we have
to hold the Ctrl Key.

But for the Users who are using our application, they have an issue.

Suppose the User selected 5 items out of 20 in a multi select drop down by
holding Ctrl Key and saved the page in the Add flow.

In the Edit flow, the User wants to select 6th item in the existing multi
select drop down and if the user forgets to hold the Ctrl key while
selecting the 6th item, then all the other 5 items are deselected and only
the 6th item is selected.

Without even realizing that they deselected the other items in the list
they save the page. By mistake they don't want that to happen.

So they asked is there a way to work with the multi select by
selecting/desecting multiple items in the list without holding the Ctrl Key
or to stop this happening with the Select tag.

So we added the below jquery script so that they can select/deselect
without holding the Ctrl Key.

jQuery('option').mousedown(function(e) {
e.preventDefault();
var selector = this.parentElement.id;
jQuery(this).prop('selected', !jQuery(this).prop('selected'));
jQuery('#' + selector).trigger('change');
return false;
});

But this script only works in Chrome and may be FF but it doesn't work in
IE.

Because most of our Users uses the IE as the default browser and most of
the application is tested on IE only, Is there any work around with this
problem or is there any property in the S:SELECT which will solve this
issue?

Please help.

Thanks
Arjuna Bandara
7 years ago
Permalink
Hi, kiran,

Have you tried with "value" property?
...
Yasser Zamani
7 years ago
Permalink
I wonder why HTML needs CTRL key when we enable multiple! Anyway, I think it's out of Struts business as an HTML issue. Unfortunately Struts Select tag doesn't provide an optional fix for this HTML issue and you've to fix it manually via some javascript coding e.g. save current selected items on each click and reselect all of them on each click too.

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

Loading...