You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Dan Marcus <da...@iacmail.wustl.edu> on 2003/04/09 21:00:50 UTC

intake fields dependent on other fields

Hi-

 

A number of fields in my form are required IF a checkbox has been
selected.  Is there a way to inform Intake that the field is only
required if the other field has a certain value?  More generally, is
there a way to specify rules for one field based on the values of other
fields?

 

Also, I haven't been able to find a document describing the built-in
rules in Intake.  Does such a document exist?  The Howto and Intake
Service documents seem to be lacking

 

Thanks in advance,

Dan Marcus

 


RE: intake fields dependent on other fields

Posted by Thomas Vandahl <th...@hm-informatik.de>.
> -----Original Message-----
> From: Quinton McCombs [mailto:qmccombs@nequalsone.com]
> Sent: Wednesday, April 09, 2003 9:43 PM
> To: 'Turbine Users List'
> Subject: RE: intake fields dependent on other fields
>
>
> > -----Original Message-----
> > From: Dan Marcus [mailto:dan@iacmail.wustl.edu]
> > Sent: Wednesday, April 09, 2003 2:01 PM
> > To: turbine-user@jakarta.apache.org
> > Subject: intake fields dependent on other fields
> >
> >
> > Hi-
> >
> >
> >
> > A number of fields in my form are required IF a checkbox has
> > been selected.  Is there a way to inform Intake that the
> > field is only required if the other field has a certain
> > value?  More generally, is there a way to specify rules for
> > one field based on the values of other fields?
> >
>
> Intake does not support validation rules that span multiple
> fields.  The
> best way to accomplish this is to perform the check inside
> your action.

We use the Field.setMessage() method inside the action to provide a
special error message for that case. This sets the valid_flag of the
corresponding field to false, so that the message will be displayed.
This way you can even handle value dependencies (e.g. start <= end).

Bye, Thomas.


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


RE: intake fields dependent on other fields

Posted by Quinton McCombs <qm...@nequalsone.com>.
> -----Original Message-----
> From: Dan Marcus [mailto:dan@iacmail.wustl.edu] 
> Sent: Wednesday, April 09, 2003 2:01 PM
> To: turbine-user@jakarta.apache.org
> Subject: intake fields dependent on other fields
> 
> 
> Hi-
> 
>  
> 
> A number of fields in my form are required IF a checkbox has 
> been selected.  Is there a way to inform Intake that the 
> field is only required if the other field has a certain 
> value?  More generally, is there a way to specify rules for 
> one field based on the values of other fields?
> 

Intake does not support validation rules that span multiple fields.  The
best way to accomplish this is to perform the check inside your action.
In this case, the rules that vary according to the value of another
field would not be present in  your intake.xml file.

> 
> Also, I haven't been able to find a document describing the 
> built-in rules in Intake.  Does such a document exist?  The 
> Howto and Intake Service documents seem to be lacking
> 
>  
> 
> Thanks in advance,
> 
> Dan Marcus
> 
>  
> 
> 


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


Re: old question about retrieving PrimaryKey from new object

