You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Geoffrey Wiseman <ge...@gmail.com> on 2009/04/09 21:28:54 UTC

BeanEditForm / BeanEditor and Validation Events

Whenever I try and capture validation events for a particular component in
beaneditor / beaneditform, I fail.  I can catch the whole form, but not the
individual components, anyone know why?

I've got a form with a beaneditor in it, and I've added a field of my own,
'sponsor', but it also contains a bean with a number of fields, including
"backgroundUrl".  I couldn't find many specifics about the component ids
used by beaneditor fields, but the HTML implies that backgroundUrl gets a
/client id/ of 'background url' at least.  I made a simple event handler
method that always throws a ValidationException just for testing.

The following methods trigger a validation error:

   - @OnEvent("validate") validate(EventContext)
   - @OnEvent(value="validate",component="sponsor") validate(EventContext)
   - onValidateForm(EventContext)
   - onValidateFromSponsor(EventContext)

The following don't:

   - @OnEvent(value="validate",component="backgroundUrl")
   validate(EventContext)
   - onValidateFromBackgroundUrl(EventContext)
   - onValidateFromBackgroundurl(EventContext)

In searching the mailing list, I'm finding other people having trouble
validating, and other people who don't know what component id they're
getting in a beaneditform, but no-one with answers.  ;)

So ... what am I missing?  I'm sure it's simple, but I'm struggling with it
nonetheless.

  - Geoffrey
-- 
Geoffrey Wiseman
http://www.geoffreywiseman.ca/

Re: BeanEditForm / BeanEditor and Validation Events

Posted by Geoffrey Wiseman <ge...@gmail.com>.
On Thu, Apr 9, 2009 at 8:11 PM, Howard Lewis Ship <hl...@gmail.com> wrote:

> The events triggered by the default components used by the BeanEditor
> can't be caught: those components are rendered from other pages, they
> aren't part of your page hierarchy, so component events bubble up on
> the other page hierarchy.
>
> In addition, the client element ids are documented, but the component
> ids are part of the implementation of BeanEditor or, more
> specifically, the contributions to the BeanBlockSource service.
>
> In other words, the TextField component that edits the backgroundURL
> field is component  core/PropertyEditBlocks:textField, so any events
> would have to be caught by PropertyEditBlocks, not your class.
> Further, the exact same component, configured differently each time,
> will be used to edit every property in your for that's data type is
> "text".
>

Hmm.  I think I'd need to dig farther into Tapestry and the core components
to really understand that completely.  I hear the words, but I'm not
attaching meaning to all of them yet.  The idea that components on my form
are being rendered from other pages doesn't mesh with my undoubtedly limited
understanding of Tapestry.

Trying my best to gloss over the parts I don't understand and extrapolate
from the parts that I think I might ... I believe you're saying that I can't
add totally custom validation via event handling to fields that are
generated by BeanEditor or BeanEditForm, and that I can either live with
form-level validation (e.g. onValidateForm), or, alternately, use my own
full form rather than BeanEdit*?

  - Geoffrey
-- 
Geoffrey Wiseman
http://www.geoffreywiseman.ca/

Re: BeanEditForm / BeanEditor and Validation Events

Posted by Howard Lewis Ship <hl...@gmail.com>.
The events triggered by the default components used by the BeanEditor
can't be caught: those components are rendered from other pages, they
aren't part of your page hierarchy, so component events bubble up on
the other page hierarchy.

In addition, the client element ids are documented, but the component
ids are part of the implementation of BeanEditor or, more
specifically, the contributions to the BeanBlockSource service.

In other words, the TextField component that edits the backgroundURL
field is component  core/PropertyEditBlocks:textField, so any events
would have to be caught by PropertyEditBlocks, not your class.
Further, the exact same component, configured differently each time,
will be used to edit every property in your for that's data type is
"text".

On Thu, Apr 9, 2009 at 12:28 PM, Geoffrey Wiseman
<ge...@gmail.com> wrote:
> Whenever I try and capture validation events for a particular component in
> beaneditor / beaneditform, I fail.  I can catch the whole form, but not the
> individual components, anyone know why?
>
> I've got a form with a beaneditor in it, and I've added a field of my own,
> 'sponsor', but it also contains a bean with a number of fields, including
> "backgroundUrl".  I couldn't find many specifics about the component ids
> used by beaneditor fields, but the HTML implies that backgroundUrl gets a
> /client id/ of 'background url' at least.  I made a simple event handler
> method that always throws a ValidationException just for testing.
>
> The following methods trigger a validation error:
>
>   - @OnEvent("validate") validate(EventContext)
>   - @OnEvent(value="validate",component="sponsor") validate(EventContext)
>   - onValidateForm(EventContext)
>   - onValidateFromSponsor(EventContext)
>
> The following don't:
>
>   - @OnEvent(value="validate",component="backgroundUrl")
>   validate(EventContext)
>   - onValidateFromBackgroundUrl(EventContext)
>   - onValidateFromBackgroundurl(EventContext)
>
> In searching the mailing list, I'm finding other people having trouble
> validating, and other people who don't know what component id they're
> getting in a beaneditform, but no-one with answers.  ;)
>
> So ... what am I missing?  I'm sure it's simple, but I'm struggling with it
> nonetheless.
>
>  - Geoffrey
> --
> Geoffrey Wiseman
> http://www.geoffreywiseman.ca/
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

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