You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Joel Trunick <Jo...@SmartPrice.com> on 2003/03/11 01:09:57 UTC

Error Handling

I have some fields that are related to the same element, for example, phone
number with area code, exchange, and last 4 digits separated. I'd like to
make label red for any error in the three boxes. What I have done so far is
to make the first field the "error field", if there is a problem with the
other two fields, I "tell the first one" that it is an error (getting the
label to turn red).

Admittedly, the way I am doing this could be kludge, but I don't know a
better way. 

Now, what if I have a list of phone numbers in a Foreach? How the heck can I
find the label to turn red?

ie:
  Phone number ([  ]) [  ]-[  ]
  Phone number ([  ]) [  ]-[  ]
  Phone number ([  ]) [  ]-[ X ]  <-- error here, how to make "Phone number"
red?
  Phone number ([  ]) [  ]-[  ]


Thanks for any input,
Joel Trunick

RE: Error Handling

Posted by "Howard M. Lewis Ship" <hl...@attbi.com>.
I don't have a solution to this case.  When doing a loop, the wrong label
gets highlighted.

The issue is that the FieldLabel keys its error status off the name proeprty
of the valid field.  That is not set to the right value until the ValidField
renders, which occurs after the FieldLabel renders.  This works for simpler,
non-looping, fields because the name property is set during the rewind phase
and is not reset.

I would suggest not using a FieldLabel component, use a home-brew component
that you can control more directly, and use just one for the bank of phone
numbers.

Getting two copmonents to coordinate when one does not enclose the other is
very difficult, even in Tapestry.  I've been thinking about switching from a
simple streaming metaphor (with buffering) when rendering to something more
like DOM or ECS, where there's a tree structure that can be updated in
arbitrary order.  If that was the case, the FieldLabel could "advertise"
itself so that later, when the ValidField renders, it can jump back and
modify the FieldLabel's output (writing the <span>  around the FieldLabel,
afthe.

--
Howard M. Lewis Ship
Creator, Tapestry: Java Web Components
http://jakarta.apache.org/proposals/tapestry



> -----Original Message-----
> From: Joel Trunick [mailto:Joel@SmartPrice.com] 
> Sent: Monday, March 10, 2003 7:10 PM
> To: 'Tapestry users'
> Subject: Error Handling
> 
> 
> 
> I have some fields that are related to the same element, for 
> example, phone number with area code, exchange, and last 4 
> digits separated. I'd like to make label red for any error in 
> the three boxes. What I have done so far is to make the first 
> field the "error field", if there is a problem with the other 
> two fields, I "tell the first one" that it is an error 
> (getting the label to turn red).
> 
> Admittedly, the way I am doing this could be kludge, but I 
> don't know a better way. 
> 
> Now, what if I have a list of phone numbers in a Foreach? How 
> the heck can I find the label to turn red?
> 
> ie:
>   Phone number ([  ]) [  ]-[  ]
>   Phone number ([  ]) [  ]-[  ]
>   Phone number ([  ]) [  ]-[ X ]  <-- error here, how to make 
> "Phone number" red?
>   Phone number ([  ]) [  ]-[  ]
> 
> 
> Thanks for any input,
> Joel Trunick
>