Discussion:
Struts 2.5 S:Select tag with Multiple True
Kiran Kongala
2018-07-14 11:01:37 UTC
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
2018-07-14 11:19:15 UTC
Permalink
Hi, kiran,

Have you tried with "value" property?
Post by Kiran Kongala
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
Yasser Zamani
2018-07-15 10:18:53 UTC
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.
-----Original Message-----
Sent: Saturday, July 14, 2018 3:32 PM
Subject: Struts 2.5 S:Select tag with Multiple True
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
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@struts.apache.org
For additional commands, e-ma

Continue reading on narkive:
Loading...