You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by manuel martin <ma...@med.cornell.edu> on 2004/08/13 00:19:18 UTC

dynamic property type specification

Hello,

I would like to be able to specify the type of a component's property
(typically for a table's row definition) at runtime, or more specifically as
a component's parameter: 

<component-specification 

class="org.sigpath.tapestry.components.table.SpEntityList"
    	allow-body="no" allow-informal-parameters="yes">

   <parameter name="entitiesType"
 
Default-value="org.sigpath.tapestry.components.table.DisplayEntity"
                   direction="auto"
                   required="no" type="java.lang.String"/>

      <!--ideally I would have liked to dynamically set the type from the
"entitiesType parameter here-->
	<property-specification name="currentEntity" type="DefaultType"/>

	<component id="tableFormRows" type="contrib:TableFormRows">
		<binding name="row" expression="currentEntity"/>
	</component>

</component-specification>

Any hints? I was thinking to do it using the setType() method of the
properties, by it's not clear if I can and where should I do it.

Thanks,                Manuel


-----Original Message-----
From: Howard Lewis Ship [mailto:hlship@gmail.com] 
Sent: Thursday, August 12, 2004 3:33 PM
To: Tapestry users
Subject: Re: Can Tapestry not instantiate abstract classes where it doesn't
have to do any work?

This will also be fixed in 3.0.1.  The change is avaialble in CVS.

On Sun, 8 Aug 2004 08:57:00 -0400, Todd O'Bryan <to...@mac.com> wrote:
> You're right, of course. But just because there's no need to do
> something, doesn't mean I'm not going to do it anyway. :-)
> 
> Thanks for the explanation. All is now clear.
> 
> Todd
> 
> 
> 
> On Aug 8, 2004, at 5:20 AM, Geoff Longman wrote:
> 
> >
> > Todd,
> >
> > Tapestry will only enhance abstract page classes that have a
> > <property-specification> tag in the spec.
> >
> > Don't make your base ProtectedPage abstract, there's no need to.
> >
> > Cheers,
> >
> > Geoff
> >
> > Todd O'Bryan wrote:
> >
> >> I have an abstract class called ProtectedPage. For some reason,
> >> Tapestry can't instantiate it. I worked around by extending it with,
> >> say
> >>
> >> public class SubsectionMenu extends ProtectedPage {
> >> }
> >>
> >> which is just an empty class.
> >>
> >> But then I tried to make (the still empty) SubsectionMenu abstract,
> >> and I get an error saying Tapestry can't instantiate it.
> >>
> >> Does Tapestry look for stuff it has to do and refuse to instantiate
> >> abstract classes if it doesn't have things to fill in or am I just
> >> doing something silly?
> >>
> >> Todd
> >>
> >>
> >> ---------------------------------------------------------------------
> >> 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
> 
> 


-- 
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind
http://howardlewisship.com

---------------------------------------------------------------------
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: dynamic property type specification

Posted by manuel martin <ma...@med.cornell.edu>.
Well yes I must admit that I forgot to change the abstract accessor
signature in the java class definition! Now everything's fine, sorry for the
inconvenience and thanks again!

-----Original Message-----
From: Marius Siegas [mailto:marius@elinara.ktu.lt] 
Sent: Friday, August 13, 2004 10:48 AM
To: Tapestry users
Subject: Re: dynamic property type specification

well yes, you need to specify the same type in your page specification 
and its class accessor methods. now why can't you use your 
org.sigpath.tapestry.components.table.DisplayEntity? or if not then why 
can't you use java.lang.Object in your java source and cast the object 
to the right time at run-time? i still see no problem here...

