You do. That code is what I put into the screen class. 1. Get the object from Torque. 2. Get the group from the intake tool. 3. Map to object to the group.
> -----Original Message----- > From: Xavier Ottolini [mailto:[EMAIL PROTECTED]] > Sent: Monday, January 13, 2003 8:51 AM > To: Turbine Users List > Subject: Re: How to create a business object to represent the > intake group ? > > > The error were diplayed becaus my fields were not propercase in the > intake.xml. > > The problem is now that the fields are always empty. In the solution > that Quinton sended, nothing is written if I had to set a > mapToObject. I > thought that to prepopulate the fields, I had to set a > mapToObject on a > group ? > > > Xavier Ottolini wrote: > > > Thank you for your answer, Quinton. > > > > I tried to implement your sample, I noticed one error : > > > Group group = intake.getGroup("Page1"); > > the method does not exist in the IntakeTool class. So I > replaced this > > line with : > > Group group = intake.get("Group", IntakeTool.DEFAULT_KEY); > > > > When I try to display the form, I get the following error in the > > turbine.log: > > [Mon Jan 13 11:54:42 CET 2003] -- ERROR -- Error rendering Velocity > > template: screens/param/AgenceForm.vm: Invocation of method > > 'get("agenceid")' in class > > org.apache.turbine.services.intake.model.Group threw > exception class > > org.apache.turbine.util.TurbineException > > [Mon Jan 13 11:54:42 CET 2003] -- ERROR -- Error rendering Velocity > > template: screens/param/AgenceForm.vm: Error rendering Velocity > > template: screens/param/AgenceForm.vm: Invocation of method > > 'get("agenceid")' in class > > org.apache.turbine.services.intake.model.Group threw > exception class > > org.apache.turbine.util.TurbineException > > > > "agenceid" is a field of my Group. > > Why do I get such messages ? > > > > I have got other questions about your doBuildTemplate sample : > > 1) How is the group updated in the intake instance ? Is the > > "group.setProperties(obj)" enough ? > > 2) Why is there no "context.put(intake)" ? > > > > Quinton McCombs wrote: > > > >> Here is one way to accomplish what you are trying to do. > >> > >> When accessing a data entry form, I have an action or a > screen class > >> that will load the appropriate object with Torque. I then get the > >> intake tool from the context and map my object to the group. > >> > >> When the page displays to the user, the fields are > populated with the > >> data from the object. When the action executes, I validate > the intake > >> group. If validation fails, I do nothing else. The same > page will > >> be displayed again with the values the user entered. If > validation > >> is successful, I take the name of the next template to > display either > >> from some configurable value (ie. Hidden form field, > properties file, > >> etc). > >> > >> For the sake of this discussion - template with the form > = Page1.vm > >> intake group name = Page1Group Action = Page1Action > >> > >> The form code would look like this: > >> <form ... > action='$link.setPage("Page1.vm").setAction("Page1Action")> > >> #set( $group = $intake.Page1Group.Default ) > >> $intake.declareGroups() <input type="hidden" > >> name="nextTemplate" value="Page2.vm"> > >> <input ... name="$group.Field1.Key" value="$group.Field1"> > >> $!group.Field1.Message <input ... Name="$group.Field2.Key" > >> value="$group.Field2"> $!group.Field2.Message > >> > >> > >> screens.Page1.java doBuildTemplate() looks like > >> > >> protected void doBuildTemplate(RunData data, Context > context) throws > >> Exception { > >> IntakeTool intake = (IntakeTool) context.get("intake"); > >> MyObject obj = <code to retreive using torque> > >> Group group = intake.getGroup("Page1"); > >> group.setProperties(obj); > >> } > >> > >> actions.Page1Action doPerform() looks like > >> > >> public void doPerform(RunData data, Context context) > throws Exception > >> { IntakeTool intake = (IntakeTool) context.get("intake"); > >> Group group = intake.getGroup("Page1"); > >> if(group.isAllValid()) > >> { > >> MyObject obj = <code to retreive using torque> > >> group.getProperties(obj); > >> obj.save(); > >> > >> > data.setScreenTemplate(data.getParameters().getString("nextTemplate") > >> ); > >> } > >> } > >> > >> > >> Although in my example, I used a screen class to populate the > >> context, you could use an action instead. It is also > possible to use > >> pull tools to get the persistent object and map it to the intake > >> group. I normally use actions to populate the context. > >> > >> You can also use ActionEvents instead of normal actions... I just > >> wanted to keep the example as basic as possible. > >> > >> > >> > >>> -----Original Message----- > >>> From: Xavier Ottolini [mailto:[EMAIL PROTECTED]] Sent: > >>> Friday, January 10, 2003 10:06 AM > >>> To: Turbine Users List > >>> Subject: How to create a business object to represent the intake > >>> group ? > >>> > >>> > >>> Hi, > >>> > >>> I want to use Intake to redisplay a form with an error in > the data. > >>> > >>> In the how-to, it is written that to map the intake group to a > >>> business object , I should do something like this : > >>> #set($loginForm = $mytool.getFormInstance()) > >>> $loginForm.setQueryKey("abc") > >>> #set($loginGroup = $intake.LoginGroup.mapTo($loginForm)) > >>> > >>> 1) My first question is : what is $mytool ? is it a > business object > >>> ? > >>> > >>> 2) Nothing is written about the SecureScreen class when Intake is > >>> used. What should I do in the doBuildTemplate method ? > >>> > >>> I read already the how-to and the service page, but I think that > >>> this point is confused. > >>> > >>> Can anyone give me an explanation ? > >>> > >>> Thanks > >>> > >>> Xavier > >>> > >>> > >>> -- > >>> To unsubscribe, e-mail: <mailto:turbine-user-> > >>> [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:turbine-user-> [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]>
