Struts 2
  1. Struts 2
  2. WW-1677

<s:submit type="button" does not render the enclosed content inside properly

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.1.3
    • Component/s: Plugin - Tags
    • Labels:
      None
    • Environment:

      Windows XP SP2, JSDK 6.0, Tomcat 5.5, Spring 2.0

      Description

      Please take a look at the following code, the <s:submit tag did not render the tags properly.
      <code>
      <s:submit type="button" theme="simple">
      <s:text name="testplan.form.submit.label" /> <img align="top" src="<s:url value="/images/save_16.png" />"/>
      </s:submit>
      </code

      I expected the output would be
      <code>
      <button type="submit">Submit <img align="top" src="images/save_16.png"/></button>
      </code>

      but the actual out put is
      <code>
      Submit <img align="top" src="/autobase/images/save_16.png?testPlan.id=1"/><button type="submit" id="testPlanForm_save" name="save" value="Submit">Submit</button>
      </code>

      1. submit-button.patch
        10 kB
        Mike Bydalek
      2. buttons.jpg
        67 kB
        Eric Martin
      3. index.jsp
        3 kB
        Eric Martin
      4. button.patch
        18 kB
        Eric Martin

        Issue Links

          Activity

          Hide
          musachy added a comment -

          just for reference $

          {parameters.body}

          is not only the inner text of the tag, but it also includes the opening of the tag, so for

          <s:submit>test</s:submit>

          body is: <input type="submit">test

          So it cannot be escaped.

          Show
          musachy added a comment - just for reference $ {parameters.body} is not only the inner text of the tag, but it also includes the opening of the tag, so for <s:submit>test</s:submit> body is: <input type="submit">test So it cannot be escaped.
          Hide
          musachy added a comment -

          re-opening to investigate

          Show
          musachy added a comment - re-opening to investigate
          Hide
          Piero Sartini added a comment -

          With this patch in place my submit buttons disappear:
          <@s.submit name="submit" key="user.register.submit" cssClass="submit"/>

          If I add type="button" it tries to do the right thing, but the generated tag is html-escaped and the browser prints out its sourcecode.

          Show
          Piero Sartini added a comment - With this patch in place my submit buttons disappear: <@s.submit name="submit" key="user.register.submit" cssClass="submit"/> If I add type="button" it tries to do the right thing, but the generated tag is html-escaped and the browser prints out its sourcecode.
          Hide
          musachy added a comment -

          Patch applied with one small mod, the label("Submit" by default) will be printed only when the body of the tag is empty, so there is no need to set label="". Thanks for reporting and the patches!

          Show
          musachy added a comment - Patch applied with one small mod, the label("Submit" by default) will be printed only when the body of the tag is empty, so there is no need to set label="". Thanks for reporting and the patches!
          Hide
          Mike Bydalek added a comment -

          Patch to implement <s:submit type="button"></s:submit>

          Show
          Mike Bydalek added a comment - Patch to implement <s:submit type="button"></s:submit>
          Hide
          Mike Bydalek added a comment - - edited

          Based on Don's thought of doing this like the div and form components, I created a little patch that does just that.

          The following code now renders as expected:

          <s:submit type="button" cssClass="button positive save" theme="simple" label="">
          <img src="<s:url value="/images/tick.png" />" alt=""> Save
          </s:submit>

          Output:

          <button type="submit" id="bleh_0" value="Submit" class="button positive save">

          <img src="/tutorial/images/tick.png" alt=""> Save
          </button>

          The only caveat was setting the label attribute to "", otherwise, it would output "Submit" as well. This is in Submit.evalutateParams() but since I'm really new to Struts, I'm not sure how to handle that in a good way.

          Additionally, I reverted the fix applied by Don since it seemed redundant.

          -Mike

          Show
          Mike Bydalek added a comment - - edited Based on Don's thought of doing this like the div and form components, I created a little patch that does just that. The following code now renders as expected: <s:submit type="button" cssClass="button positive save" theme="simple" label=""> <img src="<s:url value="/images/tick.png" />" alt=""> Save </s:submit> Output: <button type="submit" id="bleh_0" value="Submit" class="button positive save"> <img src="/tutorial/images/tick.png" alt=""> Save </button> The only caveat was setting the label attribute to "", otherwise, it would output "Submit" as well. This is in Submit.evalutateParams() but since I'm really new to Struts, I'm not sure how to handle that in a good way. Additionally, I reverted the fix applied by Don since it seemed redundant. -Mike
          Hide
          Don Brown added a comment -

          I think this can be done with the submit tag as is, but maybe we need to split the template up into submit.ftl and submit-close.ftl like the div and form components. Anyways, moving off to 2.1.x until we have a patch to apply.

          Show
          Don Brown added a comment - I think this can be done with the submit tag as is, but maybe we need to split the template up into submit.ftl and submit-close.ftl like the div and form components. Anyways, moving off to 2.1.x until we have a patch to apply.
          Hide
          Eric Martin added a comment -

          I didn't see an easy way to change the behavior of the submit tag when the type is "button", so I created a new button tag.

          The usesBody method needed to return true and there also needed to be some logic that required the button body to have a value. In addition, the button tag can have 3 types, button (default), reset, and submit.

          I used the new @StrutsTagSkipInheritance annotation in Button.java to suppress unused attributes from displaying in the Button tag html file. I don't know if this is desired, so please remove if it's not

          If it is decided to use this button tag, let me know and I can create the test cases for it.

          I've attached a test jsp page and screenshot.

          -Eric

          Show
          Eric Martin added a comment - I didn't see an easy way to change the behavior of the submit tag when the type is "button", so I created a new button tag. The usesBody method needed to return true and there also needed to be some logic that required the button body to have a value. In addition, the button tag can have 3 types, button (default), reset, and submit. I used the new @StrutsTagSkipInheritance annotation in Button.java to suppress unused attributes from displaying in the Button tag html file. I don't know if this is desired, so please remove if it's not If it is decided to use this button tag, let me know and I can create the test cases for it. I've attached a test jsp page and screenshot. -Eric
          Hide
          Ted Husted added a comment -

          The inner text of the JSP tag is still not being rendered as inner text to the HTML button, so we will need to work up another patch.

          Show
          Ted Husted added a comment - The inner text of the JSP tag is still not being rendered as inner text to the HTML button, so we will need to work up another patch.
          Hide
          Eric Martin added a comment -
          Show
          Eric Martin added a comment - Same here, using 2.0.11 and still an issue: http://www.nabble.com/-S2--Complex-submit-button-issue-tf4889527.html
          Hide
          Alberto Flores added a comment -

          I seem to have this bug still on 2.0.11. I also tried it on 2.0.5 and I get the same output (not working). Could you double check this?

          Show
          Alberto Flores added a comment - I seem to have this bug still on 2.0.11. I also tried it on 2.0.5 and I get the same output (not working). Could you double check this?
          Hide
          Don Brown added a comment -

          Fixed, thanks for bringing it up

          Show
          Don Brown added a comment - Fixed, thanks for bringing it up

            People

            • Assignee:
              Unassigned
              Reporter:
              Peng Wang
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development