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 <[EMAIL PROTECTED]> 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:[EMAIL PROTECTED] > 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: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]