manuel martin wrote:
> Hi,
> 
> I tried that already, but it does not seem to be possible. Apparently the
> class name one intends to use has to be specified, not one of its
ancestors,
> in order to allow the enhancement process to work properly:
> 
> When specifying a java.lang.Object in the currentEntity type I get the
> following exception :
> 
> Unable to enhance class org.sigpath.tapestry.components.table.SpEntityList
> because it contains property 'currentEntity' of type
> org.sigpath.tapestry.components.table.DisplayEntity, not the expected type
> java.lang.Object
> 
> Thanks,				Manuel
> 
>  
> -----Original Message-----
> From: Marius Siegas [mailto:marius@elinara.ktu.lt] 
> Sent: Friday, August 13, 2004 3:11 AM
> To: Tapestry users
> Subject: Re: dynamic property type specification
> 
> Can't you just use java.lang.Object as type?..
> 
> manuel martin wrote:
> 
>>Hello,
>>
>>I would like to be able to specify the type of a component's property
>>(typically for a table's row definition) at runtime, or more specifically
> 
> as
> 
>>a component's parameter: 
>>
>><component-specification 
>>
>>class="org.sigpath.tapestry.components.table.SpEntityList"
>>    	allow-body="no" allow-informal-parameters="yes">
>>
>>   <parameter name="entitiesType"
>> 
>>Default-value="org.sigpath.tapestry.components.table.DisplayEntity"
>>                   direction="auto"
>>                   required="no" type="java.lang.String"/>
>>
>>      <!--ideally I would have liked to dynamically set the type from the
>>"entitiesType parameter here-->
>>	<property-specification name="currentEntity" type="DefaultType"/>
>>
>>	<component id="tableFormRows" type="contrib:TableFormRows">
>>		<binding name="row" expression="currentEntity"/>
>>	</component>
>>
>></component-specification>
>>
>>Any hints? I was thinking to do it using the setType() method of the
>>properties, by it's not clear if I can and where should I do it.
>>
>>Thanks,                Manuel
> 
> 
> 
> ---------------------------------------------------------------------
> 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: dynamic property type specification

Posted by Marius Siegas <ma...@elinara.ktu.lt>.
well yes, you need to specify the same type in your page specification 
and its class accessor methods. now why can't you use your 
org.sigpath.tapestry.components.table.DisplayEntity? or if not then why 
can't you use java.lang.Object in your java source and cast the object 
to the right time at run-time? i still see no problem here...

manuel martin wrote:
> Hi,
> 
> I tried that already, but it does not seem to be possible. Apparently the
> class name one intends to use has to be specified, not one of its ancestors,
> in order to allow the enhancement process to work properly:
> 
> When specifying a java.lang.Object in the currentEntity type I get the
> following exception :
> 
> Unable to enhance class org.sigpath.tapestry.components.table.SpEntityList
> because it contains property 'currentEntity' of type
> org.sigpath.tapestry.components.table.DisplayEntity, not the expected type
> java.lang.Object
> 
> Thanks,				Manuel
> 
>  
> -----Original Message-----
> From: Marius Siegas [mailto:marius@elinara.ktu.lt] 
> Sent: Friday, August 13, 2004 3:11 AM
> To: Tapestry users
> Subject: Re: dynamic property type specification
> 
> Can't you just use java.lang.Object as type?..
> 
> manuel martin wrote:
> 
>>Hello,
>>
>>I would like to be able to specify the type of a component's property
>>(typically for a table's row definition) at runtime, or more specifically
> 
> as
> 
>>a component's parameter: 
>>
>><component-specification 
>>
>>class="org.sigpath.tapestry.components.table.SpEntityList"
>>    	allow-body="no" allow-informal-parameters="yes">
>>
>>   <parameter name="entitiesType"
>> 
>>Default-value="org.sigpath.tapestry.components.table.DisplayEntity"
>>                   direction="auto"
>>                   required="no" type="java.lang.String"/>
>>
>>      <!--ideally I would have liked to dynamically set the type from the
>>"entitiesType parameter here-->
>>	<property-specification name="currentEntity" type="DefaultType"/>
>>
>>	<component id="tableFormRows" type="contrib:TableFormRows">
>>		<binding name="row" expression="currentEntity"/>
>>	</component>
>>
>></component-specification>
>>
>>Any hints? I was thinking to do it using the setType() method of the
>>properties, by it's not clear if I can and where should I do it.
>>
>>Thanks,                Manuel
> 
> 
> 
> ---------------------------------------------------------------------
> 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: dynamic property type specification

Posted by manuel martin <ma...@med.cornell.edu>.
Hi,

I tried that already, but it does not seem to be possible. Apparently the
class name one intends to use has to be specified, not one of its ancestors,
in order to allow the enhancement process to work properly:

When specifying a java.lang.Object in the currentEntity type I get the
following exception :

Unable to enhance class org.sigpath.tapestry.components.table.SpEntityList
because it contains property 'currentEntity' of type
org.sigpath.tapestry.components.table.DisplayEntity, not the expected type
java.lang.Object

Thanks,				Manuel

 
-----Original Message-----
From: Marius Siegas [mailto:marius@elinara.ktu.lt] 
Sent: Friday, August 13, 2004 3:11 AM
To: Tapestry users
Subject: Re: dynamic property type specification

Can't you just use java.lang.Object as type?..

manuel martin wrote:
> Hello,
> 
> I would like to be able to specify the type of a component's property
> (typically for a table's row definition) at runtime, or more specifically
as
> a component's parameter: 
> 
> <component-specification 
> 
> class="org.sigpath.tapestry.components.table.SpEntityList"
>     	allow-body="no" allow-informal-parameters="yes">
> 
>    <parameter name="entitiesType"
>  
> Default-value="org.sigpath.tapestry.components.table.DisplayEntity"
>                    direction="auto"
>                    required="no" type="java.lang.String"/>
> 
>       <!--ideally I would have liked to dynamically set the type from the
> "entitiesType parameter here-->
> 	<property-specification name="currentEntity" type="DefaultType"/>
> 
> 	<component id="tableFormRows" type="contrib:TableFormRows">
> 		<binding name="row" expression="currentEntity"/>
> 	</component>
> 
> </component-specification>
> 
> Any hints? I was thinking to do it using the setType() method of the
> properties, by it's not clear if I can and where should I do it.
> 
> Thanks,                Manuel


---------------------------------------------------------------------
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: dynamic property type specification

Posted by Marius Siegas <ma...@elinara.ktu.lt>.
Can't you just use java.lang.Object as type?..

manuel martin wrote:
> Hello,
> 
> I would like to be able to specify the type of a component's property
> (typically for a table's row definition) at runtime, or more specifically as
> a component's parameter: 
> 
> <component-specification 
> 
> class="org.sigpath.tapestry.components.table.SpEntityList"
>     	allow-body="no" allow-informal-parameters="yes">
> 
>    <parameter name="entitiesType"
>  
> Default-value="org.sigpath.tapestry.components.table.DisplayEntity"
>                    direction="auto"
>                    required="no" type="java.lang.String"/>
> 
>       <!--ideally I would have liked to dynamically set the type from the
> "entitiesType parameter here-->
> 	<property-specification name="currentEntity" type="DefaultType"/>
> 
> 	<component id="tableFormRows" type="contrib:TableFormRows">
> 		<binding name="row" expression="currentEntity"/>
> 	</component>
> 
> </component-specification>
> 
> Any hints? I was thinking to do it using the setType() method of the
> properties, by it's not clear if I can and where should I do it.
> 
> Thanks,                Manuel


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