You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Cory Watson <jh...@gmail.com> on 2004/12/10 22:41:42 UTC

Corner Cases?

I am implementing a project at the office that is a Proof-Of-Concept
for an eventual rewrite of a large, important app.  My coworker and I
really liked the ideas Tapestry represents, and we were very happy to
make the jump from our JSTL based early work to Tapestry.

We met great success after getting around some of the 'unlearning'
needed to get your head wrapped around how easy it is to throw data
between pages. But after these initial successes I am repeatedly
running into smaller, nastier problems.

For example, today I wanted to implement some validation into a form
that took information from a 'customer' for an order.  This involved
billing, shipping, and payment information.

The first problem was that I only wanted the Shipping information to
be required if the user did NOT activate the 'Shipping same as
Billing' checkbox.  I initially used code like:

IFormComponent comp = (IFormComponent) getComponent("theField");
delegate.setFormComponent(comp);
delegate.record("You must enter a value for " + comp.getDisplayName(),
  ValidationConstraint.REQUIRED);
return;

Then I discovered problems:

1) getDisplayName() seems to return null for pretty much everything
except ValidField
2) record()ing the error didn't do anything to the form, like start
the field.  I understood it wouldn't do anything to the field's label,
since Tapestry had no way of knowing what text was it's label

I eventually got it work by making it a ValidField and setting it's
validator to a StringValidator with required set to false.  This
apparently gave Tapestry everything it needed to do what I wanted,
which was let me check the status of the checkbox and then check the
values of the form and mark the shipping info as missing.

My next problem was that there is no way to make a PropertySelection
'required'.  We wrote a StateSelectionModel class, and the first entry
is always an empty string, so the user _must_ select a State.  This
would seem to be a common need in any web application.  I searched the
net and the book for some type of answer, and didn't find any.  What
is the best way to approach this?

I admit to not having read the whole book yet (I am trying to finish
up Neal Stephenson's latest first).  I'm 50 or pages into it, and I've
skipped around when I'm trying to get things done. So perhaps my
ignorance of Tapestry's internals is hindering my ability to easily
convert an ugly old-style form into a beautiful collection of reusable
components.

I keep feeling that any day now I will have an ephiphany, rather than
repeatedly running into things that I have trouble implementing.

-- 
Cory 'G' Watson
http://www.onemogin.com

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org