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.

Reply via email to