Hi!

I am trying to move the validation logic definition from the tml back to the 
"application source code", because my Hibernate domain model drives the  
required and length constrains anyway. 
So I wonder why all checks have to be declared by "t:validation" on the "gui" 
side redundently. The basic idea is to have a ModelValidator which implements 
the Tapestry Validator interface and assembles other Validator based on the 
model, more precise the column annotation of the model.

So I wrote the validator and created an instance by my AppModule wihthin a 
contribute method. Worked fine.

Inside the tml the following code snipped binds the textfield and the new 
validator:

<input type="text" t:id="userAddressId" 
t:validate="modelValidation=Address.userId"/>

which means: please take all validations from column "userId" of bean 
"Address". In my validation class I tried to reuse all existing Tapestry 
validators by using the "formSupport".

public class ModelValidator ...
{
    ...

    public void render(final Field field, final String constraintValue, final 
MessageFormatter formatter,
                       final MarkupWriter writer, final FormSupport formSupport)
    {
       // hardcoded for testing. 
       if (constraintValue.equals("Address.userId")) {
          formSupport.addValidation(field, "maxLength", "my maxLength message 
to build", new Long(10));
          formSupport.addValidation(field, "required", "my required message to 
build", null);
       }
    }

    ....
} 

Everything works but then I get an error message within the browser complaining 
"Function Tapestry.Validator.maxLength() does not exist for Field 
'userAddressId'. Well, unfortunately that's right :-(
Which further steps are required to create the missing java script code which I 
guess is created by Tapestry when parsing the t:validation entry  in the tml? 
Seems Tapestry does a lot of magic behind the scenes and I really do not know 
where to start.. 

But: In case there is another validation solution to keep the rules inside the 
application and not the gui I am also interested in.

Thanks in advance

Jens

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to