----- Original Message -----
From: "John McNally" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 09, 2001 8:54 AM
Subject: Re: another intake question


>
>
> Warner Onstine wrote:
> >
> > Hi all,
> > Just wondering if there is a better way to do this:
> >
> > Currently I have one form and whether an id is passed or not it either
> > reflects a record in the database or a brand new record. There are also
two
> > possible button presses doUpdate and doInsert - only one shows depending
on
> > the id value.
> >
> > What currently happens is that I grab the group from the intake tool
via:
> > get("Project", IntakeTool.DEFAULT_KEY, false) for the insert action, and
> >
>
> This looks fine.
>
>
> > get("Project", queryKey, false) for the update action
> >
> > Now queryKey I have to pull manually from the data submitted from the
form
> > via
> > String queryKey = data.getParameters().get("proj"); - where proj is the
> > Intake value that is pre-defined on ViewProject.vm page.
> >
> > So, is there a better way to do this?
>
> Since you are updating, I assume there is a torque object that is being
> updated.  In this case I would
>
> in template
> #set ($project = torque object)
> #set ($group = $intake.Project.mapTo($project))
>
> then in the action you can do
>
> Project project = torque object
> Group group = intake.get("Project", project.getQueryKey(), false);
> ... validate etc ...
> group.setProperties(project);
> project.save();

I tried this initially, but project.queryKey() wasn't returning anything
because the project object hasn't been initialized. The only way I can see
to initialize it would be to grab a variable from the form which was
submitted.

Unless I'm missing something.

-warner

> john mcnally
>
> ---------------------------------------------------------------------
> 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]

Reply via email to