You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Stuart Townhill <st...@townhill.net> on 2003/03/02 12:33:59 UTC

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.

Re: Intake From The Beginning?

Posted by Bill <bh...@collaborativefusion.com>.
Stuart

There are a couple of problems in your code...

The big problem I see is that you are mapping your form to an object in
your template and then trying to access it with the DEFAULT_KEY in your
action class.

The second problem may be a misunderstanding in how to use intake.  In
your screen class you pass a Customer object into the context.  This
only makes sense if you are trying to populate the form with the values
of that object (for example if the form is to update a customer's info)
which your arent since the object is empty and you create a new object
in the action class.  Since the purpose of the form seems to be to
populate new customer objects, then map the form to Default, remove the
code in your screen class that places the customer object in context,
and leave your action class the way it is.

To put it another way, i think you confused the purpose of mapTo( object
).  This is not to map the elements of the form to fields of a class,
thats whats in intake.xml.  This is to map the values of an existing
object to the elements of a form.

-b


On Sun, 2003-03-02 at 06:33, Stuart Townhill wrote:
> 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: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


RE: Intake From The Beginning?

Posted by Stuart Townhill <st...@townhill.net>.
Bill,

After adding the properties to the build.properties and attempting to
rebuild om layer generated the following error:

\src\java\soundideas\covert\om\BaseEmployeejob.java:373: unreported
exception ja
va.lang.Exception; must be caught or declared to be thrown
    [javac]         setPrimaryKey(key);
    [javac]         ^
    [javac] 1 error

But have managed to do it manually as Chris K Chew mentioned

Regards,

Stuart.

-----Original Message-----
From: Bill [mailto:bhalpin@collaborativefusion.com] 
Sent: 02 March 2003 19:58
To: Turbine Users List
Subject: RE: Intake From The Beginning?

Stuart 

If you are using torque in TDK2.1 then you dont have to do anything.  If
you are using TDK2.2 then you have to change the following properties to
the Torque Configuration section of build.properties and rebuild the om
layer:

addIntakeRetrievable=true
retrievableInterface=org.apache.turbine.om.Retrievable
 


On Sun, 2003-03-02 at 14:45, Stuart Townhill wrote:
> 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:chris@fenetics.com] 
> 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:stuart@townhill.net]
> > 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: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


RE: Intake From The Beginning?

Posted by Bill <bh...@collaborativefusion.com>.
Stuart 

If you are using torque in TDK2.1 then you dont have to do anything.  If
you are using TDK2.2 then you have to change the following properties to
the Torque Configuration section of build.properties and rebuild the om
layer:

addIntakeRetrievable=true
retrievableInterface=org.apache.turbine.om.Retrievable
 


On Sun, 2003-03-02 at 14:45, Stuart Townhill wrote:
> 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:chris@fenetics.com] 
> 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:stuart@townhill.net]
> > 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: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Failed build

Posted by Keshava Murthy <ke...@bigtec.org>.
Hi,

I am trying to migrate from turbine 2.1 to turbine 2.2 with mysql as the
database. When I try to build the application using command ant init the
build is failing, and the error I am getting is -

         ^
    [javac]
E:\tdk-2.2\webapps\CTDMS1\WEB-INF\src\java\org\bigtec\CTDMS1\om\Base
HisSubLabHemDtl.java:607: cannot resolve symbol
    [javac] symbol  : method keyFor (double)
    [javac] location: class org.apache.torque.om.SimpleKey
    [javac]         return SimpleKey.keyFor(getIhisSlhdId());

In my project.xml schema I have used datatype FLOAT for columns which are
defined as primary key.

Please let me know how can I overcome this problem?

regards,
Keshava Murthy. S




---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


RE: Intake From The Beginning?

Posted by Chris K Chew <ch...@fenetics.com>.
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:stuart@townhill.net]
> 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:chris@fenetics.com]
> 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:stuart@townhill.net]
> > 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:chris@fenetics.com]
> > 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:stuart@townhill.net]
> > > 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: turbine-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


RE: Intake From The Beginning?

Posted by Stuart Townhill <st...@townhill.net>.
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:chris@fenetics.com] 
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:stuart@townhill.net]
> 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:chris@fenetics.com]
> 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:stuart@townhill.net]
> > 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: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


RE: Intake From The Beginning?

Posted by Chris K Chew <ch...@fenetics.com>.
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/CommonIntake
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:stuart@townhill.net]
> 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:chris@fenetics.com]
> 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:stuart@townhill.net]
> > 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: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


RE: Intake From The Beginning?

Posted by Stuart Townhill <st...@townhill.net>.
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:chris@fenetics.com] 
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:stuart@townhill.net]
> 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: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


RE: Intake From The Beginning?

Posted by Chris K Chew <ch...@fenetics.com>.
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:stuart@townhill.net]
> 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: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org