How to resuse an Action class in different namespace contexts?

2012-07-23 Thread Mounir Benzid



I use two different namespaces to secure my web application ( with 
spring security)


One is /pubilc  the other is called.. well..  /private. Everything 
underneath /private is available only  to logged-in users.



Currently  there is an action class living in the /public namespace 
named ShowPublicAgendaAction

which is responsible for showing today's agenda items.


A very similar action ShowPrivateAgendaAction exists in the secured 
/private namespace
which does pretty much the same thing, the only difference is, that all 
available agenda itens are presented to the user

(not only those of today)


I'd like to consolidate both actions since they differ only in one 
single line of code


 Public:   public void prepare() { ListAgendaItem items= 
agendaManager.loadTodaysItems();.}


Private:  public void prepare() {  ListAgendaItem items= 
agendaManager.loadItems();..}



How do I go about serving requests from different namespaces in one 
Action class?


Requests coming-in from /private should call  items= 
agendaManager.loadItems();

Everythng else should call items= agendaManager.loadTodaysItems();



Thanks.

Mounir











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



Re: How to resuse an Action class in different namespace contexts?

2012-07-23 Thread Łukasz Lenart
One base abstract class and two concrete classes which contain the
prepare() methods as specified.


Regards
-- 
Łukasz
mobile +48 606 323 122 http://www.lenart.org.pl/
Warszawa JUG conference - Confitura http://confitura.pl/

2012/7/23 Mounir Benzid m...@meetingmasters.de:


 I use two different namespaces to secure my web application ( with spring
 security)

 One is /pubilc  the other is called.. well..  /private. Everything
 underneath /private is available only  to logged-in users.


 Currently  there is an action class living in the /public namespace named
 ShowPublicAgendaAction
 which is responsible for showing today's agenda items.


 A very similar action ShowPrivateAgendaAction exists in the secured /private
 namespace
 which does pretty much the same thing, the only difference is, that all
 available agenda itens are presented to the user
 (not only those of today)


 I'd like to consolidate both actions since they differ only in one single
 line of code

  Public:   public void prepare() { ListAgendaItem items=
 agendaManager.loadTodaysItems();.}

 Private:  public void prepare() {  ListAgendaItem items=
 agendaManager.loadItems();..}


 How do I go about serving requests from different namespaces in one Action
 class?

 Requests coming-in from /private should call  items=
 agendaManager.loadItems();
 Everythng else should call items= agendaManager.loadTodaysItems();



 Thanks.

 Mounir











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


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