Hi Stuart. The latter is what I do. Theoretically you can use the .Default syntax in both the template and the action, and I even know some people who use it. But I never was able to make it work back when I started and have continued to do it my way ever since.
Intake is tough to get working at first, but it is very nice after that. Ck > -----Original Message----- > From: Stuart Townhill [mailto:[EMAIL PROTECTED] > Sent: Sunday, March 02, 2003 3:07 PM > To: 'Turbine Users List' > Subject: RE: Intake From The Beginning? > > > Chris, > > Almost there I think, a whole weekends work and I have just managed to > get the form to display errors when deliberately tripping the rule, > cool! The last leg of this race is just to populate the databases with > the action, I'm guessing it isn't working because of the DEFAULT_KEY > thing you pointed out earlier. Would the following work? not sure on the > name value setup passing through with the RunData/Context: > > > ---On The Form--- > > <input type="hidden" name="querykey" value="new"> > > > ---Action--- Something like this?: > > Group group = intake.get("Customerentry", "querykey"); > Or > Group group = intake.get("Customerentry", > data.getParameters().getString("querykey")); > > > > Your help has been much appreciated and I will be putting my experiences > on the wiki so maybe it might help others. > > Cheers, > > Stuart. > > > > > > > -----Original Message----- > From: Chris K Chew [mailto:[EMAIL PROTECTED] > Sent: 02 March 2003 19:58 > To: Turbine Users List > Subject: RE: Intake From The Beginning? > > Hi Stuart. > > No problem, I understand where you are. I remember writing a message > about > a year ago to the tune of "Who the heck uses this Intake anyways, and > why is > it so hard to learn?". The guys in my office can probably remember my > outbursts... > > Torque does not implement the Retrievable interface because Torque is a > separate entity from Turbine, and Retrievable is a Turbine construction. > As > such, you need to do it manually for any object you want to populate > using > Intake. I posted on the wiki a small snippet of what implementing > Retrievable means, it is very simple to do: > > http://nagoya.apache.org/wiki/apachewiki.cgi?JakartaTurbine2Faq/CommonIn > take > Problems > > Keep in mind that Torque creates an empty target object that extends > your > base object for things like this (i.e.. in your case empty Customer > extends > BaseCustomer). Fortunately, Torque will leave your changes alone when > you > add to Customer and regenerate your OM. > > Good luck, > > Chris > > > -----Original Message----- > > From: Stuart Townhill [mailto:[EMAIL PROTECTED] > > Sent: Sunday, March 02, 2003 12:45 PM > > To: 'Turbine Users List' > > Subject: RE: Intake From The Beginning? > > > > > > Chris, > > > > Thank you for the reply, much appreciated. Haven't quite implemented > all > > of the recommendations yet but had a question about the implementing > > Retrievable in my target object. I thought that if I was using Torque > > generated objects it would create them already with Retrievable > > implemented? If not then is that also the case for the getQueryKey > > setQueryKey methods? > > > > Regards, > > > > Stuart. > > > > -----Original Message----- > > From: Chris K Chew [mailto:[EMAIL PROTECTED] > > Sent: 02 March 2003 16:46 > > To: Turbine Users List > > Subject: RE: Intake From The Beginning? > > > > Hi Stuart. I noticed a couple of things in your code samples: > > > > *Is there any info in Turbine.log? > > > > *Have you by any chance implemented org.apache.turbine.om.Retrievable > in > > your target object? This is an easy thing to miss and will keep > Intake > > from > > initializing. > > > > *I think you should have mapToObject="Customer" instead of > > mapToObject="customer" in your intake.xml group declaration. Java > cares > > about capitalization, and Customer is not the same class as customer. > > > > (These last two should make the #set ($customerGroup = > > $intake.Customerentry.mapTo($customer)) work anyways) > > > > *In your action class, you call group.getProperties(customer). I > think > > that > > you actually want group.setProperties(customer). If you read the > > JavaDoc > > for org.apache.turbine.services.intake.model.Group, it indicates that > > getProperties populates the form field from the object, while > > setProperties() sets the object properties from the form field. And > you > > want to populate the object in the action, not the form field. > > > > *Your action contains the line: > > Group group = intake.get("Group", IntakeTool.DEFAULT_KEY); > > which should be: > > Group group = intake.get("Customerentry", > > IntakeTool.DEFAULT_KEY); > > > > *One last thing, I have never been successful with the .Default > syntax. > > Instead, I set the querykey to something like "new", and put the query > > key > > in a hidden form field which is picked up in the action class and used > > in > > intake.get("groupname",querykey). > > > > I just created a Common Intake Problems page in the wiki. Please add > to > > it > > as you get your instance working! > > > > Good luck, > > > > Chris > > > > > > > > > > > -----Original Message----- > > > From: Stuart Townhill [mailto:[EMAIL PROTECTED] > > > Sent: Sunday, March 02, 2003 4:34 AM > > > To: 'Turbine Users List' > > > Subject: Intake From The Beginning? > > > > > > > > > To anyone who can help, > > > > > > I know intake is the most talked about topic and that everyone may > be > > > fed up of the posts but I have read a lot and now going around in > > > circles. If I get a very simple intake to work just using the tools > > > supplied with TDK and working with my database (business object) I > > will > > > attempt to write a very basic idiots guide on the wiki. Anyway not > > sure > > > what to say is wrong with my code but have copied and pasted four > > > cuttings from the relevant files. I have read the service document > and > > > how-to and are aware of it using Scarab and have seen many posts on > > > various different issues but I believe using the screen class to > > > populate the context rather than actions and the use of pull tools > > would > > > be simpler for a beginning. > > > > > > Pretty sure intake.xml is fine. > > > > > > Think I have populated context correctly in screen class? > > > > > > In template when I map to object in context " #set ($customerGroup = > > > $intake.Customerentry.mapTo($customer)) " my input field does not > > render > > > correctly in browser and the if statement to catch " > > FirstName.isValid() > > > " fails but they do create correctly with " #set ($customerGroup = > > > $intake.Customerentry.Default) " but from my reading this statement > is > > > only to do with intake and NOT mapping to a business object. > > > > > > Not to sure about action yet since haven't managed to create form > > > correctly but have written it. > > > > > > > > > ---My Coding Attempt--- > > > > > > ---Intake.xml--- > > > > > > <input-data basePackage="soundideas.covert.om."> > > > <group name="Customerentry" key="customerentry" > > > mapToObject="customer"> > > > <field name="Firstname" key="f" type="String" > > > mapToProperty="firstname"> > > > <rule name="minLength" value="1">Please enter first > > > name</rule> > > > </field> > > > </group> > > > </input-data> > > > > > > > > > ---Screen Class--- > > > > > > public class InsertCustomerIntake extends SecureScreen > > > { > > > public void doBuildTemplate(Context context) > > > { > > > Customer customer = new Customer(); > > > context.put("customer", customer); > > > } > > > } > > > > > > > > > ---Template--- > > > > > > <form action="$link.setPage("InsertCustomerIntake.vm")" > method="post" > > > name="customerentry"> > > > > > > <input type="hidden" name="action" value="doInsertCustomer"> > > > #if ($data.Parameters.nextTemplate) > > > <input type="hidden" name="nextTemplate" > > > value="$data.Parameters.nextTemplate"> > > > #else > > > <input type="hidden" name="nextTemplate" value="index.vm"> > > > #end > > > > > > #set ($customerGroup = $intake.Customerentry.mapTo($customer)) > > > > > > #if ( !$customerGroup.Firstname.isValid() ) > > > $customerGroup.Firstname.Message<br> > > > #end > > > > > > <input type="text" name="$customerGroup.Firstname.Key" > > > value="!$customerGroup.Firstname ")> > > > > > > <input type="submit" name="eventSubmit_doInsert" > value="Insert"/> > > > > > > $intake.declareGroups() > > > > > > </form> > > > > > > > > > ---Action--- > > > > > > public class doInsertCustomer extends SecureAction > > > { > > > public void doInsert(RunData data, Context context) > > > throws Exception > > > { > > > IntakeTool intake = (IntakeTool) context.get("intake"); > > > Group group = intake.get("Group", IntakeTool.DEFAULT_KEY); > > > if (group.isAllValid()) > > > { > > > Customer customer = new Customer(); > > > group.getProperties(customer); > > > customer.save(); > > > > > > > > > data.setScreenTemplate(data.getParameters().getString("nextTemplate")); > > > } > > > } > > > } > > > > > > Regards, > > > > > > Stuart. > > > > > > > > > --------------------------------------------------------------------- > > 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] > > > > > --------------------------------------------------------------------- > 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]
