Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Configure interface Preparable in Struts2..

 
Leonardo Carreira
Ranch Hand
Posts: 494
Eclipse IDE Java Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends...

i have a little question..

Do we have to implements Preparable?..
what conditions we have to use interface Preparable?..
How to setup the implements Preparable?..

Thank's in advance..
 
Mudit Srivastava
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Include the prepare interceptor in your interceptor stack or use the defaultStack which has a specific place for the prepare interceptor. Implement your action with the Preparable interface by defining a prepare() method. When the prepare interceptor executes, it looks for the prepare() method in your action which will allow for any sort of preprocessing to occur. .

Prepare Interceptor

Cheers

 
Leonardo Carreira
Ranch Hand
Posts: 494
Eclipse IDE Java Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks @Mudit for your post reply..

in that URL explained that the Preparable Interface used to ensure some logic runs before the actual execute method runs.
i have Class DeleteAction..
in that class iam not implement Preparable..
the class shown like this..



is it the code good for implementation?..
or i have to use Preparable and declare category as private property with getter and setter?..


Thanks in advance..
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what that has to do with the original question, which was about implementing Preparable. If you don't have anything to prepare, there's really no reason to implement Preparable.
 
Mudit Srivastava
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah I agree with David. For the code you've written, I don't see the need for the interceptor.
 
Leonardo Carreira
Ranch Hand
Posts: 494
Eclipse IDE Java Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks in advance..

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic