Is there anyway to validate a collection of objects in a myAction-validation.xml file?
I have some JSP:
<s:iterator value="messageTypes" status="status">
<tr>
<td> <s:property value="messageType" /> </td>
<td> <s:checkbox name="messageTypes[%{#status.index}].enabled" value="enabled" label="" /> </td>
<td> <s:textfield name="messageTypes[%{#status.index}].reminderDate" value="%{reminderDate}" label="" labelSeparator="" /> </td>
<td>
<s:select name="messageTypes[%{#status.index}].reminderHour" list="hours" label="Hour" />
<s:select name="messageTypes[%{#status.index}].reminderMinute" list="minutes" label="Minute" /> </td>
<td> <s:textfield name="messageTypes[%{#status.index}].reminderTo" value="%{reminderTo}" label="" labelSeparator="" /> </td>
</tr>
</s:iterator>
And would like to validate the individual fields, like reminderDate
with date validation for example. Is this possible? Note, all of the fields are Strings apart from enabled which is a boolean.
I think you'll have to either apply validation on your MessageType class itself using the visitor field validator (see also: visitor validator ). Alternately you could do the validation by overriding validate()
in your Action (so long as you extend ActionSupport
) and manually invoking addActionError
or addFieldError
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.