You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Erik Hatcher <er...@ehatchersolutions.com> on 2004/04/21 18:00:45 UTC

component name

How do you get the component "name" (i.e. its type, like "Insert" from 
an @Insert component) from an instance of IComponent?

Am I just slow this morning and don't see it?  I'm looking at 
DefaultComponentMessagesSource and see it goes through a contortion of 
pulling it from an IResourceLocation and pulling everything before the 
dot.  Is that the only way?  Ouch.

Thanks,
	Erik


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


Re: component name

Posted by Harish Krishnaswamy <hk...@comcast.net>.
Xyz.jwc
<component-specification ... class="blah.blah.Abc">
...
</component-specification>

Typically your component class name would be the same as the component 
name but it is not mandatory.

Components w/o a class would have the BaseComponent as the component 
class by default if it has a template.

-Harish


Kevin C. Dorff wrote:

> Can you give me a case where the component type and class name don't 
> relate to some sort of (more or less) 1:1 relationship where you could 
> at least map class name x to component type y ?? I was under the 
> impression when I create a component of type "Table" Tapestry was 
> behind the scenes creating an object of type 
> "org.apache.tapestry.contrib.table.components.Table", which appears to 
> be 1:1.
>
> The only time I can think of when a class name wouldn't be hepful 
> would be a component that has no associated class -- which is 
> possible. I am not sure what you would get back in the case.
>
> When I am debugging the code in Eclipse and look at the component 
> obtained by "c = getComponent("resultsTable");" and the specification 
> obtained by "IComponentSpecification s = c.getSpecification();" I 
> don't see anywhere it has "Table" in its properties, the closest I 
> found was "org.apache.tapestry.contrib.table.components.Table". 
> Hopefully you are right and there is some method call I am missing -- 
> this would be handy.
>
> Kevin
>
> Erik Hatcher wrote:
>
>> But the class name and the component "type" don't have to relate at 
>> all, so I'd rather not key off the class name.  Common sense says the 
>> names should match though, but nothing requires that.
>>
>> Thanks,
>>     Erik
>>
>>
>> On Apr 21, 2004, at 12:27 PM, Kevin C. Dorff wrote:
>>
>>> I am not 100% this will help, but assuming you are naming your 
>>> components, more like
>>>
>>>    jwcid="resultsTable@Table"
>>>
>>> Or even better split up so you just have jwcid="resultsTable" and 
>>> that is completely defined in your .page file.
>>>
>>> In your java code for the page you could
>>>
>>>        IComponent c = getComponent("resultsTable");
>>>        IComponentSpecification s = c.getSpecification();
>>>        String x = s.getComponentClassName();
>>> and this would give you the Java type being used... for table you get
>>>
>>>   org.apache.tapestry.contrib.table.components.Table
>>>
>>> Hope that gets you at least in the right direction. From a cursory 
>>> glance that is the best I came up with although there certainly may 
>>> be better.
>>>
>>> Kevin
>>>
>>> Erik Hatcher wrote:
>>>
>>>> How do you get the component "name" (i.e. its type, like "Insert" 
>>>> from an @Insert component) from an instance of IComponent?
>>>>
>>>> Am I just slow this morning and don't see it?  I'm looking at 
>>>> DefaultComponentMessagesSource and see it goes through a contortion 
>>>> of pulling it from an IResourceLocation and pulling everything 
>>>> before the dot.  Is that the only way?  Ouch.
>>>>
>>>> Thanks,
>>>>     Erik
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>
>

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


Re: component name

Posted by "Kevin C. Dorff" <kd...@kcp.com>.
Can you give me a case where the component type and class name don't 
relate to some sort of (more or less) 1:1 relationship where you could 
at least map class name x to component type y ?? I was under the 
impression when I create a component of type "Table" Tapestry was behind 
the scenes creating an object of type 
"org.apache.tapestry.contrib.table.components.Table", which appears to 
be 1:1.

The only time I can think of when a class name wouldn't be hepful would 
be a component that has no associated class -- which is possible. I am 
not sure what you would get back in the case.

When I am debugging the code in Eclipse and look at the component 
obtained by "c = getComponent("resultsTable");" and the specification 
obtained by "IComponentSpecification s = c.getSpecification();" I don't 
see anywhere it has "Table" in its properties, the closest I found was 
"org.apache.tapestry.contrib.table.components.Table". Hopefully you are 
right and there is some method call I am missing -- this would be handy.

Kevin

Erik Hatcher wrote:

> But the class name and the component "type" don't have to relate at 
> all, so I'd rather not key off the class name.  Common sense says the 
> names should match though, but nothing requires that.
>
> Thanks,
>     Erik
>
>
> On Apr 21, 2004, at 12:27 PM, Kevin C. Dorff wrote:
>
>> I am not 100% this will help, but assuming you are naming your 
>> components, more like
>>
>>    jwcid="resultsTable@Table"
>>
>> Or even better split up so you just have jwcid="resultsTable" and 
>> that is completely defined in your .page file.
>>
>> In your java code for the page you could
>>
>>        IComponent c = getComponent("resultsTable");
>>        IComponentSpecification s = c.getSpecification();
>>        String x = s.getComponentClassName();
>> and this would give you the Java type being used... for table you get
>>
>>   org.apache.tapestry.contrib.table.components.Table
>>
>> Hope that gets you at least in the right direction. From a cursory 
>> glance that is the best I came up with although there certainly may 
>> be better.
>>
>> Kevin
>>
>> Erik Hatcher wrote:
>>
>>> How do you get the component "name" (i.e. its type, like "Insert" 
>>> from an @Insert component) from an instance of IComponent?
>>>
>>> Am I just slow this morning and don't see it?  I'm looking at 
>>> DefaultComponentMessagesSource and see it goes through a contortion 
>>> of pulling it from an IResourceLocation and pulling everything 
>>> before the dot.  Is that the only way?  Ouch.
>>>
>>> Thanks,
>>>     Erik
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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: component name

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
But the class name and the component "type" don't have to relate at 
all, so I'd rather not key off the class name.  Common sense says the 
names should match though, but nothing requires that.

Thanks,
	Erik


On Apr 21, 2004, at 12:27 PM, Kevin C. Dorff wrote:

> I am not 100% this will help, but assuming you are naming your 
> components, more like
>
>    jwcid="resultsTable@Table"
>
> Or even better split up so you just have jwcid="resultsTable" and that 
> is completely defined in your .page file.
>
> In your java code for the page you could
>
>        IComponent c = getComponent("resultsTable");
>        IComponentSpecification s = c.getSpecification();
>        String x = s.getComponentClassName();
> and this would give you the Java type being used... for table you get
>
>   org.apache.tapestry.contrib.table.components.Table
>
> Hope that gets you at least in the right direction. From a cursory 
> glance that is the best I came up with although there certainly may be 
> better.
>
> Kevin
>
> Erik Hatcher wrote:
>
>> How do you get the component "name" (i.e. its type, like "Insert" 
>> from an @Insert component) from an instance of IComponent?
>>
>> Am I just slow this morning and don't see it?  I'm looking at 
>> DefaultComponentMessagesSource and see it goes through a contortion 
>> of pulling it from an IResourceLocation and pulling everything before 
>> the dot.  Is that the only way?  Ouch.
>>
>> Thanks,
>>     Erik
>>
>>
>> ---------------------------------------------------------------------
>> 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: component name

Posted by "Kevin C. Dorff" <kd...@kcp.com>.
I am not 100% this will help, but assuming you are naming your 
components, more like

    jwcid="resultsTable@Table"

Or even better split up so you just have jwcid="resultsTable" and that 
is completely defined in your .page file.

In your java code for the page you could

        IComponent c = getComponent("resultsTable");
        IComponentSpecification s = c.getSpecification();
        String x = s.getComponentClassName();    

and this would give you the Java type being used... for table you get

   org.apache.tapestry.contrib.table.components.Table

Hope that gets you at least in the right direction. From a cursory 
glance that is the best I came up with although there certainly may be 
better.

Kevin

Erik Hatcher wrote:

> How do you get the component "name" (i.e. its type, like "Insert" from 
> an @Insert component) from an instance of IComponent?
>
> Am I just slow this morning and don't see it?  I'm looking at 
> DefaultComponentMessagesSource and see it goes through a contortion of 
> pulling it from an IResourceLocation and pulling everything before the 
> dot.  Is that the only way?  Ouch.
>
> Thanks,
>     Erik
>
>
> ---------------------------------------------------------------------
> 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: component name

Posted by Mindbridge <mi...@yahoo.com>.
Hi,

Since there is a 1:many mapping between a component specification and a
component type (alias, etc), this is a bit more complex than it should be.
The following should do it though, I believe:

getContainer().getSpecification().getComponent(getId()).getType()

Does this do what is needed?

-mb

----- Original Message ----- 
From: "Erik Hatcher" <er...@ehatchersolutions.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Wednesday, April 21, 2004 7:00 PM
Subject: component name


> How do you get the component "name" (i.e. its type, like "Insert" from
> an @Insert component) from an instance of IComponent?
>
> Am I just slow this morning and don't see it?  I'm looking at
> DefaultComponentMessagesSource and see it goes through a contortion of
> pulling it from an IResourceLocation and pulling everything before the
> dot.  Is that the only way?  Ouch.
>
> Thanks,
> Erik
>
>
> ---------------------------------------------------------------------
> 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