Reputation: 87
preface: i'm currently using struts2-core-2.3.1.2, and upgrading isn't an option.
i'm trying to implement HTML5 required fields in my struts2 form. struts won't even render this:
<s:textfield name="x_serialNbr" id="i_sn" required />
and while it will render these:
<s:textfield name="x_serialNbr" id="i_sn" required="true" />
<s:textfield name="x_serialNbr" id="i_sn" required="required" />
the resulting HTML is not what i want:
<input type="text" name="x_serialNbr" value="" id="i_sn" />
after extensive googling, this post from over a year ago is the closest i can find to something that addresses my issue. it seems to indicate that this problem has been resolved in the current version of struts2, but as i said, i can't upgrade.
as far as i can see, my options are
Upvotes: 4
Views: 1547
Reputation: 1
You can use plain html,but the value you should get either OGNL or EL
<input type="text" name="x_serialNbr" value="<s:property value='x_serialNbr'/>" id="i_sn" required="true">
<input type="text" name="x_serialNbr" value="${x_serialNbr}" id="i_sn" required="required">
Upvotes: 3