New issue 254 by camusg: s:optiontransferselect and sj:submit
http://code.google.com/p/struts2-jquery/issues/detail?id=254
What steps will reproduce the problem?
1. In a Struts Form (s:form), use the s:optiontransferselect.
2. Try to post your form with a sj:submit
3. Compare with s:submit
What is the expected output? What do you see instead?
Neither of param in s:optiontransferselect are posted in HTTP query with
sj:submit.
When using s:submit, you can see that some javascript code is added just
after submit button.
Javascript code added is like this (exported from struts 2 showcase) :
<script type="text/javascript">
var containingForm =
document.getElementById("lotsOfOptiontransferselectSubmit");
StrutsUtils.addEventListener(containingForm, "submit",
function(evt) {
var selectObj =
document.getElementById("lotsOfOptiontransferselectSubmit_favouriteCartoonCharacters");
selectAllOptionsExceptSome(selectObj, "key", "-1");
}, true);
StrutsUtils.addEventListener(containingForm, "submit",
function(evt) {
var selectObj =
document.getElementById("lotsOfOptiontransferselectSubmit_favouriteCars");
selectAllOptionsExceptSome(selectObj, "key", "");
}, true);
(...)
</script>
Which struts2 version?
2.1.8.1
Which struts2-jquery plugin version?
2.3.0
Comment #1 on issue 254 by johgep: s:optiontransferselect and sj:submit
http://code.google.com/p/struts2-jquery/issues/detail?id=254
can you provide a sample jsp? I have never worked with
s:optiontransferselect but currently I see no reason why it should not work.
Here an sample with jsp and action.
I work with your showcase (2.3.1 version).
You can put "pages.zip" in "pages" directory, and "action.zip"
in "com\jgeppert\struts2\jquery\showcase" directory.
I rewrite form.jsp to add my new link at the bottom of left menu.
In my page, I put two submit buttons, first from this plugin (sj:submit)
and second from struts 2 (s:submit).
Both result is displaying in your echo page.
I use Fiddler and Firebug to track all of parameters sent in HTTP request.
With sj:submit, the parameters are only, with this sample and default
values :
__multiselect_favouriteNames=&__multiselect_notFavouriteNames=
With s:submit, the parameters are :
favouriteNames=Patrick&favouriteNames=Jason&favouriteNames=Jay&favouriteNames=Toby&favouriteNames=Rene&__multiselect_favouriteNames=¬FavouriteNames=Robert&__multiselect_notFavouriteNames=
I think the problem is with a javascript function added (see my first
message) with Struts 2 Submit button, that is not added with Ajax Submit.
This sample is written with struts2-jquery plugin version 2.3.1.
Thank you for your great work and plugin !
Attachments:
action.zip 1.2 KB
pages.zip 2.6 KB
can you please try to put the onSubmit Events from Struts into an
onBeforeTopics?
<script type='text/javascript'>
jQuery(document).ready(function () {
$.subscribe('beforeSubmit', function(event, data) {
var selectObj = document.getElementById("<yourid>");
selectAllOptionsExceptSome(selectObj, "key", "");
var selectObj2 = document.getElementById("<yourdoubleid>");
selectAllOptionsExceptSome(selectObj2, "key", "");
});
});
</script>
<sj:submit ...
onBeforeTopics="beforeSubmit"
/>
I tried with your code, but I notice that all options are selected after
POST HTTP. If a push submit button a second time, that's work. But it
doesn't work the first time.
To solve this problem, we have to add manually some javascript code ? or
the code will be added by taglib ?
With struts submit button, code added automatically... It's possible to
extend this behavior with this plugin ?
Thanks for your work !
the problem is that the optiontransferselect element uses some javascript
which is registered to th onsubmit event of the form.
this events can't fired by code only by user interaction.
the next problem is that this scripts provided by struts only select all
items so the values are correctly submitted. but it does not deselect them
after submit.
currently i don't have a short solution for this.
We are seeing the same problem, but only when using Chrome. Firefox and IE
work fine. I'm using Chrome 6 on Linux, Firefox 3.8 on Linux and IE8 on XP.
Comment #7 on issue 254 by johgep: s:optiontransferselect and sj:submit
http://code.google.com/p/struts2-jquery/issues/detail?id=254
this is struts2 javascript which work not well with this plugin.
just add an onBeforeTopics which select all entries in your option transfer
ans add an onCompleteTopics which deselect them after request is finished.
if anyone can provide a better solution I will reopen this Issue.