You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Skorpien126 <lo...@web.de> on 2006/10/04 16:30:53 UTC
Insert Components depending on SubClass
Hi Guys..
I?m let?s say a Newbie. I have a Project and i want to realize the
following:
I have a abstract class called Person extending from BaseComponent owning
some properties. Furthermore I have class Worker and Non-Worker extending
from Person and owning some properties each. I read an array from Database
including Worker and Non-Workers Objects.
I have made a new component for Workers and one for non-Worker.
In another Component I read the array. This one should entry a the
Non-worker component or the Worker-Component for each object depending on
which object i want to visualize. Is there a way realize that?!?!
--
View this message in context: http://www.nabble.com/Insert-Components-depending-on-SubClass-tf2382665.html#a6640638
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Insert Components depending on SubClass
Posted by Skorpien126 <lo...@web.de>.
Juip, thats it. This should work..
( i thougth of a funtion definition in the base class, which i have to
override in every subclass... giving out the correct code)
thank u very much....
Norbert S?ndor wrote:
>
> Use the For and the If components. Pseudo code:
>
> <span jwcid="@For" source="ognl:arrayOfPersons" value="ognl:person">
> <span jwcid="@If" condition="ognl:person instanceof Worker">
> <span jwcid="@Worker" ... />
> </span>
> <span jwcid="@If" condition="ognl:person instanceof NonWorker">
> <span jwcid="@NonWorker" ... />
> </span>
> </span>
>
> I hope I understood your problem well...
>
> Regards,
> Norbi
>
> Skorpien126 wrote:
>> Hi Guys..
>> I?m let?s say a Newbie. I have a Project and i want to realize the
>> following:
>>
>> I have a abstract class called Person extending from BaseComponent owning
>> some properties. Furthermore I have class Worker and Non-Worker extending
>> from Person and owning some properties each. I read an array from
>> Database
>> including Worker and Non-Workers Objects.
>>
>> I have made a new component for Workers and one for non-Worker.
>>
>> In another Component I read the array. This one should entry a the
>> Non-worker component or the Worker-Component for each object depending on
>> which object i want to visualize. Is there a way realize that?!?!
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/Insert-Components-depending-on-SubClass-tf2382665.html#a6641608
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Insert Components depending on SubClass
Posted by Norbert Sándor <de...@erinors.com>.
Use the For and the If components. Pseudo code:
<span jwcid="@For" source="ognl:arrayOfPersons" value="ognl:person">
<span jwcid="@If" condition="ognl:person instanceof Worker">
<span jwcid="@Worker" ... />
</span>
<span jwcid="@If" condition="ognl:person instanceof NonWorker">
<span jwcid="@NonWorker" ... />
</span>
</span>
I hope I understood your problem well...
Regards,
Norbi
Skorpien126 wrote:
> Hi Guys..
> I?m let?s say a Newbie. I have a Project and i want to realize the
> following:
>
> I have a abstract class called Person extending from BaseComponent owning
> some properties. Furthermore I have class Worker and Non-Worker extending
> from Person and owning some properties each. I read an array from Database
> including Worker and Non-Workers Objects.
>
> I have made a new component for Workers and one for non-Worker.
>
> In another Component I read the array. This one should entry a the
> Non-worker component or the Worker-Component for each object depending on
> which object i want to visualize. Is there a way realize that?!?!
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Insert Components depending on SubClass
Posted by Christian Haselbach <ch...@tngtech.com>.
Quoting Skorpien126 <lo...@web.de>:
> In another Component I read the array. This one should entry a the
> Non-worker component or the Worker-Component for each object depending on
> which object i want to visualize. Is there a way realize that?!?!
You can use the If component to choose how to display something.
Assuming your Person Class has a method isWorker() that is true
iff the person instance is a worker and your component stores a
Person instance in a component property called person, you can
write the following in the html template (untested code follows):
<span jwcid="@If" condition="ognl:person.worker">
<span jwcid="@WorkerDisplayComponent" worker="ognl:person">
</span>
<span jwcid="@Else">
<span jwcid="@NonWorkerDisplayComponent" nonWorker="ognl:person">
</span>
WorkerDisplayComponent here is a component that has a parameter
worker and NonWorkerDisplayComponent is a component that has a
parameter nonWorker.
HTH
Ciao Christian
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org