PDA

View Full Version : Suppress binding with <form:input> tag?



HughScott
Dec 19th, 2007, 09:10 AM
Can I use a <form:input> tag to render data to the browser, but not have it bind when the form is submitted by the user?

The "readonly" attribute prohibits the user from editing the field, but it's still submitted in the request.

I'm looking for a custom tag or attribute to <form:input> that prevents binding. I realize I can always code a standard HTML <input> tag, along with a value="" scriptlet, but am looking for a solution that integrates well with the <form:form> tag.

Thanks in advance.

Hugh

pmularien
Dec 19th, 2007, 09:24 AM
You'd have to handle this on the bind end of things. If you aren't already customizing your bind process by enforcing the allowedFields list, you could add the field as a disallowedField and it would be ignored. Look at the Javadoc for DataBinder (http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/validation/DataBinder.html) for more detail on these bits you can tweak.

HughScott
Dec 19th, 2007, 09:29 AM
So setDisallowedFields() will prevent the request data from binding, but won't actually prevent the data from being submitted? It'll be in the request, but ignored by the binding process?

pmularien
Dec 19th, 2007, 09:42 AM
So setDisallowedFields() will prevent the request data from binding, but won't actually prevent the data from being submitted? It'll be in the request, but ignored by the binding process?
Yes, I believe that's how it works.