struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From taltun <tunca...@gmail.com>
Subject Re: Prevent persisting data when validation fails
Date Mon, 20 Jul 2009 17:43:57 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?






Greg Lindholm-2 wrote:
> 
>>
>> By the way, how can I let JPA return a deatached object ?
>>
>> I make use of GenericDaoJpa.java which is attached to this message.
>> http://www.nabble.com/file/p24571326/GenericDaoJpa.java
>> GenericDaoJpa.java
>>
>>
>>
> See
> http://stackoverflow.com/questions/31446/detach-an-entity-from-jpa-ejb3-persistence-contextfor
> discussion but the answer seems to be use the Hibernate
> session.evict(object) method.
> 
> It may be easier to do an EntityManager.clear() or close() when validation
> fails.  Of course this will only work if you only use manual validation
> with
> the validate() method, if you use declarative validation then you never
> get
> a chance to react when validation fails.
> 
>   ( @Struts Experts: Is there any way to call an action method
> post-validation but before the result is taken so you can do some stuff
> when
> validation fails?  I know about PreResultListener but don't think it's
> what
> I want.)
> 
> 
>> What is the best way to copy a persistent object ? Using BeanUtil.copy or
> clone, etc?
> 
> I guess you can use clone, but I always write a copy constructor for
> entity
> classes so I have more control over handling of references to other
> entities.
> 
> 

-- 
View this message in context: http://www.nabble.com/Prevent-persisting-data-when-validation-fails-tp24566713p24574368.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message