You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Joe Andolina <jo...@andomation.com> on 2005/01/30 02:50:30 UTC

Multiple Product Listings

Hello,
    I am building an app that has several Product types to list, not at 
the same time. So far the application is generic in its handling of 
these various objects. When it comes to listing them I would like to 
have a custom jwc / html for each Product type. Music has an artist 
where as clothing has sizes. So my app may contain a MusicListing.jwc 
and a ClothingListing.jwc. Is there a way for me to switch out the 
'type' on my component 'productListing'? See below

Joe

<div jwcid="productList" element="div">               
    <div jwcid="productListing"/>
</div>


<component id="productList" type="Foreach">
    <binding name="source" expression="productList" />
    <binding name="value" expression="currProduct" />
</component>

<component id="productListing" type="ProductListing">
    <binding name="index" expression="components.productList.index"/>
    <binding name="product" expression="currProduct"/>
</component>



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


Re: Multiple Product Listings

Posted by Jamie Orchard-Hays <ja...@dang.com>.
I should have include a pseudo-condition:
<component id="ifClothing" type="Conditional">
     <binding name="condition" condition="product instanceof 
your.package.Clothing"/>
</component>

On Jan 30, 2005, at 2:05 PM, Jamie Orchard-Hays wrote:

> <component id="ifClothing" type="Conditional">
>     <binding name="condition" condition="...."/>
> </component>


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


Re: Multiple Product Listings

Posted by Jamie Orchard-Hays <ja...@dang.com>.
Great!

Jamie
On Jan 30, 2005, at 3:13 PM, Joe Andolina wrote:

> PERFECT! Thanks
>
> Jamie Orchard-Hays wrote:
>
>> Is this what you're trying to do?
>>
>> You have a list of products to display, so you iterate the list and  
>> display them
>> You have different display components because each type needs to be  
>> displayed differently
>> So, you need to be able to identify what type each product is and use  
>> the correct component for it
>>
>> It seems to me that you might leverage "instanceof" in your loop. So  
>> you'd end up with something like:
>>
>> <component id="ifClothing" type="Conditional">
>>     <binding name="condition" condition="...."/>
>> </component>
>> <component id="ifMusic" type="Conditional">
>>     <binding name="condition" condition="...."/>
>> </component>
>>
>> Then in your html template you'd have:
>>
>> <span jwcid="ifClothing>
>>     <span jwcid="clothingComponent"/>
>> </span>
>> <span jwcid="ifMusic>
>>     <span jwcid="musicComponent"/>
>> </span>
>>
>>
>> Does this help?
>>
>> Jamie
>>
>> On Jan 30, 2005, at 12:23 PM, Joe Andolina wrote:
>>
>>> Jaime,
>>>    The objects being returned are all implementing the same  
>>> interface. The details of which type each object is, is contained  
>>> within the object. I thought it might be "right" to have a  
>>> containerListing component. That way the containerListing component  
>>> can be included in my loop and the containerListing will have a  
>>> conditional for each object type and include the proper product  
>>> listing. I was thinking I can use this same concept for product  
>>> details pages as well. Is that a good approach?
>>>
>>> Joe
>>>
>>> Jamie Orchard-Hays wrote:
>>>
>>>> When your Foreach executes, how does it know which product type is  
>>>> being listed?
>>>>
>>>>
>>>>
>>>> On Jan 29, 2005, at 8:50 PM, Joe Andolina wrote:
>>>>
>>>>> Hello,
>>>>>    I am building an app that has several Product types to list,  
>>>>> not at the same time. So far the application is generic in its  
>>>>> handling of these various objects. When it comes to listing them I  
>>>>> would like to have a custom jwc / html for each Product type.  
>>>>> Music has an artist where as clothing has sizes. So my app may  
>>>>> contain a MusicListing.jwc and a ClothingListing.jwc. Is there a  
>>>>> way for me to switch out the 'type' on my component  
>>>>> 'productListing'? See below
>>>>>
>>>>> Joe
>>>>>
>>>>> <div jwcid="productList" element="div">                  <div  
>>>>> jwcid="productListing"/>
>>>>> </div>
>>>>>
>>>>>
>>>>> <component id="productList" type="Foreach">
>>>>>    <binding name="source" expression="productList" />
>>>>>    <binding name="value" expression="currProduct" />
>>>>> </component>
>>>>>
>>>>> <component id="productListing" type="ProductListing">
>>>>>    <binding name="index"  
>>>>> expression="components.productList.index"/>
>>>>>    <binding name="product" expression="currProduct"/>
>>>>> </component>
>>>>>
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------- 
>>>>> --
>>>>> 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: Multiple Product Listings

