You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Chris Lewis <ch...@bellsouth.net> on 2008/08/18 00:13:58 UTC

T5: Form Field from an embedded component

Hello list,

I have a page that has a form component, and in the form is another
component "contactinfo." This component is basically a custom editor for
a contact bean. In the page I must do some custom validation on the
server side, and in at least one instance I want to record an error on a
field within the contactinfo. However I run into the issue that I can't
use @Component in my page class, because the Field (component) is within
an embedded component. How can I get at the Field? ComponentResources
has getEmbeddedComponent, it returns type Component. Any ideas?

Thanks in advance,
Chris Lewis

-- 
http://thegodcode.net


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


Re: T5: Form Field from an embedded component

Posted by "Filip S. Adamsen" <fs...@fsadev.com>.
Hi,

Glad it helped. :)

Another possible way to do this would be triggering a custom event 
through ComponentResources#triggerEvent in ContactInfo and pass along 
whatever you need. Your page could then handle this event and do 
whatever it needs to do. It's a little cleaner API-wise, and not a lot 
of work, really.

-Filip

On 2008-08-19 05:17, Chris Lewis wrote:
> Filip,
> 
> I had actually thought about that, but the explicit cast to Field
> prompted me ask the list. I hadn't tried that method until you mentioned
> it, and it does indeed work. If anyone can suggest a cleaner method I'd
> love to hear it, but for now this will do. Thanks again Filip!
> 
> chris
> 
> Filip S. Adamsen wrote:
>> Hi Chris,
>>
>> Get "contactinfo" through getEmbeddedComponent, get its
>> ComponentResources, and finally get the component you need through
>> getEmbeddedComponent and cast it to Field.
>>
>> That's the quick and dirty way, anyhow.
>>
>> -Filip
>>
>> On 2008-08-18 00:13, Chris Lewis wrote:
>>> Hello list,
>>>
>>> I have a page that has a form component, and in the form is another
>>> component "contactinfo." This component is basically a custom editor for
>>> a contact bean. In the page I must do some custom validation on the
>>> server side, and in at least one instance I want to record an error on a
>>> field within the contactinfo. However I run into the issue that I can't
>>> use @Component in my page class, because the Field (component) is within
>>> an embedded component. How can I get at the Field? ComponentResources
>>> has getEmbeddedComponent, it returns type Component. Any ideas?
>>>
>>> Thanks in advance,
>>> Chris Lewis
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 

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


Re: T5: Form Field from an embedded component

Posted by Chris Lewis <ch...@bellsouth.net>.
Filip,

I had actually thought about that, but the explicit cast to Field
prompted me ask the list. I hadn't tried that method until you mentioned
it, and it does indeed work. If anyone can suggest a cleaner method I'd
love to hear it, but for now this will do. Thanks again Filip!

chris

Filip S. Adamsen wrote:
> Hi Chris,
>
> Get "contactinfo" through getEmbeddedComponent, get its
> ComponentResources, and finally get the component you need through
> getEmbeddedComponent and cast it to Field.
>
> That's the quick and dirty way, anyhow.
>
> -Filip
>
> On 2008-08-18 00:13, Chris Lewis wrote:
>> Hello list,
>>
>> I have a page that has a form component, and in the form is another
>> component "contactinfo." This component is basically a custom editor for
>> a contact bean. In the page I must do some custom validation on the
>> server side, and in at least one instance I want to record an error on a
>> field within the contactinfo. However I run into the issue that I can't
>> use @Component in my page class, because the Field (component) is within
>> an embedded component. How can I get at the Field? ComponentResources
>> has getEmbeddedComponent, it returns type Component. Any ideas?
>>
>> Thanks in advance,
>> Chris Lewis
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

-- 
http://thegodcode.net


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


Re: T5: Form Field from an embedded component

Posted by "Filip S. Adamsen" <fs...@fsadev.com>.
Hi Chris,

Get "contactinfo" through getEmbeddedComponent, get its 
ComponentResources, and finally get the component you need through 
getEmbeddedComponent and cast it to Field.

That's the quick and dirty way, anyhow.

-Filip

On 2008-08-18 00:13, Chris Lewis wrote:
> Hello list,
> 
> I have a page that has a form component, and in the form is another
> component "contactinfo." This component is basically a custom editor for
> a contact bean. In the page I must do some custom validation on the
> server side, and in at least one instance I want to record an error on a
> field within the contactinfo. However I run into the issue that I can't
> use @Component in my page class, because the Field (component) is within
> an embedded component. How can I get at the Field? ComponentResources
> has getEmbeddedComponent, it returns type Component. Any ideas?
> 
> Thanks in advance,
> Chris Lewis
> 

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