You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by temp temp <mi...@yahoo.com> on 2005/04/14 23:55:28 UTC

code repetation in action classes

I am implementing pagination for most of my jsp's so I
created a pagination bean 
with properties corresponding to pagination  and this
bean extends to ActionForm .

All my formbeans extend to the pagination bean class.
In all my action  classes I am repeating code to set
values corresponding to pagination and the rest is
setting properties  specific to formbeans . I want to
avoid the repetation of code for setting pagination
values in my action classes . Is there way to avoid
this.

thanks & regards



		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Find what you need with new enhanced search. 
http://info.mail.yahoo.com/mail_250

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


Re: code repetation in action classes

Posted by Dave Newton <ne...@pingsite.com>.
temp temp wrote:

>I am implementing pagination for most of my jsp's so I
>created a pagination bean 
>with properties corresponding to pagination  and this
>bean extends to ActionForm .
>
>All my formbeans extend to the pagination bean class.
>In all my action  classes I am repeating code to set
>values corresponding to pagination and the rest is
>setting properties  specific to formbeans . I want to
>avoid the repetation of code for setting pagination
>values in my action classes . Is there way to avoid
>this.
>  
>
Sure.

Refactor the code out into an Action base class.

Or create an interface and implementations that each action can 
instantiate that do the right thing for that particular bean and/or Action.

Or put the code in the formbean (which doesn't seem like a good idea).

Or move the pagination code out of the form bean (where it probably 
doesn't belong) and put it in a class that knows about collections and 
can paginate them.

Or put the pagination into a presentation-layer tool like a tag class 
that does all the work for you (or use one of several existing solutions).

Dave



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