struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Lindholm <>
Subject Re: Prevent persisting data when validation fails
Date Mon, 20 Jul 2009 19:07:58 GMT
> Thank you very much!!
> During my research, I remember some one solved the issue by creating an
> Struts 2 intercepter. He placed the intercepter right after the
> validationIntercepter. The job of the intercepter was to check if
> getActionErrors or getFieldErrors collections was not empty than it closed
> and flushed the entityManager. But he didn't specified what intercepter
> method (before, inside or after the action was invoked) he implemented.
> Do you think this is a solution ?
> Any disadvangages ?
> What intercepter method do you think will be the correct one to implement?
You could probably make this work. You can take a look at the Workflow
Interceptor as an example of how to tell if there are errors.

You would have to do your stuff before calling invocation.invoke(); cause
after is too late, the result will have already been rendered.

Disadvantages are hard to determine, depends a lot on how you are managing
your Hibernate sessions. If you clear() /close()/rollback you are throwing
away all changes in the Hibernate session not just the one object you that
failed validation.   To avoid these issues that is why I always work with a
copy of the db object.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message