Posted by Michael Mainguy <ma...@mich.com>.
I'm assuming you're autoincrement field is an integer, have you tried 
branchAddress.getID() {or whatever the field name is?)
That works for me...
I also noticed there is a setBranchAddress(BranchAddress a) on my Base
Objects, perhaps that would work too (I haven't tried it though).


On Wed, 2003-04-16 at 10:35, Jeffery Painter wrote: 
> 
> I know I've read the posts many many times about returning the primary key 
> of a newly formed base object, and I thought I had figured it all out.
> 
> However, I'm running into a wall with an action trying to do a complex 
> insert of multiple objects from one form.
> 
> I have the following code but it is returning null for the primary keys
> 
> database is set to use idbroker and keys are autoincrement, mysql database
> 
> my action doInsert method
> 
> 	Date now = new Date();
>         Participant entry = new Participant();
>         Address branchAddress = new Address();
>         Address mailingAddress = new Address();
> 
>         data.getParameters().setProperties(entry);
>         entry.setDateCreated(now);
>         entry.setDateModified(now);
> 
>         branchAddress.setNew(true);
>         branchAddress.save();
> 
>         mailingAddress.setNew(true);
>         mailingAddress.save();
> 
>         entry.setBranchAddressId( branchAddress.getPrimaryKey() );
>         entry.setMailingAddressId( mailingAddress.getPrimaryKey() );
> 
> 	entry.setNew(true);
>         entry.save();
> 
> my participant object has the following base methods generated from torque
> 
>  public void setBranchAddressId(NumberKey v )
>  public void setBranchAddressId(String v )
>  public void setAddressRelatedByBranchAddressId(Address v)
> 
> I've tried using all three methods, however, they all end up being null
> 
> Am I missing a step here? shouldn't the primary key be available after the 
> save method or is there something else I need to do.
> 
> 
> Thanks,
> 
> Jeff Painter
> painter@kiasoft.com
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> 
-- 
Michael Mainguy
(248)935-8507
mainguym@mich.com


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


Re: old question about retrieving PrimaryKey from new object [SOLUTION]

Posted by Michael Mainguy <ma...@mich.com>.
That's pretty funny, because I've been creating tables left and right
and I have constantly remind myself to make sure the id_table values get
generated.  The way it's set up in the init target something gets
screwed up and none of my idtable rows get properly generated.  I've
been manually running the generated sql script, I didn't realize there
was an ant target that would do it... Good information!


On Wed, 2003-04-16 at 13:33, Jeffery Painter wrote:
> alright... I got so used to not running ant init I had forgotten to hit 
> my id-table... so it looks like when developing using the following 
> targets
> 
>  ant project-om 
>  ant project-sql
> 
> you should also hit the target
> 
>  ant project-id-table-init-sql
> 
> to update the idbroker entries in id_table if you create
> new tables in your project.
> 
> arg... I should have looked for this sooner ;)
> 
> 
> Thanks for the help!
> 
> Jeff Painter
> painter@kiasoft.com
> 
> 
> 
> On Wed, 16 Apr 2003, Jeffery Painter wrote:
> 
> > 
> > hmm... I added this additional table later in my project than the original 
> > elements and it looks like there is no entry in ID_TABLE for the ADDRESS 
> > table.
> > 
> > maybe I need to regenerate my sql targets :)
> > 
> > thanks for the pointer... I'll post the exact solution when I get it.
> > 
> > 
> > Jeff Painter
> > painter@kiasoft.com
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> 
-- 
Michael Mainguy
(248)935-8507
mainguym@mich.com



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


Re: old question about retrieving PrimaryKey from new object [SOLUTION]

Posted by Jeffery Painter <pa...@kiasoft.com>.
alright... I got so used to not running ant init I had forgotten to hit 
my id-table... so it looks like when developing using the following 
targets

 ant project-om 
 ant project-sql

you should also hit the target

 ant project-id-table-init-sql

to update the idbroker entries in id_table if you create
new tables in your project.

arg... I should have looked for this sooner ;)


Thanks for the help!

Jeff Painter
painter@kiasoft.com



On Wed, 16 Apr 2003, Jeffery Painter wrote:

> 
> hmm... I added this additional table later in my project than the original 
> elements and it looks like there is no entry in ID_TABLE for the ADDRESS 
> table.
> 
> maybe I need to regenerate my sql targets :)
> 
> thanks for the pointer... I'll post the exact solution when I get it.
> 
> 
> Jeff Painter
> painter@kiasoft.com
> 


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


Re: old question about retrieving PrimaryKey from new object

Posted by Jeffery Painter <pa...@kiasoft.com>.
hmm... I added this additional table later in my project than the original 
elements and it looks like there is no entry in ID_TABLE for the ADDRESS 
table.

