Data AccessCore JavaApp FrameworksViewTestingBuildingDeploymentDev ToolsSecurityOpinions

Monday, July 6, 2009

Preparable CRUD actions with multiple prepare methods

Many of the Struts2 Tutorials guide you towards stuffing multiple CRUD operations for a single entity within a single action. Sounds nice, but what happens when you need to prepare these actions differently?

Your first instinct might tell you to implement multiple actions for that one entity (one per CRUD operation, or maybe even stuff two inside one action).

However, you can add multiple prepare{METHOD}() like prepareDoDelete(),
prepareDoUpdate(). If you follow this convention, the appropriate prepare method will be called before your action method.

The following is a snippet from the Struts 2 Documentation at:

In PrepareInterceptor

Applies only when action implements Preparable

1. if the action class have prepare{MethodName}(), it will be invoked
2. else if the action class have prepareDo(MethodName()}(), it will be invoked
3. no matter if 1] or 2] is performed, if alwaysinvokePrepare property of the interceptor is "true" (which is by default "true"), prepare() will be invoked.


  1. I have read your blog its very attractive and impressive. I like it your blog.

    Java Training in Chennai Java Training in Chennai | Core Java Training in Chennai

    Online Java Training Java Online Training | Java J2EE Online Training | JavaEE Training Institute in Chennai

  2. The outcome is an amazingly adaptable payback plan. On the off chance that you have an awful month, you may battle to influence the installment on your customary business to credit, online Check Cashing Chula vista

  3. One of the most essential things you should know is how to change you wifi password and router login settings, that's why you will need

  4. Packers and Movers Pune Provide High Quality ***Household Shifting, Home/Office Relocation, Insurance, Packing, Loading, ###Car Transportation Service Pune and High experiences, Top Rated, Safe and Reliable, Best and Secure Packers and Movers Pune Team List. Get ✔✔✔Affordable Rate Charts and Compare Quotation and Save Money and Time @ Packers And Movers Pune