Struts 2
  1. Struts 2
  2. WW-1972

<s:optiontransferselect ... items not autoselected on submit.

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 3.0
    • Component/s: Plugin - Dojo Tags
    • Labels:
      None
    • Environment:

      WindowsXP, Java 1.6, Tomcat v5.5

      Description

      Have form like:
      <s:form action="addUser" method="get">
      <s:textfield name="user.username"><s:param name="label"><fmt:message key="user.label.username"/></s:param></s:textfield>
      <s:password name="user.password"><s:param name="label"><fmt:message key="user.label.password"/></s:param></s:password>
      <s:optiontransferselect name="user.roles" list="user.roles" listKey="id" listValue="name" doubleName="roleList" doubleList="roleList" doubleListKey="id" doubleListValue="name">
      </s:optiontransferselect>
      <s:submit type="button" value="%

      {'add'}

      ">
      <s:param name="label"><fmt:message key="global.label.add"/></s:param>
      </s:submit>
      </s:form>

      AddUserAction implements ParameterAware. When form submitted only parameters received are user.username & user.password. Tag reference for <s:optiontransferselect> states that all values in both lists are supposed to be selected before submit (so they'd also be added as parameters).

        Activity

        Hide
        Jan Hornbøll Hansen added a comment -

        Not a bug (except maybe in documentation) dojo.js not mentioned anywhere in tag reference even though atleast some tags rely on it.

        Show
        Jan Hornbøll Hansen added a comment - Not a bug (except maybe in documentation) dojo.js not mentioned anywhere in tag reference even though atleast some tags rely on it.
        Hide
        Ted Husted added a comment -

        Setting Fix Version to "future" for issues without a set fix version.

        Show
        Ted Husted added a comment - Setting Fix Version to "future" for issues without a set fix version.
        Hide
        Thorsten Schäfer added a comment -

        It took me some time to understand that the items in the select box need to be selected in order to be submitted. This should be added to the documentation and it should be stated that you need to add <s:head/> to the header in order to get autoselect working.

        Show
        Thorsten Schäfer added a comment - It took me some time to understand that the items in the select box need to be selected in order to be submitted. This should be added to the documentation and it should be stated that you need to add <s:head/> to the header in order to get autoselect working.
        Hide
        Mario Matias Urbieta added a comment -

        This is the second work arround that i had to do today. I'll never use this framework again.
        The main problem is that dojo plugin uses dojo to send the form in a ajax way and many struts2 components spect a
        dom submit event- such as optiontransferselect- that allows listeners to select the comprised items.
        So i emulated the traditional form submition by the following steps avoiding refactoring the xhtml tags:

        • Add a listener to the form for stopping the dom submit event bubble. This is the key, i supposed that this listener will be the last executed ( it worked on FF3 and IE7).
        • Fire on submit event. this will excercise the listeners but will be stoped by our listener.

        This JS goes at the ajax form

        dojo.event.topic.subscribe("/selectAll",
        function(widget, event) {
        StrutsUtils.addEventListener(document.getElementById('$

        {parameters.id}'), "submit",
        function(evt) { dojo.event.browser.stopEvent(evt); }, true);

        fire('submit',document.getElementById('${parameters.id}

        '));

        });

        function fire(evttype,el) {
        if (document.createEvent)

        { var evt = document.createEvent('HTMLEvents'); evt.initEvent( evttype, true, true); el.dispatchEvent(evt); }

        else if (document.createEventObject)

        { el.fireEvent('on' + evttype); }

        }

        and finally i had to add the following attribute to the ajax submit tag wich triggers the emulation behavior.

        beforeNotifyTopics="/selectAll"

        this work arround is oblivious and seamless.

        Show
        Mario Matias Urbieta added a comment - This is the second work arround that i had to do today. I'll never use this framework again. The main problem is that dojo plugin uses dojo to send the form in a ajax way and many struts2 components spect a dom submit event- such as optiontransferselect- that allows listeners to select the comprised items. So i emulated the traditional form submition by the following steps avoiding refactoring the xhtml tags: Add a listener to the form for stopping the dom submit event bubble. This is the key, i supposed that this listener will be the last executed ( it worked on FF3 and IE7). Fire on submit event. this will excercise the listeners but will be stoped by our listener. This JS goes at the ajax form dojo.event.topic.subscribe("/selectAll", function(widget, event) { StrutsUtils.addEventListener(document.getElementById('$ {parameters.id}'), "submit", function(evt) { dojo.event.browser.stopEvent(evt); }, true); fire('submit',document.getElementById('${parameters.id} ')); }); function fire(evttype,el) { if (document.createEvent) { var evt = document.createEvent('HTMLEvents'); evt.initEvent( evttype, true, true); el.dispatchEvent(evt); } else if (document.createEventObject) { el.fireEvent('on' + evttype); } } and finally i had to add the following attribute to the ajax submit tag wich triggers the emulation behavior. beforeNotifyTopics="/selectAll" this work arround is oblivious and seamless.
        Hide
        suman lohani added a comment - - edited

        This problem still exists in struts 2.0.11.
        I am trying the work around suggested by Mario Matias Urbieta. In that code do we replace ${parameters.id with any specific parameter or just use as is. Any suggestions is appreciated.

        Show
        suman lohani added a comment - - edited This problem still exists in struts 2.0.11. I am trying the work around suggested by Mario Matias Urbieta. In that code do we replace ${parameters.id with any specific parameter or just use as is. Any suggestions is appreciated.
        Hide
        Lukasz Lenart added a comment -

        Dojo plugin is deprecated and will be removed from the next major release

        Show
        Lukasz Lenart added a comment - Dojo plugin is deprecated and will be removed from the next major release

          People

          • Assignee:
            Unassigned
            Reporter:
            Jan Hornbøll Hansen
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:

              Development