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

Unable to retrieve s:hidden field values

    Details

    • Flags:
      Important

      Description

      After upgrading Struts 2.3.16 to 2.3.20, my application GUI looks different. The application cannot retrieve a value stored in a hidden field using the jquery find function.
      – The hidden fields are stored in table rows

                  <table>
                     <s:iterator value="xxx" var="yyy">
                            <tr onclick="javascript:showRow(this);" >
                                  <td> some value </td>
                                 <s:hidden id="some hidden value" value="%{hiddenValue}" />
                                 <td> some value</td>             
                          </tr>	
                    </s:iterator>
              </table>
      
             function showRow(row) {
                      var $element = $(row);
                      $element.closest("tr").find('td:first').add($element).find("input:hidden").each(function (i, elem) {
      
                      // Why the code cannot access to any hidden fields here - not working in Struts 2.3.20
                      }
            }
      

        Issue Links

          Activity

          Hide
          lukaszlenart Lukasz Lenart added a comment -

          You doubled <tr> and <td> tags, can you just use:

              <s:hidden id="lastUpdateTimestamp_" value="%{lastUpdateTimestamp}" />
          

          instead of

          <tr>
          <td>
              <s:hidden id="lastUpdateTimestamp_" value="%{lastUpdateTimestamp}" />
          </td>
          </tr>
          

          Alternatively you can switch to simple theme

          <tr>
          <td>
              <s:hidden id="lastUpdateTimestamp_" value="%{lastUpdateTimestamp}" theme="simple"/>
          </td>
          </tr>
          
          Show
          lukaszlenart Lukasz Lenart added a comment - You doubled <tr> and <td> tags, can you just use: <s:hidden id= "lastUpdateTimestamp_" value= "%{lastUpdateTimestamp}" /> instead of <tr> <td> <s:hidden id= "lastUpdateTimestamp_" value= "%{lastUpdateTimestamp}" /> </td> </tr> Alternatively you can switch to simple theme <tr> <td> <s:hidden id= "lastUpdateTimestamp_" value= "%{lastUpdateTimestamp}" theme= "simple" /> </td> </tr>
          Hide
          nickhoang1 nick added a comment - - edited

          ----- JSP code -----------------------------------------------------

          <tr>
          
          <td>
          
          <!---- modified and working code ------>
          
              <input type="hidden" id="lastUpdateTimestamp_" value="<s:property
          value="lastUpdateTimestamp"/>"/>
          
          <!---- original and non-working code with Struts 2.3.20 ------->
          
              <s:hidden id="lastUpdateTimestamp_" value="%{lastUpdateTimestamp}" />
          
          </td>
          
          </tr>
          

          ------- generated HTML code --------------------------------------------

          <tr>
          
          <td>
          
              <input type="hidden" id="lastUpdateTimestamp_" value="6/13/16 11:02:48
          AM.000"/>
          
          <!---- original and non-working code with Struts 2.3.20 (extra tr style and td colspan) ------->
          
          <tr style="display:none;">
          
              <td colspan="2">
          
              <input type="hidden" name="" value="6/13/16 11:02:48 AM.000" id
          ="lastUpdateTimestamp_"/>
          
             </td>
          
          </tr>
          
          </td>
          
          </tr>
          
          Show
          nickhoang1 nick added a comment - - edited ----- JSP code ----------------------------------------------------- <tr> <td> <!---- modified and working code ------> <input type= "hidden" id= "lastUpdateTimestamp_" value="<s:property value= "lastUpdateTimestamp" />"/> <!---- original and non-working code with Struts 2.3.20 -------> <s:hidden id= "lastUpdateTimestamp_" value= "%{lastUpdateTimestamp}" /> </td> </tr> ------- generated HTML code -------------------------------------------- <tr> <td> <input type= "hidden" id= "lastUpdateTimestamp_" value="6/13/16 11:02:48 AM.000"/> <!---- original and non-working code with Struts 2.3.20 (extra tr style and td colspan) -------> <tr style= "display:none;" > <td colspan= "2" > <input type= "hidden" name= "" value=" 6/13/16 11:02:48 AM.000" id = "lastUpdateTimestamp_" /> </td> </tr> </td> </tr>
          Show
          aleksandr-m Aleksandr Mashchenko added a comment - Please check version notes https://cwiki.apache.org/confluence/display/WW/Version+Notes+2.3.20 .
          Hide
          lukaszlenart Lukasz Lenart added a comment -

          I was asking about what your original JSP produces

          Show
          lukaszlenart Lukasz Lenart added a comment - I was asking about what your original JSP produces
          Hide
          nickhoang1 nick added a comment -

          Like I said, I have to modify the code from

          <s:hidden value="%

          {x}

          " />
          to
          <input type="hidden" value="<s:property value="x"/>/>

          using combined HTML and Struts tags, which is ugly. It does not make any
          sense to modify the existing code this way.

          It is just one example. There are many other Struts tags in the code that
          need to be modified because the new Struts messed up the view.

          Nick

          On Thu, Jun 9, 2016 at 3:18 PM, Lukasz Lenart (JIRA) <jira@apache.org>

          Show
          nickhoang1 nick added a comment - Like I said, I have to modify the code from <s:hidden value="% {x} " /> to <input type="hidden" value="<s:property value="x"/>/> using combined HTML and Struts tags, which is ugly. It does not make any sense to modify the existing code this way. It is just one example. There are many other Struts tags in the code that need to be modified because the new Struts messed up the view. Nick On Thu, Jun 9, 2016 at 3:18 PM, Lukasz Lenart (JIRA) <jira@apache.org>
          Hide
          lukaszlenart Lukasz Lenart added a comment -

          Can you post generated html?

          Show
          lukaszlenart Lukasz Lenart added a comment - Can you post generated html?
          Hide
          nickhoang1 nick added a comment -

          Hi Johannes,

          I still have the problem even with using find('input[type='hidden"]'). The
          tag <s:hidden> cannot be recognized.
          I then changed it to <input type="hidden"> to be recognized by the find
          function. However the property value cannot be recognized, then I have to
          change the property syntax to something else.

          Why the new Struts 2.3.20 is not backward compatible. What jar files have
          been changed? What freemarker, jquery versions need to be used in order for
          the existing code to work?

          Please advise.

          Nick

          On Wed, Jun 8, 2016 at 2:39 AM, Johannes Geppert (JIRA) <jira@apache.org>

          Show
          nickhoang1 nick added a comment - Hi Johannes, I still have the problem even with using find('input [type='hidden"] '). The tag <s:hidden> cannot be recognized. I then changed it to <input type="hidden"> to be recognized by the find function. However the property value cannot be recognized, then I have to change the property syntax to something else. Why the new Struts 2.3.20 is not backward compatible. What jar files have been changed? What freemarker, jquery versions need to be used in order for the existing code to work? Please advise. Nick On Wed, Jun 8, 2016 at 2:39 AM, Johannes Geppert (JIRA) <jira@apache.org>
          Hide
          jogep Johannes Geppert added a comment -

          Please use for user questions our user mailing list and not the issue tracker:
          https://lists.apache.org/list.html?user@struts.apache.org
          https://struts.apache.org/mail.html

          Have you already tried input[type="hidden"] instead of input:hidden?

          Show
          jogep Johannes Geppert added a comment - Please use for user questions our user mailing list and not the issue tracker: https://lists.apache.org/list.html?user@struts.apache.org https://struts.apache.org/mail.html Have you already tried input [type="hidden"] instead of input:hidden?

            People

            • Assignee:
              lukaszlenart Lukasz Lenart
              Reporter:
              nickhoang1 nick
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 48h
                48h
                Remaining:
                Remaining Estimate - 48h
                48h
                Logged:
                Time Spent - Not Specified
                Not Specified

                  Development