|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ActionForm org.springframework.web.struts.SpringBindingActionForm
@Deprecated public class SpringBindingActionForm
A thin Struts ActionForm adapter that delegates to Spring's more complete and advanced data binder and Errors object underneath the covers to bind to POJOs and manage rejected values.
Exposes Spring-managed errors to the standard Struts view tags, through exposing a corresponding Struts ActionMessages object as request attribute. Also exposes current field values in a Struts-compliant fashion, including rejected values (which Spring's binding keeps even for non-String fields).
Consequently, Struts views can be written in a completely traditional
fashion (with standard html:form
, html:errors
, etc),
seamlessly accessing a Spring-bound POJO form object underneath.
Note this ActionForm is designed explicitly for use in request scope.
It expects to receive an expose
call from the Action, passing
in the Errors object to expose plus the current HttpServletRequest.
Example definition in struts-config.xml
:
<form-beans> <form-bean name="actionForm" type="org.springframework.web.struts.SpringBindingActionForm"/> </form-beans>Example code in a custom Struts
Action
:
public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { SpringBindingActionForm form = (SpringBindingActionForm) actionForm; MyPojoBean bean = ...; ServletRequestDataBinder binder = new ServletRequestDataBinder(bean, "myPojo"); binder.bind(request); form.expose(binder.getBindingResult(), request); return actionMapping.findForward("success"); }This class is compatible with both Struts 1.2.x and Struts 1.1. On Struts 1.2, default messages registered with Spring binding errors are exposed when none of the error codes could be resolved. On Struts 1.1, this is not possible due to a limitation in the Struts message facility; hence, we expose the plain default error code there.
#expose(org.springframework.validation.Errors, javax.servlet.http.HttpServletRequest)
Nested Class Summary | |
---|---|
private static class |
SpringBindingActionForm.SpringBindingAwarePropertyUtilsBean
Deprecated. Special subclass of PropertyUtilsBean that it is aware of SpringBindingActionForm and uses it for retrieving field values. |
Field Summary | |
---|---|
private static boolean |
defaultActionMessageAvailable
Deprecated. |
private Errors |
errors
Deprecated. |
private java.util.Locale |
locale
Deprecated. |
private static Log |
logger
Deprecated. |
private MessageResources |
messageResources
Deprecated. |
Constructor Summary | |
---|---|
SpringBindingActionForm()
Deprecated. |
Method Summary | |
---|---|
void |
expose(Errors errors,
HttpServletRequest request)
Deprecated. Set the Errors object that this SpringBindingActionForm is supposed to wrap. |
private java.lang.String |
findEffectiveMessageKey(ObjectError error)
Deprecated. Find the most specific message key for the given error. |
private ActionMessages |
getActionMessages()
Deprecated. Return an ActionMessages representation of this SpringBindingActionForm, exposing all errors contained in the underlying Spring Errors object. |
private java.lang.Object |
getFieldValue(java.lang.String propertyPath)
Deprecated. Get the formatted value for the property at the provided path. |
private java.lang.Object[] |
resolveArguments(java.lang.Object[] arguments)
Deprecated. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Log logger
private static boolean defaultActionMessageAvailable
private Errors errors
private java.util.Locale locale
private MessageResources messageResources
Constructor Detail |
---|
public SpringBindingActionForm()
Method Detail |
---|
public void expose(Errors errors, HttpServletRequest request)
errors
- the Spring Errors object to wrap, usually taken from
a DataBinder that has been used for populating a POJO form objectrequest
- the HttpServletRequest to retrieve the attributes fromDataBinder.getBindingResult()
private ActionMessages getActionMessages()
Errors.getAllErrors()
private java.lang.Object[] resolveArguments(java.lang.Object[] arguments)
private java.lang.String findEffectiveMessageKey(ObjectError error)
error
- the ObjectError to find a message key for
private java.lang.Object getFieldValue(java.lang.String propertyPath) throws java.lang.NoSuchMethodException
propertyPath
- the property path
java.lang.NoSuchMethodException
- if called during Struts binding
(without Spring Errors object being exposed), to indicate no
available property to Struts
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |