Re: [OT] Struts and Design Patterns

2003-02-17 Thread Matt Raible <[EMAIL PROTECTED]>
Figures... I own the book and left it at work.  Anyone care to save 
me a trip into the office to verify this?

Thanks,

Matt

--- In [EMAIL PROTECTED], "Jerome Jacobsen" 
<[EMAIL PROTECTED]> wrote:
> This has already been done by Ted in his book, I think.  At least 
in the
> downloadable draft version there is a Patterns chapter.  Actually 
it is
> Appendix D.
> 
> > -Original Message-
> > From: Matt Raible [mailto:matt@r...]
> > Sent: Monday, February 17, 2003 11:57 AM
> > To: [EMAIL PROTECTED]
> > Subject: [OT] Struts and Design Patterns
> >
> >
> > I'm writing a chapter on Struts for a book, Professional JSP 
2.0, from
> > Wrox (http://www.wrox.com/books/1861008325.htm).  The reason I'm 
sending
> > this post is to verify my belief of the different design 
patterns that
> > Struts implements.  From the Core J2EE Design Patterns book (by 
Alur,
> > Crupi, and Malks), there are 6 patterns discussed:
> >
> > Intercepting Filter
> > Front Controller
> > View Helper
> > Composite View
> > Service to Worker
> > Dispatcher View
> >
> > In Struts, I'm assuming the following:
> >
> > Front Controller (ActionServlet)
> > View Helper (ActionForm)
> > Composite View (Tiles)
> > Service to Worker (ActionServlet to your Actions)
> > Dispatcher View (RequestProcessor)
> >
> > Thanks,
> >
> > Matt
> >
> >
> >
> > -

> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> 
> 
> ---
--
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Any Struts-based calendar examples out there?

2003-01-23 Thread Matt Raible &lt;[EMAIL PROTECTED]>
One open source project (Roller) I work on has a JSP Tag Library
calendar - you might be able to tweak it.

Project Page:

http://rollerweblogger.org/

And there's also a big calendar as part of it - example at:

http://www.rollerweblogger.org/page/roller/Archives

For my favorite javascript-based popup-calendar, check out:

http://www.mattkruse.com/javascript/calendarpopup/

#2 is my fav.

Matt

--- In [EMAIL PROTECTED], "James Mitchell" <[EMAIL PROTECTED]> wrote:
> This should give you a few ideas.although it requires javascript:
> 
>  http://javascript.internet.com/calendars/
> 
> 
> 
> --
> James Mitchell
> Software Engineer/Struts Evangelist
> http://www.open-tools.org/
> 
> "The man who does not read good books has no advantage over the man who
> cannot read them."
>   - Mark Twain (1835-1910)
> 
> 
> 
> 
> 
> 
> 
> > -Original Message-
> > From: Trevor Morris [mailto:morr0209@t...] 
> > Sent: Wednesday, January 22, 2003 9:34 PM
> > To: [EMAIL PROTECTED]
> > Subject: Any Struts-based calendar examples out there?
> > 
> > 
> > I have to create a calendar page to display meetings, etc.  
> > As you know,
> > anything date-related is not the easiest task in the world.  
> > I have found a
> > JSP-based calendar, but it would require some extensive 
> > rework to get rid
> > of all the scriplet code.  
> > 
> > Short deadline + overworked programmer = trying to steal code 
> > instead of
> > reinventing the wheel ;)
> > 
> > Anyone seen anything in any struts example code out there?
> > 
> > Trevor
> > 
> > --
> > To unsubscribe, e-mail:   
> >  [EMAIL PROTECTED]>
> > For 
> > additional commands, 
> > e-mail: 
> > 
> > 
> 
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: [Validator] Client-side works, but not server-side

2002-12-30 Thread Matt Raible &lt;[EMAIL PROTECTED]>
Actually, I'm not getting the famous Struts blank screen of
nothingness, but rather, it seems that validation is just not kicking
in - it routes me to my success page.

I am using the forwardInput="true" on my  element and have
the input specified as "editProfile" where my forward is below:



I've tried using the path instead (input="/userProfile.do") and it
doesn't seem to work either.  I'm sure it's something simple, I just
can't seem to figure it out right now.

Thanks,

Matt

--- In [EMAIL PROTECTED], "Michelle Wynn" <[EMAIL PROTECTED]> wrote:
> 
> I assume you are only getting nothing when the server side validation
> fails.  If you are getting nothing when the validation doesn't fail
that is
> another problem.
> 
> If it is the former, I suspect your problem is related to your input
> parameter in the action mapping.  I had a similar situation (blank
screen
> when server side validation failed and javascript was turned off). 
Turned
> out Input was set to an invalid path, once it was corrected, it
worked like
> a charm.
> 
> 
> 
> 
>
  
>   "Matt Raible"
  
>
>   ns.com>  cc: 
  
>Subject:  [Validator]
Client-side works, but not server-side   
>   12/29/2002 05:58 
  
>   PM   
  
>   Please respond to
  
>   "Struts Users
  
>   Mailing List"
  
>
  
>
  
