[jala-dev] Re: Feedback to updated jala.Form

  • From: <robert.gaggl@xxxxxx>
  • To: <jala-dev@xxxxxxxxxxxxx>
  • Date: Wed, 2 May 2007 10:52:32 +0200

Hi Tobi,

thanks for your extensive review of jala.Form. I second most of it,
however i'd like to drop in some comments:

Reg. "components" vs. "elements": the reason for "components" instead of
"elements" is imo to avoid confusion, since a form component consists of
more than just the form element(s) (label, help text, error message
etc.). That's why i think that "component" is a better term, although it
might not be that intuitive.

Reg. instantiation: afais jala.Form doesn't depend on a HopObject
containing the data (although in most cases one will use a persistent
HopObject as basis), the data object can currently be any object, or
none (think of a simple login-form). That's why getting rid of
parseConfig and making both the form config and the data object required
would imo limit the usage of jala.Form. However i think the constructor
should accept the data object as second argument, so that calling
setDataObj() shouldn't be a necessary step. And maybe "parseConfig"
should be renamed to "createInstance", as that's what it does (not only
parses the form config, but also constructs a form instance based on
that). I agree with you that "class" in a form config should be renamed
to "type", accepting a string identifier instead of the constructor
function name.

Reg. getting rid of the "Component" part of the various constructors:
i'd vote for keeping it, as eg. "new TextareaComponent()" is imo much
clearer than "new Text()" or the like. And i'd prefer to keep
"TextareaComponent" instead of renaming it to "TextComponent", just
because the constructor name tells me what i'll get (i agree with you
that CheckboxComponent is a much better name than "FlagComponent").

I personally find your idea with require() very appealing. Instead of
using strings as identifiers (eg. "minlength") i think using constants
would be a nicer way, plus we could allow passing an error message as
optional third argument, eg.:

text.require(jala.Form.MINLENGTH, 2, "You must enter at least 2

In relation to: how about renaming checkSyntax() to checkRequirements()?

There's one thing that i find a bit odd in the current jala.Form: it
encloses all of its components in a fieldset that you can't get rid of.
Instead i would prefer it to provide a Fieldset(Component) constructor,
allowing to create multiple fieldsets in a form, each one containing
multiple components as children.

I second renaming Form.prototype.check() to validate(). However this
method should imho basically just loop over all components and call
their validate() method. So every component (including Fieldset) should
be somehow capable to validate itself.


> -----Original Message-----
> From: jala-dev-bounce@xxxxxxxxxxxxx 
> [mailto:jala-dev-bounce@xxxxxxxxxxxxx] On Behalf Of 
> tobias.schaefer@xxxxxx
> Sent: Tuesday, April 24, 2007 3:24 PM
> To: jala-dev@xxxxxxxxxxxxx
> Subject: [jala-dev] Feedback to updated jala.Form
> Hi Stefan, hi list
> I collected some first experiences with the updated jala.Form 
> module here:
> https://opensvn.csie.org/traccgi/jala/wiki/JalaModules/FormFeedback
> Would be happy to discuss it here on the list.
> Ciao,
> tobi

Other related posts: