1 : no 2 : no Struts allows to forward from an action to another action!!! (should be documented in the mailing-list-archive and the dtd,...)
This way each page is a single problem (action to init, display, action to evaluate). Struts-config.xml will tie them together. Whether you use 1 or 2 actions for a page (earlier posts in the thread) does not matter. I prefer 1 action and control the "flow" using the parameter-attribute in the action-definition in struts-config.xml In the action I just have a if ("init".equals(mapping.getParameter()))... else if ("eval".equals(mapping.getParameter()))... hope this helps Alexander Jesse -----Original Message----- From: Ian Beaumont [mailto:[EMAIL PROTECTED]] Sent: Mittwoch, 20. Februar 2002 17:52 To: 'Struts Users Mailing List' Subject: RE: ActionForm and default values This means that in the action for the "select item" I need to get hold of the form bean for the next page I'm going to so I can populate it. Two problems with this: 1. How do I get hold of the form bean? Do I create it myself? 2. This all relies on me knowing the mappings of what page I'm going to go to next so I can populate the form bean. This defeats the object of having the struts-XML file. Below is the text from a previous email I sent. The only reply I got was the example didn't show 'best practises'. In which case, what is the best practise. I've been through the struts-example again. What I want to achieve is something similar to the 'Edit user registration details'. This pre-populates the form with existing details. Now the way the example does this is to create the RegistrationForm in the action and then populate it. >From "EditRegistrationAction.java" // Populate the user registration form if (form == null) { if (servlet.getDebug() >= 1) servlet.log(" Creating new RegistrationForm bean under key " + mapping.getAttribute()); form = new RegistrationForm(); if ("request".equals(mapping.getScope())) request.setAttribute(mapping.getAttribute(), form); else session.setAttribute(mapping.getAttribute(), form); } This seems really nasty as you are now hard-coding the name of the form class that will be used for validation on the next page. Any changes in future to the "struts-config" file may well break the system. It doesn't feel right to have to create these forms ourselves. Wouldn't it be more sensible to have a pre-creation method on the action of a form that allowed allowed a the action to populate the form fields before the page was displayed. -----Original Message----- From: Jim Crossley [mailto:[EMAIL PROTECTED]] Sent: 20 February 2002 16:38 To: Struts Users Mailing List Subject: Re: ActionForm and default values Ian Beaumont <[EMAIL PROTECTED]> writes: > Ok - I want to select an item on one page which will take me to > another page where I can edit the selected item. Sounds common enough. > How do I pre-populate the form for the edit page in the action for > the selected item as the form won't exist at this point? As long as you have the "name" attribute set correctly for the appropriate <action> element of struts-config, the formbean will always exist! The controller servlet creates it for you. -- Jim > -----Original Message----- > From: Jim Crossley [mailto:[EMAIL PROTECTED]] > Sent: 20 February 2002 16:06 > To: Struts Users Mailing List > Subject: Re: ActionForm and default values > > > It's pretty simple, I think. > > 1) The formbean is passed to the action's perform method by the Struts > controller. > > 2) The action populates the formbean (ReportDataForm) from the value > object (ReportData). > > 3) The action returns the appropriate ActionForm to render the view. > > 4) The view (ReportData.jsp) need look no more complicated than this: > > <html:form action="/reportAction"> > <html:text property="reportName"/> > </html:form> > > -- Jim > > Ian Beaumont <[EMAIL PROTECTED]> writes: > > > This question seems to be going around and around this mailing list > and > > no > > one has produced an answer. > > > > -----Original Message----- > > From: Dua, Amit [mailto:[EMAIL PROTECTED]] > > Sent: 20 February 2002 15:46 > > To: 'Struts Users Mailing List' > > Cc: '[EMAIL PROTECTED]' > > Subject: RE: ActionForm and default values > > > > > > But then how will I set the default values > > > > amit > > > > -----Original Message----- > > From: Keith [mailto:[EMAIL PROTECTED]] > > Sent: Wednesday, February 20, 2002 10:36 AM > > To: Struts Users Mailing List > > Subject: Re: ActionForm and default values > > > > > > try removing the value= attribute from your <html: text. > > hope that helps. > > > > --- "Dua, Amit" <[EMAIL PROTECTED]> wrote: > > > Hi > > > > > > I want to populate my page with default value > > > > > > So, in order to do that > > > I have a value object (ReportData), ReportDataForm (Form Bean) > > > > > > I populate the Value object through one of the Action classes and > then > > do > > a > > > Action Forward to one of the Jsp namely ReportData.jsp > > > > > > In the ReportData.jsp I do following > > > > > > ReportData reoportData = > > (ReportData)request.getAttribute("reportdata"); > > > <html:form action="reportAction.do"> > > > <html:text property="reportName" > > value="<%=reportData.getReportName()%>"/> > > > .................. > > > .............. > > > > > > > > > I do all the validation In ReportAction class which is mapped to > > > reportAction.do > > > > > > But when there is an error In the field , I am not able to get the > > value > > > populated for the text field. > > > > > > > > > Is there something wrong I am doing. > > > Or is there any other better way of doing this thing.. > > > > > > > > > Amit > > > > > > > > > -- > > > To unsubscribe, e-mail: > > <mailto:[EMAIL PROTECTED]> > > > For additional commands, e-mail: > > <mailto:[EMAIL PROTECTED]> > > > > > > > > > ===== > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Search the archive:- > > http://www.mail-archive.com/struts-user%40jakarta.apache.org/ > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Keith Bacon - Looking for struts work - South-East UK. > > phone UK 07960 011275 > > > > __________________________________________________ > > Do You Yahoo!? > > Yahoo! Sports - Coverage of the 2002 Olympic Games > > http://sports.yahoo.com > > > > -- > > To unsubscribe, e-mail: > > <mailto:[EMAIL PROTECTED]> > > For additional commands, e-mail: > > <mailto:[EMAIL PROTECTED]> > > > > -- > > To unsubscribe, e-mail: > > <mailto:[EMAIL PROTECTED]> > > For additional commands, e-mail: > > <mailto:[EMAIL PROTECTED]> > > -- > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>