Return-Path: Delivered-To: apmail-jakarta-struts-user-archive@www.apache.org Received: (qmail 94311 invoked from network); 4 Feb 2004 05:11:02 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 4 Feb 2004 05:11:02 -0000 Received: (qmail 11659 invoked by uid 500); 4 Feb 2004 05:09:48 -0000 Delivered-To: apmail-jakarta-struts-user-archive@jakarta.apache.org Received: (qmail 11603 invoked by uid 500); 4 Feb 2004 05:09:48 -0000 Mailing-List: contact struts-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list struts-user@jakarta.apache.org Received: (qmail 11534 invoked from network); 4 Feb 2004 05:09:47 -0000 Received: from unknown (HELO web41411.mail.yahoo.com) (66.218.93.77) by daedalus.apache.org with SMTP; 4 Feb 2004 05:09:47 -0000 Message-ID: <20040204050958.70450.qmail@web41411.mail.yahoo.com> Received: from [208.191.101.87] by web41411.mail.yahoo.com via HTTP; Tue, 03 Feb 2004 21:09:58 PST Date: Tue, 3 Feb 2004 21:09:58 -0800 (PST) From: Pat Young Subject: RE: Need to pass data to JSP in ActionForm To: Struts Users Mailing List , andrew.david.hill@gridnode.com In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N I like the adapter idea. Does the adapter contain all data that is required by the jsp page? so fomr a modelling perspective, do you have adapter that match the pages? Thanks, Pat Young --- Andrew Hill wrote: > If the list doesnt change during the course of a > users session then the best > thing to do is to create it on first demand and > store it in the session. > This saves you from looking it up from the db > repeatedly when unnecessary > and is thus more efficient. If the list is the same > for all users and doesnt > change at all then you could store it in the servlet > (application) context. > > If it does change (for example when new records are > added) then you will > still need to look it up each time. In this case > your best bet might be to > extend Rick's suggestion about having a seperate > helper class that assembles > the list (always a good idea). This > helper/manager/thing is part of your > business process layer. Above that you could have an > aditional (very simple) > adaptor class that is passed a request, calls this > helper to obtain the > list, and stores said list under the appropriate > request attribute. > > Your validate method could thus call this adapter to > setup the list when it > is validating the entered data. Your setup action, > likewise would call the > adaptor class rather than directly calling the > business layer and storing > the result. > > One thing to beware of when you do such non-trivial > things in the > actionform, is that if memory serves me correctly > (someone please correct me > if Im wrong on this!), exceptions thrown here wont > be handled by the > exception handler you configured in struts config as > the try/catch that > invokes that handler is merely around the invocation > of the actual action > execute and not the form reset / validate stuff. > > These are some of the reasons I personally prefer to > do my validation in the > action itself and dont make use of the forms > validate method. (Of course if > your using struts validator that becomes problematic > too) > > hth > Andrew > > > -----Original Message----- > From: Rick Reumann [mailto:struttin@reumann.net] > Sent: Wednesday, 4 February 2004 12:26 > To: Struts Users Mailing List > Subject: Re: Need to pass data to JSP in ActionForm > > > Pat Young wrote: > > > 6. The problem I am having is that if the > ActionForm > > failes validation, then the sales.jsp page gets an > > error becaue it can not find the bean in the > Request > > for the products list. Should I build this bean > in my > > validate and place it in the request at the > beginning > > of validate? If validate fails, there is no other > > opportunity to build the products list and get it > into > > the Request. > > Personally I often opt for the easy solution and put > the List in Session > scope, but there are other alternatives that have > been discussed on this > list before. > > > 7. I typically uses Actions to retrieves and > build > > beans and then add them to the request for the jsp > to > > access. Is this an acceptable practice also? > > Depends what you mean by "build beans." Nothing > wrong wtih setting stuff > into Request scope from your Actions, but make sure > you are calling some > business process that does the actual "building." > For example... > > //in your Action: > List someList = someBusinessClass.getMyList(); > request.setAttribute("listWhatever", someList); > > -- > Rick > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > struts-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: > struts-user-help@jakarta.apache.org > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > struts-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: > struts-user-help@jakarta.apache.org > __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/ --------------------------------------------------------------------- To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: struts-user-help@jakarta.apache.org