You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Adam Zimowski <zi...@gmail.com> on 2006/02/15 18:33:42 UTC

How to dynamically obtains component's form id?

Hi,

Suppose I have a custom component built around a @TextField such that
I can drop this component inside any new @Form and it will magicall
work. From within my @TextField component I know nothing about the
host @Form, but I need to know it's ID at runtime. How can I do this?

-adam

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


Re: How to dynamically obtains component's form id?

Posted by Ivano <i....@mclink.it>.
Hi Adam,
sorry but I must be mistaken, probably you want to extend

org.apache.tapestry.form.AbstractFormComponent.

That should do?

Enjoy!

Ivano Pagano

Adam Zimowski wrote:

>Thanks! That may be what I was looking for! But looking at the JavaDoc
>for getForm it says:
>
>"Returns the IForm which contains the component, or null if the
>component is not contained by a form, of if the containing Form is not
>currently renderring."
>
>Well, my component is not contained in any form. It is expected to be
>placed on a page (or another component) which provides a form for it.
>So how can I implement this interface not knowing anything about the
>form?
>
>-adam
>
>On 2/16/06, Ivano <i....@mclink.it> wrote:
>  
>
>>If you write a component which should work inside a form I think you're
>>supposed to implement the
>>
>>org.apache.tapestry.form.IFormComponent interface, which has a getForm()
>>,method.
>>
>>Bye
>>
>>Ivano Pagano.
>>
>>Jesse Kuhnert wrote:
>>
>>    
>>
>>>Not sure if this is in 4.0 officially, but TapestryUtils has a method
>>>called:
>>>
>>>public static IForm getForm(IRequestCycle cycle, IComponent component)
>>>
>>>Which will return you the current form instance (assuming you are calling
>>>this from a form component or any component contained by a form ).
>>>
>>>On 2/15/06, Adam Zimowski <zi...@gmail.com> wrote:
>>>
>>>
>>>      
>>>
>>>>Hi,
>>>>
>>>>Suppose I have a custom component built around a @TextField such that
>>>>I can drop this component inside any new @Form and it will magicall
>>>>work. From within my @TextField component I know nothing about the
>>>>host @Form, but I need to know it's ID at runtime. How can I do this?
>>>>
>>>>-adam
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>        
>>>>
>>>
>>>      
>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>    
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>
>  
>

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


Re: How to dynamically obtains component's form id?

Posted by Adam Zimowski <zi...@gmail.com>.
Thanks! That may be what I was looking for! But looking at the JavaDoc
for getForm it says:

"Returns the IForm which contains the component, or null if the
component is not contained by a form, of if the containing Form is not
currently renderring."

Well, my component is not contained in any form. It is expected to be
placed on a page (or another component) which provides a form for it.
So how can I implement this interface not knowing anything about the
form?

-adam

On 2/16/06, Ivano <i....@mclink.it> wrote:
> If you write a component which should work inside a form I think you're
> supposed to implement the
>
> org.apache.tapestry.form.IFormComponent interface, which has a getForm()
> ,method.
>
> Bye
>
> Ivano Pagano.
>
> Jesse Kuhnert wrote:
>
> >Not sure if this is in 4.0 officially, but TapestryUtils has a method
> >called:
> >
> >public static IForm getForm(IRequestCycle cycle, IComponent component)
> >
> >Which will return you the current form instance (assuming you are calling
> >this from a form component or any component contained by a form ).
> >
> >On 2/15/06, Adam Zimowski <zi...@gmail.com> wrote:
> >
> >
> >>Hi,
> >>
> >>Suppose I have a custom component built around a @TextField such that
> >>I can drop this component inside any new @Form and it will magicall
> >>work. From within my @TextField component I know nothing about the
> >>host @Form, but I need to know it's ID at runtime. How can I do this?
> >>
> >>-adam
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >>
> >>
> >>
> >>
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>

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


Re: How to dynamically obtains component's form id?

Posted by Ivano <i....@mclink.it>.
If you write a component which should work inside a form I think you're 
supposed to implement the

org.apache.tapestry.form.IFormComponent interface, which has a getForm() 
,method.

Bye

Ivano Pagano.

Jesse Kuhnert wrote:

>Not sure if this is in 4.0 officially, but TapestryUtils has a method
>called:
>
>public static IForm getForm(IRequestCycle cycle, IComponent component)
>
>Which will return you the current form instance (assuming you are calling
>this from a form component or any component contained by a form ).
>
>On 2/15/06, Adam Zimowski <zi...@gmail.com> wrote:
>  
>
>>Hi,
>>
>>Suppose I have a custom component built around a @TextField such that
>>I can drop this component inside any new @Form and it will magicall
>>work. From within my @TextField component I know nothing about the
>>host @Form, but I need to know it's ID at runtime. How can I do this?
>>
>>-adam
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>    
>>
>
>  
>

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


Re: How to dynamically obtains component's form id?

Posted by Jesse Kuhnert <jk...@gmail.com>.
Not sure if this is in 4.0 officially, but TapestryUtils has a method
called:

public static IForm getForm(IRequestCycle cycle, IComponent component)

Which will return you the current form instance (assuming you are calling
this from a form component or any component contained by a form ).

On 2/15/06, Adam Zimowski <zi...@gmail.com> wrote:
>
> Hi,
>
> Suppose I have a custom component built around a @TextField such that
> I can drop this component inside any new @Form and it will magicall
> work. From within my @TextField component I know nothing about the
> host @Form, but I need to know it's ID at runtime. How can I do this?
>
> -adam
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>

Re: How to dynamically obtains component's form id?

Posted by Edgar Chan Carrillo <ed...@gmail.com>.
I thing the only way to do this is iterate over all page components and look
for some
Form class component instance, as far as i know theres no direct way to get
the id from a component type, something like the DOM getElementByTagName
does (which could be graet!!)

Correct me if im wrong.


On 2/15/06, Adam Zimowski <zi...@gmail.com> wrote:
>
> Hi,
>
> Suppose I have a custom component built around a @TextField such that
> I can drop this component inside any new @Form and it will magicall
> work. From within my @TextField component I know nothing about the
> host @Form, but I need to know it's ID at runtime. How can I do this?
>
> -adam
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>