> 
> 
> 
> 
> I have the following defined in validation.xml:
> 
>   
> 
> depends="required,email">
>name="required"
> key="errors.required"/>
>name="email"
> key="errors.email"/>
> 
>   
>   
> 
>   
> 
> And this works great for prompting me with client-side validation, but
> when I turn off Javascript to test server-side validation, I get
> nothing.  Any ideas?  I'm using inputForward="true" on my ,
> but I changed to be a regular path to "/editProfile.do" and still I get
> no server-side validation.  Here is my action-mapping:
> 
>name="userForm" scope="session" input="/userProfile.do"
>   parameter="action" unknown="false" validate="true"/>
> 
> Any ideas?  I'm fairly confident that I have things configured
> correctly, as the client-side validation works.  Suggestions are
> appreciated.
> 
> Thanks,
> 
> Matt
> 
> 
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: login mechanism

2002-12-30 Thread Matt Raible &lt;[EMAIL PROTECTED]>
I have my ActionServlet mapped to "*.do" and an ActionFilter mapped to
that same url-pattern.  In ActionFilter, I check to see if there is a
UserForm in the session, and secondly to see if
request.getRemoteUser() returns null.  If either of these occur, I
call my Business Delegate (UserManager in my case) to get the user's
information. Currently, it talks to a database to get the information,
but it easily could talk to a Directory Server like LDAP.  Here's some
code from my doFilter method:

UserForm userForm = (UserForm)
session.getAttribute(Constants.USER_KEY);
ServletContext ctx = filterConfig.getServletContext();
String username = request.getRemoteUser();

// user authenticated, empty user object
if ((username != null) && (userForm == null)) {
try {
UserManager mgr = new UserManagerImpl((String)
ctx.getAttribute(Constants.DAO_TYPE));
UserForm user = mgr.getUser(username);
session.setAttribute(Constants.USER_KEY, user);
} catch (Exception e) {
log.error("Error getting user's information", e);
e.printStackTrace();

ActionErrors errors = new ActionErrors();
errors.add(ActionErrors.GLOBAL_ERROR,
   new ActionError("errors.general"));

while (e != null) {
errors.add(ActionErrors.GLOBAL_ERROR,
   new ActionError("errors.detail",
e.getMessage()));
e = (Exception) e.getCause();
}

request.setAttribute(Globals.ERROR_KEY, errors);

// forward to the error page
RequestDispatcher dispatcher =
request.getRequestDispatcher("/error.jsp");
dispatcher.forward(request, response);

return; // stop processing
}
}



--- In [EMAIL PROTECTED], usha <[EMAIL PROTECTED]> wrote:
> Hi
> 
> can you tell me briefly how you are using filtes in security-example 
> application.
> 
> Thanks
> usha
> 
> Matt Raible wrote:
> 
> >You could use a filter to map to all your protected resources.  This 
> >is what I do in the security-example application I recently wrote.  
> >You can download the source at:  
> >
> >http://javawebapps.com/downloads/security-example.zip (14MB)
> >
> >HTH,
> >
> >Matt
> >
> >--- In [EMAIL PROTECTED], usha <[EMAIL PROTECTED]> wrote:
> >  
> >
> >>Hi
> >>
> >>Sorry what you mean by proxy. i didn't get you actually i wanted 
> >>
> >>
> >to 
> >  
> >
> >>authenticate logged in user against the users that are there in 
> >>
> >>
> >the 
> >  
> >
> >>database, and when ever they bookmark some page and if they go to 
> >>
> >>
> >that 
> >  
> >
> >>page directly i wanted to display the login page after they login 
> >>sussefully only . right now with form based authentication i am 
> >>
> >>
> >getting 
> >  
> >
> >>this , but i had some drawbacks as i mentioned in the previous 
> >>
> >>
> >mail. is 
> >  
> >
> >>there a standard way i can use for user login checks.
> >>
> >>thanks
> >>usha
> >>
> >>Eddie Bush wrote:
> >>
> >>
> >>
> >>>Write a proxy to retrieve the user data you wish to put in the 
> >>>session. The proxy will check to see if a user has been 
> >>>  
> >>>
> >authenticated 
> >  
> >
> >>>(request.getUserPrincipal() != null), and, if they have, it will 
> >>>  
> >>>
> >check 
> >  
> >
> >>>to see if your user data has been created yet.  If it has, it 
> >>>  
> >>>
> >will 
> >  
> >
> >>>just take it from the session and return it.  If it hasn't, it 
> >>>  
> >>>
> >will 
> >  
> >
> >>>create it, save it to the session, and return it.
> >>>
> >>>That help?
> >>>
> >>>usha wrote:
> >>>
> >>>  
> >>>
> Hi
> 
> i am new to structs. right now i am using in my project form 
> 
> 
> >based 
> >  
> >
> authentication. with this i have some problems like i cannot 
> instantiate some of session veriable upon logging etc. is there 
> 
> 
> >any 
> >  
> >
> standard mechnism for loging using sturcts. i am using JBoss as 
> 
> 
> >my 
> >  
> >
> application server.
> 
> Thanks in advance
> usha.. 
> 
> 
> >>>  
> >>>
> >>
> >>
> >>--
> >>To unsubscribe, e-mail:   
> >>For additional commands, e-mail: 
> >>
> >>
> >
> >
> >--
> >To unsubscribe, e-mail:   
> >For additional commands, e-mail: 
> >  
> >
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: login mechanism

