You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jo...@apache.org on 2001/08/24 21:10:18 UTC
cvs commit: jakarta-turbine-2/xdocs/services intake-service.xml
jon 01/08/24 12:10:18
Modified: xdocs/services intake-service.xml
Log:
adding more documentation based on conversations on the list
Revision Changes Path
1.2 +85 -0 jakarta-turbine-2/xdocs/services/intake-service.xml
Index: intake-service.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/xdocs/services/intake-service.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- intake-service.xml 2001/08/16 05:10:44 1.1
+++ intake-service.xml 2001/08/24 19:10:18 1.2
@@ -764,6 +764,91 @@
to an associated bean.
</p>
+
+<source>
+Dan Diephouse wrote:
+>
+> I want to validate a form that updates my business object properties
+> with intake. I got the latest cvs of turbine-2 repository and built a
+> new distribution of the turbine jar. I can easily use intake to add
+> validate items I add to my databse, but I'm running in to a snag when
+> trying to modify them. I've defined by business object in the intake
+> validation file. I use the following code to update my item:
+>
+> IntakeTool intake = (IntakeTool) context.get("intake");
+>
+> ParameterParser pp = data.getParameters();
+>
+> if ( intake.isAllValid() ) {
+> Job j = new Job();
+> j.setNew(false);
+> group.setProperties(j);
+>
+> JobPeer.doUpdate(j);
+>
+> Error--> data.getParameters().add("jobid", j.getJobId().toString());
+> data.setMessage("Job updated.");
+> } else {
+> data.setMessage("There was an error updating the job.
+> Check below for further information.");
+> }
+>
+> It runs OK, until I try and retrieve the JobId. I get a Null Pointer
+> exception. Is there something I'm doing wrong here? Or is this a bug?
+> Do I need to specify that this is not a new object to intake? I would
+> include my template, but there are lots of fields so its really long.
+> But here's a little summary with most fields gone:
+>
+> #set ( $job = $basecamp.getJob() ) - This gets a job from a pull tool
+> #set ( $jobGroup = $intake.Job.mapTo($job) )
+> <input type=hidden name="$jobGroup.JobId.Key"
+> value="$jobGroup.JobId.Value">
+>
+> #if ( !$jobGroup.Title.isValid() )
+> $jobGroup.Title.Message<br>
+> #end
+> <input type=text name="$jobGroup.Title.Key"
+> value="$!jobGroup.Title.Value" size="50">
+> .
+> .
+> .
+> .
+> $intake.declareGroups()
+>
+> Thanks,
+>
+> Dan Diephouse
+
+This is not how i usually do things, but I guess it could work. One
+thing that is wrong is that you are using mapTo(job) in the template and
+then in the action you are using IntakeTool.DEFAULT_KEY. Unless
+job.getQueryKey() returns "_0", this combination is not going to work.
+Print out data.getParameters().toString() in the action to see what the
+parameters look like.
+
+Here is what I consider a normal course of events:
+
+1. In the template:
+
+$job = $foo.Job
+#set ( $jobGroup = $intake.Job.mapTo($job) )
+
+(This job is can be a new Job or one that is already saved.)
+
+2. In the action:
+
+// get the same (not necessarilary the same java Object, but has the
+exact same attribute values) job
+Job job = foo.getJob()
+Group group = intake.get("Job", job.getQueryKey());
+group.setProperties(job);
+
+It appears as though you are trying to map the parameters given for one
+job to another job.
+
+john mcnally
+</source>
+
</section>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org