Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-4804

inputtransferselect does not auto-select its elements

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Not A Problem
    • Affects Version/s: 2.5.10
    • Fix Version/s: 2.5.12
    • Component/s: Core Tags
    • Labels:

      Description

      I assume that this is a bug though and I am using the tag correctly.

      I have been trying to use the inputtransferselect tag. I created the component in my form and it renders on the page fine. However the documentation link here states that it "Will auto-select all its elements upon its containing form submission." However based on my attempts this is not the case. You need to select each entry which is added for them to come through to the action.

      Ideally I'd post all of the code but I'll need to cut it down because it's corporate (hopefully that won't hide what's going wrong)

      Action class:

      public class MyAction implements Preparable
      {
        private List<String> myList= new ArrayList<>();
      
        public List<String> getMyList()
        {
          return this.dependants;
        }
      
        public void setMyList(List<String> pDependants)
        {
          this.dependants = pDependants;
        }
      
        @Override
        public void prepare() throws Exception
        {
          // Populates my list from session memory, this works fine...
        }
      
      @Override
        @Actions({
                @Action(
                        value = "/" + ActionPathConstants.SAVE,
                        interceptorRefs = @InterceptorRef(
                                value = "defaultSecurityStack",
                                params = {
                                        "tokenSession.includeMethods",
                                        "*" }),
                        results = {
                                @Result(
                                        type = "redirectAction",
                                        name = ActionPathConstants.SUCCESS,
                                        location = ActionPathConstants.NEXT_PAGE),
                                }) })
        public String save() throws Exception
        {
          // This maps the value of myList back to session memory
        }
      }
      

      JSP file:

      <s:form id="myPageSave" action="myPageSave" method="post">
        <s:inputtransferselect
                              label="myList"
                              name="myList"
                              addLabel="Add"
                              removeLabel="Remove"
                              removeAllLabel="Remove all"
                              allowUpDown="false"
                              leftTitle="Input item"
                              rightTitle="Existing items"
                              list="myList"
                       />
      </s:form>
      

      Note that the from is submitted via javascript. Rather than by directly pressing a submit button. Could this have any impact on how the auto select works?

        Activity

        Hide
        aleksandr-m Aleksandr Mashchenko added a comment -

        Cannot reproduce. How do you use it? Add relevant code.

        Show
        aleksandr-m Aleksandr Mashchenko added a comment - Cannot reproduce. How do you use it? Add relevant code.
        Hide
        suipaste Stephe added a comment -

        Will update Monday. Thanks.

        Show
        suipaste Stephe added a comment - Will update Monday. Thanks.
        Hide
        suipaste Stephe added a comment - - edited

        See update - had to try and trim it down. The real class is massive.
        ****

        Probably found the source of the issue-
        Uncaught ReferenceError: StrutsUtils is not defined.

        Just need to work out why that isn't included...

        Show
        suipaste Stephe added a comment - - edited See update - had to try and trim it down. The real class is massive. **** Probably found the source of the issue- Uncaught ReferenceError: StrutsUtils is not defined. Just need to work out why that isn't included...
        Hide
        lukaszlenart Lukasz Lenart added a comment -

        Request missed an action and hit directly the JSP?

        Show
        lukaszlenart Lukasz Lenart added a comment - Request missed an action and hit directly the JSP?
        Hide
        suipaste Stephe added a comment -

        I was missing the <s:head> tag in my jsp so the utils.js file never got picked up.
        I still have some issues with this but unlikely to be a Struts2 project issue!

        Thanks for your help.

        Show
        suipaste Stephe added a comment - I was missing the <s:head> tag in my jsp so the utils.js file never got picked up. I still have some issues with this but unlikely to be a Struts2 project issue! Thanks for your help.

          People

          • Assignee:
            Unassigned
            Reporter:
            suipaste Stephe
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development