Hi Anthony,

My wicket project http://code.google.com/p/visural-wicket has a JSR303 based
form which might be of use for this.

Take a look at http://visural-wicket-examples.appspot.com/app/jsr303

Essentially you can annotate your model bean properties with JSR303
annotations e.g. @Size(max=200) and assuming your form uses a property
model, it will pick up the appropriate validations from the model bean that
the property model is bound to.

I think this should solve your problem?


On Thu, Sep 16, 2010 at 10:54 AM, Anthony DePalma <[email protected]>wrote:

> I have a reusable form panel for some of my applications, but many of
> the text fields and text areas have different max lengths depending on
> the application using them. So I was thinking of the best ways to pass
> these lengths and came up with a bunch of ideas.
>
> The obvious way is to pass the limits in the constructor, but having a
> constructor like
> Panel(String id, IModel model, int nameLength, intContentLength,
> ....many more) is error prone and ugly with alot of arguments.
>
> Then I looked at injecting integers via spring, which was clean but
> its not obvious they are required and the application fails to load
> the panel if the beans werent defined.
>
> Another option is having abstract or protected getters that can be
> overridden, which I am leaning towards:
>
> protected int getNameMaxLength() {
>  return someDefault;
> }
>
> protected abstract int getContentMaxLength();
>
> And finally I could create some configuration object and pass that
> along to the constructor, but that means a new object and maybe
> overkill since it wouldn't work well with panels with only one or two
> length parameters.
>
> Which way would you choose?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>


-- 
Richard Nichols
http://www.richardnichols.net/ :: http://onmydoorstep.com.au/

Reply via email to