problem in overriding how data is displayed in a contrib:table component

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

problem in overriding how data is displayed in a contrib:table component

ChrisAndCatharineMiller
Hi,

I am trying to override the way in which data is displayed in a contrib:Table component.

I have a List (productList) which contains a list of Product Objects.

The Product class includes methods such as
  a.. getProductsImage - which returns URL which represents the image associated with the product
  b.. getProductsId - the unique ID of the product
  c.. getProductsDescriptionForCurrentCountry - which returns a ProductsDescription object for the locale in which the user is currently in  (this is to allow different information about the product such as Name, Description etc to be locale specific). The ProductsDescription class includes a getProductsName method.
 I have managed to display the list of products and show the associated image using the following html:

  <table class="productListing" width="100%" jwcid=" table@contrib:Table "
  source="ognl:productList"
  columns="productsId, productsImage, productsPrice, productsDescriptionForCurrentCountry.productsName"
  </table>

  <!-- This will override the way in which the image column is displayed
       (so that we can display the image rather than just the text representing
       the URL as text) -->
  <span jwcid="productsImageColumnValue@Block">
      <img jwcid="@Image" image="ognl:components.table.tableRow.productsImageAsset"/>
  </span>
This works fine and correctly shows the name for the users locale and a product image. However I also want to add a DirectLink to the productsDescriptionForCurrentCountry.productsName column so that the full details for the product can be shown.
In theory, based on the productsImage implementation, the way to do this would be to add

  <span jwcid="productsDescriptionForCurrentCountry.productsNameColumnValue@Block">
      <img jwcid="@DirectLink" listener="ognl:listeners.showProductDetailsListener" parameters="ognl:components.table.tableRow.productsId"/>
  </span>
However, this causes an exception
 Tag <span> on line 22 contains an invalid jwcid 'productsDescriptionForCurrentCountry.productsNameColumnValue@Block'.

is there a way for me create the correct syntax to setup a hyperlink on this column ?

I can seen why productsDescriptionForCurrentCountry.productsNameColumnValue@Block would cause problems, but cannot see how to do it properly. In the worst case I can implement a method on my Product object such as getNameForCurrentCountry which implements getProductsDescriptionForCurrentCounry,getProductsName
but I am trying to keep my data objects separate from the view components.

Any help much appreciated !

Thanks,

Chris




Reply | Threaded
Open this post in threaded view
|

Re: problem in overriding how data is displayed in a contrib:table component

Mind Bridge
Hi,

>   columns="productsId, productsImage, productsPrice,
productsDescriptionForCurrentCountry.productsName"

Everything comes from here. Make your column ID to be
'productsDescriptionForCurrentCountry'. If you want this column to be sorted
by the product's name, then make the OGNL expression used for sorting that
column to be 'productsDescriptionForCurrentCountry.productsName' (or if you
do not want this column to be sortable, simply prepend ! to it).

In other words, define the columns like that:

columns="productsId, productsImage, productsPrice,
productsDescriptionForCurrentCountry:productsDescriptionForCurrentCountry.pr
oductsName"

In this way, you column ID becomes 'productsDescriptionForCurrentCountry',
the block to override the rendering of the column becomes

  <span jwcid="productsDescriptionForCurrentCountryColumnValue@Block">

then in your properties file you can define the following to define the
column title:

productsDescriptionForCurrentCountry = Product Description

etc.

I hope this helps...

-mb


----- Original Message -----
From: "ChrisAndCatharineMiller" <[hidden email]>
To: <[hidden email]>
Sent: Saturday, May 14, 2005 2:28 PM
Subject: problem in overriding how data is displayed in a contrib:table
component


Hi,

I am trying to override the way in which data is displayed in a
contrib:Table component.

I have a List (productList) which contains a list of Product Objects.

The Product class includes methods such as
  a.. getProductsImage - which returns URL which represents the image
associated with the product
  b.. getProductsId - the unique ID of the product
  c.. getProductsDescriptionForCurrentCountry - which returns a
ProductsDescription object for the locale in which the user is currently in
(this is to allow different information about the product such as Name,
Description etc to be locale specific). The ProductsDescription class
includes a getProductsName method.
 I have managed to display the list of products and show the associated
image using the following html:

  <table class="productListing" width="100%" jwcid=" table@contrib:Table "
  source="ognl:productList"
  columns="productsId, productsImage, productsPrice,
productsDescriptionForCurrentCountry.productsName"
  </table>

  <!-- This will override the way in which the image column is displayed
       (so that we can display the image rather than just the text
representing
       the URL as text) -->
  <span jwcid="productsImageColumnValue@Block">
      <img jwcid="@Image"
image="ognl:components.table.tableRow.productsImageAsset"/>
  </span>
This works fine and correctly shows the name for the users locale and a
product image. However I also want to add a DirectLink to the
productsDescriptionForCurrentCountry.productsName column so that the full
details for the product can be shown.
In theory, based on the productsImage implementation, the way to do this
would be to add

  <span
jwcid="productsDescriptionForCurrentCountry.productsNameColumnValue@Block">
      <img jwcid="@DirectLink"
listener="ognl:listeners.showProductDetailsListener"
parameters="ognl:components.table.tableRow.productsId"/>
  </span>
However, this causes an exception
 Tag <span> on line 22 contains an invalid jwcid
'productsDescriptionForCurrentCountry.productsNameColumnValue@Block'.

is there a way for me create the correct syntax to setup a hyperlink on this
column ?

I can seen why
productsDescriptionForCurrentCountry.productsNameColumnValue@Block would
cause problems, but cannot see how to do it properly. In the worst case I
can implement a method on my Product object such as getNameForCurrentCountry
which implements getProductsDescriptionForCurrentCounry,getProductsName
but I am trying to keep my data objects separate from the view components.

Any help much appreciated !

Thanks,

Chris







---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]