Posted by Jamie Orchard-Hays <ja...@dang.com>.
Is this what you're trying to do?

You have a list of products to display, so you iterate the list and 
display them
You have different display components because each type needs to be 
displayed differently
So, you need to be able to identify what type each product is and use 
the correct component for it

It seems to me that you might leverage "instanceof" in your loop. So 
you'd end up with something like:

<component id="ifClothing" type="Conditional">
     <binding name="condition" condition="...."/>
</component>
<component id="ifMusic" type="Conditional">
     <binding name="condition" condition="...."/>
</component>

Then in your html template you'd have:

<span jwcid="ifClothing>
     <span jwcid="clothingComponent"/>
</span>
<span jwcid="ifMusic>
     <span jwcid="musicComponent"/>
</span>


Does this help?

Jamie

On Jan 30, 2005, at 12:23 PM, Joe Andolina wrote:

> Jaime,
>    The objects being returned are all implementing the same interface. 
> The details of which type each object is, is contained within the 
> object. I thought it might be "right" to have a containerListing 
> component. That way the containerListing component can be included in 
> my loop and the containerListing will have a conditional for each 
> object type and include the proper product listing. I was thinking I 
> can use this same concept for product details pages as well. Is that a 
> good approach?
>
> Joe
>
> Jamie Orchard-Hays wrote:
>
>> When your Foreach executes, how does it know which product type is 
>> being listed?
>>
>>
>>
>> On Jan 29, 2005, at 8:50 PM, Joe Andolina wrote:
>>
>>> Hello,
>>>    I am building an app that has several Product types to list, not 
>>> at the same time. So far the application is generic in its handling 
>>> of these various objects. When it comes to listing them I would like 
>>> to have a custom jwc / html for each Product type. Music has an 
>>> artist where as clothing has sizes. So my app may contain a 
>>> MusicListing.jwc and a ClothingListing.jwc. Is there a way for me to 
>>> switch out the 'type' on my component 'productListing'? See below
>>>
>>> Joe
>>>
>>> <div jwcid="productList" element="div">                  <div 
>>> jwcid="productListing"/>
>>> </div>
>>>
>>>
>>> <component id="productList" type="Foreach">
>>>    <binding name="source" expression="productList" />
>>>    <binding name="value" expression="currProduct" />
>>> </component>
>>>
>>> <component id="productListing" type="ProductListing">
>>>    <binding name="index" expression="components.productList.index"/>
>>>    <binding name="product" expression="currProduct"/>
>>> </component>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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: Multiple Product Listings

Posted by Jamie Orchard-Hays <ja...@dang.com>.
When your Foreach executes, how does it know which product type is 
being listed?



On Jan 29, 2005, at 8:50 PM, Joe Andolina wrote:

> Hello,
>    I am building an app that has several Product types to list, not at 
> the same time. So far the application is generic in its handling of 
> these various objects. When it comes to listing them I would like to 
> have a custom jwc / html for each Product type. Music has an artist 
> where as clothing has sizes. So my app may contain a MusicListing.jwc 
> and a ClothingListing.jwc. Is there a way for me to switch out the 
> 'type' on my component 'productListing'? See below
>
> Joe
>
> <div jwcid="productList" element="div">                  <div 
> jwcid="productListing"/>
> </div>
>
>
> <component id="productList" type="Foreach">
>    <binding name="source" expression="productList" />
>    <binding name="value" expression="currProduct" />
> </component>
>
> <component id="productListing" type="ProductListing">
>    <binding name="index" expression="components.productList.index"/>
>    <binding name="product" expression="currProduct"/>
> </component>
>
>
>
> ---------------------------------------------------------------------
> 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