struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Mitchell" <jmitch...@apache.org>
Subject Re: Subclassing ActionForward
Date Wed, 18 May 2005 22:17:03 GMT
LOL...about 3 minutes with Textpad and it's wonderful block select (Alt + 
mouse drag).



--
James Mitchell
Software Engineer / Open Source Evangelist
Consulting / Mentoring / Freelance
EdgeTech, Inc.
http://www.edgetechservices.net/
678.910.8017
AIM:   jmitchtx
Yahoo: jmitchtx
MSN:   jmitchell@apache.org




----- Original Message ----- 
From: "Benedict, Paul C" <paul_benedict@merck.com>
To: "'Struts Users Mailing List'" <user@struts.apache.org>
Sent: Wednesday, May 18, 2005 4:11 PM
Subject: RE: Subclassing ActionForward


> How long did it take to do your nice UML graph in ASCII? :)
>
> -----Original Message-----
> From: James Mitchell [mailto:jmitchell@apache.org]
> Sent: Wednesday, May 18, 2005 3:02 PM
> To: Struts Users Mailing List; lee@leebase.com
> Subject: Re: Subclassing ActionForward
>
>
> In your BaseDispatchAction override the execute() method, and in that, if
> everything checks out (session expiration, authentication, authorization,
> etc, etc) then simply super.execute().
>
>  DispatchAction    MyBaseDispAct      CustomerAction
>      |                   |                  |
> ------- execute() ------->|----.             |
>      |                   |    |             |
>      |                   | (if session ok)  |
>      |                   |    |             |
>      |<--super.execute()------'             |
>      |                   |                  |
>      |--------------- foo() --------------->|
>      |                   |                  |
>      |                   |                  |
>
>
> --
> James Mitchell
> Software Engineer / Open Source Evangelist
> Consulting / Mentoring / Freelance
> EdgeTech, Inc.
> http://www.edgetechservices.net/
> 678.910.8017
> AIM:   jmitchtx
> Yahoo: jmitchtx
> MSN:   jmitchell@apache.org
>
>
>
>
> ----- Original Message ----- 
> From: "Lee Harrington" <leebase@gmail.com>
> To: "Struts Users Mailing List" <user@struts.apache.org>
> Sent: Wednesday, May 18, 2005 1:47 PM
> Subject: Re: Subclassing ActionForward
>
>
> I'm all for doing things "the struts way".
>
> What I don't see in your example is WHERE to either throw the
> exception or call the global forward.  I'm trying to avoid putting
> this in all my actions (btw, I use dispatch actions).
>
> I did have the foresight to subclass the dispatchAction class:
>
> public class BaseDispatchAction extends DispatchAction {
>
> /**
> *
> */
> public BaseDispatchAction() {
> super();
>
> }
>
> public static void main(String[] args) {
> }
> }
>
> I just don't see where I have access to my "struts goodies" like
> request, mapping etc.
>
> Sorry to be so dull.
>
> Lee
>
> On 5/18/05, James Mitchell <jmitchell@apache.org> wrote:
>> I do not recommend using a filter.  You are much better off using what
>> you've already invested your time in (Struts).
>>
>> By using a base action as a single point of entry into your Actions, you
>> can
>> do this check in one place, and reuse any resources already handed to you
>> in
>> your base action.
>>
>> You could:
>> a) forward to some global forward
>>
>> For example:
>>
>> <global-forwards>
>>   <forward name="STATE__SESSION_EXPIRED" path="/sesson-expired.jsp"/>
>> ...(removed for brevity)...
>> <global-forwards>
>>
>> b) throw an exception that you've globally configured
>>    Struts to handle (declarative exception handling)
>>
>> With b you now have a declarative way to handle an expired
>> sessions and you have full access to your resource bundle.
>>
>> With either approach, you don't have to worry about whether your app is
>> the
>> root application (http://www.myapp.com/), or nested either by
>> configuration
>> or using Modules (http://www.myapp.com/go/here/for/my/app/), all cases 
>> are
>> handled.
>>
>> With a filter, you would basically have to hard code where your app goes.
>> For example:
>>  - /foo.jsp
>>      (single jsp to display some friendly error message)
>>
>>  - /NonStruts/SessionExpiredCustomServlet
>>      (custom servlet for dealing with sessions)
>>
>>  - /SessionExpired.do
>>      (forward to Struts anyway.....bad idea)
>>
>> Sure, you could get foo.jsp (from above) as a context-param, but I like 
>> to
>> keep my work in one place, the struts-config.xml file.
>>
>> --
>> James Mitchell
>> Software Engineer / Open Source Evangelist
>> Consulting / Mentoring / Freelance
>> EdgeTech, Inc.
>> http://www.edgetechservices.net/
>> 678.910.8017
>> AIM:   jmitchtx
>> Yahoo: jmitchtx
>> MSN:   jmitchell@apache.org
>>
>>
>> ----- Original Message -----
>> From: "Lee Harrington" <leebase@gmail.com>
>> To: "Struts Users Mailing List" <user@struts.apache.org>
>> Sent: Wednesday, May 18, 2005 12:07 PM
>> Subject: Re: Subclassing ActionForward
>>
>> Ok....have a filter...it runs (use logging to determine this).
>>
>> I'm stuck on how to forward to the login page.
>>
>> Here's my filter code:
>>
>> public void doFilter(ServletRequest request,
>> ServletResponse response,
>> FilterChain chain)
>> throws IOException, ServletException {
>>
>> try {
>> chain.doFilter(request, response);
>> //
>> // Ensure there is a user in the session
>> //
>> UserDTO user = (UserDTO) request.getSession().getAttribute("user");
>> if (user==null) {
>> // User is not logged in, redirect to login page
>> // How do I do that?
>> }
>>
>> } finally {
>> }
>> }
>>
>> TIA,
>>
>> Lee
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
>
> ------------------------------------------------------------------------------
> Notice:  This e-mail message, together with any attachments, contains 
> information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, New 
> Jersey, USA 08889), and/or its affiliates (which may be known outside the 
> United States as Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as 
> Banyu) that may be confidential, proprietary copyrighted and/or legally 
> privileged. It is intended solely for the use of the individual or entity 
> named on this message.  If you are not the intended recipient, and have 
> received this message in error, please notify us immediately by reply 
> e-mail and then delete it from your system.
> ------------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
> 



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


Mime
View raw message