4

I have the following <s:submit> tag code:

<s:submit action="shipment_deleteShipperFromChosenShipperViewList" 
          type="image" src="/llr/theme/delete.gif"
          onclick="clearDirtyFlag();deleteShipperFromChosenShipperViewList('%{organizationInfo.orgId}');"
          tabindex="16" />

which generates the following HTML:

<input type="image" 
       alt="Submit" 
       src="/llr/theme/delete.gif" 
       id="shipment_shipment_deleteShipperFromChosenShipperViewList" 
       name="action:shipment_deleteShipperFromChosenShipperViewList" 
       value="Submit"
       tabindex="16"
       onclick="clearDirtyFlag();deleteShipperFromChosenShipperViewList('1');"/>

The W3C Markup Validator (W3C) marks the HTML as an error. The error message is:

Attributevalue not allowed on element input at this point.

Evidently value is not an allowed attribute when the type is image. How do I keep Struts2 from generating the value attribute?

15
  • 4
    Maintainer of the W3C HTML checker (validator) here. This is not a bug in the HTML checker. The checker conforms to the spec in not allowing the value attribute in this case. If you go to html.spec.whatwg.org/multipage/… and scroll down to the Bookkeeping details section, you’ll see that it says, “The element's value attribute must be omitted.”.
    – sideshowbarker
    May 4, 2016 at 14:55
  • 1
    It's valid in HTML 4 because DTDs can't make an attribute forbidden only if another attribute has a specific value. HTML 5 doesn't use DTDs so it can mark it invalid.
    – Quentin
    May 4, 2016 at 18:37
  • 2
    @RomanC — The question is asking how to prevent struts2 from generating a value attribute on an image input. It is entirely about struts2.
    – Quentin
    May 4, 2016 at 18:40
  • 1
    @RomanC — The question is perfectly clear. "Is the validator right, if so, how do I fix my struts2 code to fix the HTML?". The comments have established that the validator is right, so it just comes down to "How do I fix it?". The part about the validator is just a reasonable check to make sure that the question isn't based on a false premise.
    – Quentin
    May 4, 2016 at 18:48
  • 2
    Since @sideshowbarker showed the Validator was correct I do need to know how to keep Struts2 from generating the value attribute. I created a jira as @Aleksandr recommended.
    – ponder275
    May 4, 2016 at 19:17

1 Answer 1

3

Until the fixed version is released, you have a few options.

  • Use plain HTML input tag <input type="image" ...> instead of <s:submit>. If you are using not simple theme then you also should put <input> into some HTML tags.

  • Copy the submit.ftl from the struts2-core jar into your project and modify it.

  • Just ignore this W3C Markup Validator error, there are probably worse things to worry about. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.