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]