I was looking at the Form Validation sample today and I found that there was
a little more code in the xsp page then I would like.
I'm trying to find a way to get the if-else if statements out of the page
and put them into the action instead. Here's what I came up with. I tried
to put the needed error message into the descriptor file.
I haven't tried writing the action yet, I thought I'd see what people
thought of this way of doing it. I've included code below. Is it possible
this way? Is it a good way of doing it?
Any comments greatly appreciated,
Paul
Here's what my descriptor file would look like:
<?xml version="1.0"?>
<root>
<parameter name="persons" type="long" default="4" nullable="yes">
<constraint name="min" value="2">
<err-msg>The smallest available car seats 2.</err-msg>
</constraint>
<constraint name="max" value="7">
<err-msg>The largest available car seats 7.</err-msg>
</constraint>
</parameter>
<parameter name="deposit" type="double">
<constraint name="min" value="10.0">
<err-msg>The deposit has to be at least EUR 10.00.</err-msg>
</constraint>
<constraint name="max" value="999.99">
<err-msg>The deposit has to be at most EUR 999.99.</err-msg>
</constraint>
</parameter>
<constraint-set name="car-reservation">
<validate name="persons"/>
<validate name="deposit"/>
</constraint-set>
</root>
Here's a snippet from the xsp file:
<xsp:page>
...
How many persons should the car seat?
<input type="text" name="persons" size="2">
<xsp:attribute name="value"><xsp-request:get-parameter name="persons"
default=""/></xsp:attribute>
</input>
<error>
<xsp-request:get-parameter name="persons-err"/>
</error>
...
</xsp:page>
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>