You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Hunter Kelly <hk...@newbay.com> on 2004/03/03 18:49:42 UTC

How to access meta-info from java?

I have some components that I want to tag with some
extra information, and then later, I want to have another piece
of code read that info back.

for example

<component type="Foo">
  <param name="myThingEnabled" value="true">
  ...
</component>

I tried getProperty() on the IComponent object, but that threw an
OGNL exception.

Is that property visible from java?

Thanks,

Hunter



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


Re: How to access meta-info from java?

Posted by Harish Krishnaswamy <hk...@comcast.net>.
When I said "yourComponent.getSpecification" I meant your containing 
component. So if the page was containing the declaration of component 
Foo then yes you have to get the specification of the page. Although you 
can simply say getSpecification() assuming you are doing this from 
within the page().

IComponentSpecification compSpec = getSpecification();
String myThingEnabled = compSpec.getComponent("fooId").getProperty("myThingEnabled");

-Harish

Hunter Kelly wrote:

>Actually, I did get this to work, but had to do the following:
>
>IComponentSpecification pspec = component.getPage().getSpecification();
>IContainedComponent cspec = pspec.getComponent(component.getId());
>String required = cspec.getProperty("renderRequiredMarker");
>
>As in, I had to get the page specification, then the component
>specification, instead of getting the components specification
>directly.
>
>I'm guessing that this is because getting the components spec
>is getting the spec from the actual components jwc file, 
>as opposed to where the instance of the component is declared,
>ie, in the page spec?
>
>Thanks,
>
>H
>
>On Thu, 2004-03-04 at 11:44, Hunter Kelly wrote:
>  
>
>>I tried what you suggested, and variations (like not looking up
>>contained components, etc), but I wasn't able to find _any_ properties
>>for the component, even when looking at the page specification,
>>etc.
>>
>>Not sure what the problem is, do I have to enable keeping
>>those properties or something?
>>
>>H
>>
>>On Wed, 2004-03-03 at 18:28, Harish Krishnaswamy wrote:
>>    
>>
>>>Try ...
>>>
>>>.jwc
>>><component id="fooId" type="Foo">
>>>    <property name="myThingEnabled" value="true" />
>>>    ...
>>></component>
>>>
>>>.java
>>>...
>>>IComponentSpecification compSpec = yourComponent.getSpecification();
>>>String myThingEnabled = 
>>>compSpec.getComponent("fooId").getProperty("myThingEnabled");
>>>...
>>>
>>>-Harish
>>>
>>>
>>>Hunter Kelly wrote:
>>>
>>>      
>>>
>>>>I have some components that I want to tag with some
>>>>extra information, and then later, I want to have another piece
>>>>of code read that info back.
>>>>
>>>>for example
>>>>
>>>><component type="Foo">
>>>> <param name="myThingEnabled" value="true">
>>>> ...
>>>></component>
>>>>
>>>>I tried getProperty() on the IComponent object, but that threw an
>>>>OGNL exception.
>>>>
>>>>Is that property visible from java?
>>>>
>>>>Thanks,
>>>>
>>>>Hunter
>>>>
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>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: How to access meta-info from java?

Posted by Hunter Kelly <re...@eircom.net>.
Actually, I did get this to work, but had to do the following:

IComponentSpecification pspec = component.getPage().getSpecification();
IContainedComponent cspec = pspec.getComponent(component.getId());
String required = cspec.getProperty("renderRequiredMarker");

As in, I had to get the page specification, then the component
specification, instead of getting the components specification
directly.

I'm guessing that this is because getting the components spec
is getting the spec from the actual components jwc file, 
as opposed to where the instance of the component is declared,
ie, in the page spec?

Thanks,

H

On Thu, 2004-03-04 at 11:44, Hunter Kelly wrote:
> I tried what you suggested, and variations (like not looking up
> contained components, etc), but I wasn't able to find _any_ properties
> for the component, even when looking at the page specification,
> etc.
> 
> Not sure what the problem is, do I have to enable keeping
> those properties or something?
> 
> H
> 
> On Wed, 2004-03-03 at 18:28, Harish Krishnaswamy wrote:
> > Try ...
> > 
> > .jwc
> > <component id="fooId" type="Foo">
> >     <property name="myThingEnabled" value="true" />
> >     ...
> > </component>
> > 
> > .java
> > ...
> > IComponentSpecification compSpec = yourComponent.getSpecification();
> > String myThingEnabled = 
> > compSpec.getComponent("fooId").getProperty("myThingEnabled");
> > ...
> > 
> > -Harish
> > 
> > 
> > Hunter Kelly wrote:
> > 
> > >I have some components that I want to tag with some
> > >extra information, and then later, I want to have another piece
> > >of code read that info back.
> > >
> > >for example
> > >
> > ><component type="Foo">
> > >  <param name="myThingEnabled" value="true">
> > >  ...
> > ></component>
> > >
> > >I tried getProperty() on the IComponent object, but that threw an
> > >OGNL exception.
> > >
> > >Is that property visible from java?
> > >
> > >Thanks,
> > >
> > >Hunter
> > >
> > >
> > >
> > >---------------------------------------------------------------------
> > >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 access meta-info from java?

Posted by Hunter Kelly <re...@eircom.net>.
I tried what you suggested, and variations (like not looking up
contained components, etc), but I wasn't able to find _any_ properties
for the component, even when looking at the page specification,
etc.

Not sure what the problem is, do I have to enable keeping
those properties or something?

H

On Wed, 2004-03-03 at 18:28, Harish Krishnaswamy wrote:
> Try ...
> 
> .jwc
> <component id="fooId" type="Foo">
>     <property name="myThingEnabled" value="true" />
>     ...
> </component>
> 
> .java
> ...
> IComponentSpecification compSpec = yourComponent.getSpecification();
> String myThingEnabled = 
> compSpec.getComponent("fooId").getProperty("myThingEnabled");
> ...
> 
> -Harish
> 
> 
> Hunter Kelly wrote:
> 
> >I have some components that I want to tag with some
> >extra information, and then later, I want to have another piece
> >of code read that info back.
> >
> >for example
> >
> ><component type="Foo">
> >  <param name="myThingEnabled" value="true">
> >  ...
> ></component>
> >
> >I tried getProperty() on the IComponent object, but that threw an
> >OGNL exception.
> >
> >Is that property visible from java?
> >
> >Thanks,
> >
> >Hunter
> >
> >
> >
> >---------------------------------------------------------------------
> >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 access meta-info from java?

Posted by Harish Krishnaswamy <hk...@comcast.net>.
Try ...

.jwc
<component id="fooId" type="Foo">
    <property name="myThingEnabled" value="true" />
    ...
</component>

.java
...
IComponentSpecification compSpec = yourComponent.getSpecification();
String myThingEnabled = 
compSpec.getComponent("fooId").getProperty("myThingEnabled");
...

-Harish


Hunter Kelly wrote:

>I have some components that I want to tag with some
>extra information, and then later, I want to have another piece
>of code read that info back.
>
>for example
>
><component type="Foo">
>  <param name="myThingEnabled" value="true">
>  ...
></component>
>
>I tried getProperty() on the IComponent object, but that threw an
>OGNL exception.
>
>Is that property visible from java?
>
>Thanks,
>
>Hunter
>
>
>
>---------------------------------------------------------------------
>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