maybe I need to regenerate my sql targets :)

thanks for the pointer... I'll post the exact solution when I get it.


Jeff Painter
painter@kiasoft.com



On Wed, 16 Apr 2003, Eric Emminger wrote:

> Jeffery
> 
> > I know I've read the posts many many times about returning the primary key 
> > of a newly formed base object, and I thought I had figured it all out.
> > 
> > However, I'm running into a wall with an action trying to do a complex 
> > insert of multiple objects from one form.
> > 
> > I have the following code but it is returning null for the primary keys
> > 
> > database is set to use idbroker and keys are autoincrement, mysql database
> 
> Are you sure that Address is using autoincrement, rather than inheriting 
> idbroker from the database element?
> 
> Eric
> 
> 
> ---------------------------------------------------------------------
> 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: old question about retrieving PrimaryKey from new object

Posted by Eric Emminger <er...@ericemminger.com>.
Jeffery

> I know I've read the posts many many times about returning the primary key 
> of a newly formed base object, and I thought I had figured it all out.
> 
> However, I'm running into a wall with an action trying to do a complex 
> insert of multiple objects from one form.
> 
> I have the following code but it is returning null for the primary keys
> 
> database is set to use idbroker and keys are autoincrement, mysql database

Are you sure that Address is using autoincrement, rather than inheriting 
idbroker from the database element?

Eric


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


old question about retrieving PrimaryKey from new object

Posted by Jeffery Painter <pa...@kiasoft.com>.
I know I've read the posts many many times about returning the primary key 
of a newly formed base object, and I thought I had figured it all out.

However, I'm running into a wall with an action trying to do a complex 
insert of multiple objects from one form.

I have the following code but it is returning null for the primary keys

database is set to use idbroker and keys are autoincrement, mysql database

my action doInsert method

	Date now = new Date();
        Participant entry = new Participant();
        Address branchAddress = new Address();
        Address mailingAddress = new Address();

        data.getParameters().setProperties(entry);
        entry.setDateCreated(now);
        entry.setDateModified(now);

        branchAddress.setNew(true);
        branchAddress.save();

        mailingAddress.setNew(true);
        mailingAddress.save();

        entry.setBranchAddressId( branchAddress.getPrimaryKey() );
        entry.setMailingAddressId( mailingAddress.getPrimaryKey() );

	entry.setNew(true);
        entry.save();

my participant object has the following base methods generated from torque

 public void setBranchAddressId(NumberKey v )
 public void setBranchAddressId(String v )
 public void setAddressRelatedByBranchAddressId(Address v)

I've tried using all three methods, however, they all end up being null

Am I missing a step here? shouldn't the primary key be available after the 
save method or is there something else I need to do.


Thanks,

Jeff Painter
painter@kiasoft.com


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


RE: intake fields dependent on other fields

Posted by Chris K Chew <ch...@fenetics.com>.
Hi Dan,

> From: Dan Marcus
>
> A number of fields in my form are required IF a checkbox has been
> selected.  Is there a way to inform Intake that the field is only
> required if the other field has a certain value?  More generally, is
> there a way to specify rules for one field based on the values of other
> fields?

The turbine-user list archives are going to be your best resource for
intake, and will answer just about any question you have.  It especially
will provide some approaches for this issue.

> Also, I haven't been able to find a document describing the built-in
> rules in Intake.  Does such a document exist?  The Howto and Intake
> Service documents seem to be lacking

The intake howto in the unrealeased 2.3 development module is *slightly*
improved over the 2.2 howto, you can find it at
http://jakarta.apache.org/turbine/turbine-2.3/howto/intake-howto.html.  The
rule section of the document describes all the built-in rules available.  It
is easy to write your own validators if need be.

Depending on your java expertise and project timeline, you might consider
looking into the revamped intake in 2.3.

Good luck,

Chris


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