cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Pattison" <>
Subject Form validation
Date Wed, 15 May 2002 00:59:15 GMT
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,


Here's what my descriptor file would look like:

<?xml version="1.0"?>
  <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 name="max" value="7">
      <err-msg>The largest available car seats 7.</err-msg>

  <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 name="max" value="999.99">
      <err-msg>The deposit has to be at most EUR 999.99.</err-msg>

  <constraint-set name="car-reservation">
    <validate name="persons"/>
    <validate name="deposit"/>

Here's a snippet from the xsp file:

  How many persons should the car seat?
  <input type="text" name="persons" size="2">
    <xsp:attribute name="value"><xsp-request:get-parameter name="persons"
    <xsp-request:get-parameter name="persons-err"/>

Please check that your question has not already been answered in the
FAQ before posting. <>

To unsubscribe, e-mail: <>
For additional commands, e-mail: <>

View raw message