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]

Reply via email to