2002-12-29 Thread Matt Raible &lt;[EMAIL PROTECTED]>
You could use a filter to map to all your protected resources.  This 
is what I do in the security-example application I recently wrote.  
You can download the source at:  

http://javawebapps.com/downloads/security-example.zip (14MB)

HTH,

Matt

--- In [EMAIL PROTECTED], usha <[EMAIL PROTECTED]> wrote:
> Hi
> 
> Sorry what you mean by proxy. i didn't get you actually i wanted 
to 
> authenticate logged in user against the users that are there in 
the 
> database, and when ever they bookmark some page and if they go to 
that 
> page directly i wanted to display the login page after they login 
> sussefully only . right now with form based authentication i am 
getting 
> this , but i had some drawbacks as i mentioned in the previous 
mail. is 
> there a standard way i can use for user login checks.
> 
> thanks
> usha
> 
> Eddie Bush wrote:
> 
> > Write a proxy to retrieve the user data you wish to put in the 
> > session. The proxy will check to see if a user has been 
authenticated 
> > (request.getUserPrincipal() != null), and, if they have, it will 
check 
> > to see if your user data has been created yet.  If it has, it 
will 
> > just take it from the session and return it.  If it hasn't, it 
will 
> > create it, save it to the session, and return it.
> >
> > That help?
> >
> > usha wrote:
> >
> >> Hi
> >>
> >> i am new to structs. right now i am using in my project form 
based 
> >> authentication. with this i have some problems like i cannot 
> >> instantiate some of session veriable upon logging etc. is there 
any 
> >> standard mechnism for loging using sturcts. i am using JBoss as 
my 
> >> application server.
> >>
> >> Thanks in advance
> >> usha.. 
> >
> >
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: Best Practices for Logging?

2002-12-09 Thread Matt Raible &lt;[EMAIL PROTECTED]>
Thanks for all the responses on this topic, now another question:

What is the recommended method of configuring logging for a particular
class:

private Log log = LogFactory.getLog(getClass().getName());

or

private Log log = LogFactory.getLog(className.class);

The first is easier as it allows for copy/paste, and might allow for
placement in a parent class with protected access.  Would that work
for child classes?

Thoughts?

Matt

--- In [EMAIL PROTECTED], [EMAIL PROTECTED] wrote:
> Just some addition to this logging discussion.
> If u are using log4j , then in any case,there wil be 1 instance per
class and 
> not per object.BEcause logger instances are named entities and they are 
> cached.So if u ask for the same logger again(same class name I
mean), u will 
> retrieve same instance.New instance will not be created.I dont know
how other 
> logger implementations used in commons logging work.So u dont add any 
> performance advantage by making them static.
> 
> regards,
> Shirish
> 
> -Original Message-
> From: ekbush [mailto:ekbush@s...]
> Sent: Friday, December 06, 2002 9:38 PM
> To: struts-user
> Cc: ekbush
> Subject: Re: Best Practices for Logging?
> 
> 
> Sri Sankaran wrote:
> 
> >>-Original Message-
> >>From: Matt Raible [mailto:matt@r...] 
> >>Sent: Friday, December 06, 2002 1:34 PM
> >>To: [EMAIL PROTECTED]
> >>Subject: Best Practices for Logging?
> >>
> >>
> >>I'm wondering what is considered the best practice for logging using 
> >>commons-logging in a Struts app.  My current approach is to 
> >>have a Base 
> >>class in every package that has the following:
> >>
> >>protected Log log =
> >> LogFactory.getLog("my.package.name");
> >>
> >>But I've noticed that some of the Struts examples have an instance of 
> >>this in every class.  
> >>
> >>
> >Personally I prefer the class level.  This provides you with a
finer grain of 
> control.  However, I restrict it to only one per class and not one
per object
> >
> >public class Foo {
> >  private static Log log = LogFactory.getLog(Foo.class);
> >  ..
> >}
> >
> General consensus seems to be that this is the "best practice"
approach. 
>  You wind up with more loggers, but they give you very fine-grained 
> control as Sri mentioned.  You can still set a log-level for a package, 
> but you then also have the ability to manipulate the log-level on a per 
> class basis too - so you can relaly "zoom-in" on things.
> 
> >>Is this recommended, so that logging 
> >>can be done 
> >>on a class level, as well as a package level?  Any thoughts/opinions 
> >>are appreciated.
> >>
> It should be a static member as per what Sri shows (so you only have
one 
> per class).  Yes - it's so you can control logging on a package/class 
> basis.
> 
> >>Thanks,
> >>
> >>Matt
> >>
> >>
> >Sri
> >
> 
> -- 
> Eddie Bush
> 
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 


--
To unsubscribe, e-mail:   
For additional commands, e-mail: