Thanks for the reply John - it helped a lot. I still have one outstanding
problem and a few other questions if I can trouble you to read the
comments I have added below.
> The minLength rule was broken, it is fixed in the HEAD.
> The required rule should work. I would concentrate efforts here, though
> I do not have any specific advise on why it is broken for you.
>
> The required-message rule needs some clarification in the docs, but it
> only provides a way to keep the messages in a central location. It does
> not force the field to be required. It is useful if the field is not
> always required, so in an Action you would have
>
> field.setRequired(conditional)
> if (intake.isAllValid())
> ...
>
>
> and if the conditional=true and the field did not have a value and you
> have the template set up to show an error message
>
> <font color=red>$field.Message</font>
>
> would show the message specified in <required-message>
>
> If the field is always going to be required you are better off using
> <rule name=required value=true>This field is required</rule>
> style as you do not need to include the additional code in Action(s).
Thanks for this info - very helpful.
<off-topic>
I have seen "HEAD" mentioned a few times over the last couple
of days. I've looked through the mail archive but I can't find a
brief explanation of what people mean when they talk about
it. Is this the top of the CVS tree that will form the basis of
some future version of torque? It's talked about as if it
pertains to some specific set of features. Would you mind
providing a small explanation for a newbee like me (or
point me to where I can find this).
</off-topic>
> > 3. An action that retrieves a database record into the context
> > as "entry" (Login.java, modified slightly to use class Subject
> > rather than Rdf - for all intents and purposes these are exactly
> > the same)
>From what you are saying, the crux of my problem is that
my mappings are out of wack.
>From your previous response I think I grasp things a little
better, but not quite as far as I need to make it work :-)
So, Login.java retrieves the data to populate a Subject
object and places this in the Velocity context thus:
Subject subject = (Subject) SubjectPeer.doSelect(criteria).elementAt(0);
context.put("entry", subject);
> >
> > 4. A screen template that includes:
> >
In my screen template I need to map from $entry to
intake thus:
#set ( $group = $intake.Subject.mapTo($entry) )
This maps the values from $entry to intake with the key
set to the value returned by $entry.getQueryKey() (at
least this is what it appears to be doing). $entry and the
subject group in intake both include a SubjectId, as
does the form (I have included these myself). It is also
included in the form a second time as "subject" (the key
of the group) by virtue of $intake.declareGroups() at
the bottom of the form.
In theory I can use the Default key thus:
#set ( $group = $intake.Subject.Default )
I would do this when there was no entry to begin with
and I just wanted to validate a form against an intake group.
Is this correct?
Incidentally, how does the mapToObject attribute of <group>
in the intake xml file relate to this? The documentation seems
to say that if I omit this attribute then intake can retrieve the
values directly. This sounds like a desirable thing to be able
to control, but I don't quite get it.
> > 5. An action SaveForm.java (a variation of SQL.java)
> > that includes (excuse my use of the error log, I don't
> > seem to be able to get debug logging to work):
<off-topic>
Any idea why:
org.apache.turbine.util.Log.debug("text to go to the debug log");
doesn't work out of the box? Do I have to change something in
TR.properties to get the debug messages to be produced?
</off-topic>
> I am a bit confused by your use of the Default_Key. It is also showing
> up in your html shown at the end, but I see no mention of it in your
> sample template above. I would use
>
> group = intake.get("Subject", entry.getQueryKey());
>
> where entry would be the same object (or representing the same object,
> as in having the same PrimaryKey) You appear to be using a new Subject
> even to represent an object that is already saved in the database. I
> don't recommend this, but it could be made to work.
>
> The DEFAULT_KEY is meant to be used in cases where the fields do not map
> to any object and instead of making up a key, a default one is
> provided. There is nothing special about it as a key.
That makes sense. I now have:
Group group = intake.get("Subject", data.getParameters().getString("subject"));
I am assuming that the "subject" (really the group key) field is added
to the form to allow for this. As I am now using the correct key to
retrieve the intake group, isValidAll() on the group now works.
I can also go:
Subject entry = new Subject();
group.setProperties(entry);
to give me a Subject object that I can then update in the database:
entry.setModified(true);
entry.setNew(false);
entry.save();
> > 6. In case it is relevant, here is the generated html
The bottom of the generated form is now:
<input type="hidden" name="subject2s" value="2"/>
<input type="submit" name="eventSubmit_doInsert" value="Insert"/>
<input type="submit" name="eventSubmit_doUpdate" value="Update"/>
<input type="submit" name="eventSubmit_doDelete" value="Delete"/>
</div>
<input type="hidden" name="intake-grp" value="subject"></input>
<input type="hidden" name="subject" value="2"></input>
</form>
I include this to show the subject2s field (which is the
SubjectId I included in the intake xml file and the form
as well as the subject field which is the one generated by
$intake.declareGroups() .
My last outstanding problem is that when a validation
error is picked up by intake and the form is redisplayed,
$entry is no longer in the context and thus the form is
displayed with no fields filled in. I'm sure I had this
working at one point, but I can't seem to repeat it.
Can you spot my hopefully obvious mistake?
>
> john mcnally
>
Thanks again,
Scott
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]