I did something recently that might be of use, it was not pretty though...

Basically the underlying page returned a list of MarketData objects (POJOs) 
that each have a method called getMarketData(String key) on them that pulled 
data from a map
i.e. each Market Data object held a number of pieces of data keyed by Strings.

For the Contrib table definition the definition was:

  <component id="resultsTable" type="Contrib:TableView">
    <binding name="source"   value="ognl:results"/>
    <binding name="columns"  value="ognl:tableColumns"/>
    <binding name="pageSize" value="ognl:pageSize"/>
  </component>

Where the getTableColumns() method on the underlying page returned something 
like:

data0:displayName1:getMarketDate('key1'),data1:displayName2:getMarketDate('key2'),data2:displayName3:getMarketDate('key3')

e.g.

data0:Mid Price:getMarketDate('Mid_Price'),data1:Mid 
Yield:getMarketDate('Mid_Yield'),data2:Ask Price:getMarketDate('Ask Price')

And the getResults() method returned a list of the MarketData objects

in the .html I then had something like:

        <td jwcid="[EMAIL PROTECTED]">
          <span jwcid="@Insert" 
value="ognl:components.rows.tableRow.getMarketData(keys[0])"></span>
        </td>
        <td jwcid="[EMAIL PROTECTED]">
          <span jwcid="@Insert" 
value="ognl:components.rows.tableRow.getMarketData(keys[1])"></span>
        </td>
        <td jwcid="[EMAIL PROTECTED]">
          <span jwcid="@Insert" 
value="ognl:components.rows.tableRow.getMarketData(keys[2])"></span>
        </td>

This is a simplified version as the original had a lot more junk...

the getKeys method returns a list of Strings that corresponds to the keys used 
to build up the original tableColumns list

You can have as many of the above Block definitions as you like to cater for up 
to the maximum number of columns of data you want to show but they will only be 
rendered for the number of columns that you declare in your table columns.

As I said it's not pretty but it did work... I did try to get it to render the 
above blocks in a For loop but could not work out how to generate them 
dynamically.

I should also point out that I'm relatively new to Tapestry so there may be 
others with far better solutions. In the end I also binned the Contrib table 
and did it myself which made for much neater code.

Dom



                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                              
             "Daniel Jue" <[EMAIL PROTECTED]>                                   
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                             
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                              
             10/18/2006 06:50 PM                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                           To 
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
        "Tapestry users" <users@tapestry.apache.org>                            
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                              
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                           cc 
                                                                                
                                                                                
                                     Please respond to                          
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                              
                                                                                
                                                                                
                        "Tapestry users" <users@tapestry.apache.org>            
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                      Subject 
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
        Complex Bindings with Contrib Table                                     
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                              
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                              
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                              
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                              
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                              
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                              
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                              




I have a POJO that has a Map object in it.  Inside the map are a bunch
of properties I'd like to display, which are strings and ints.

What I am trying to get around is having to construct getters and
setters for all the properties, but I still want to use the Contrib
Table.  (the quantity and names of the properties in the Map are
dynamic, loaded from a DB.)

Usually, it's accessed like this:
mypojo.mymap.get("SomePropertyX");

So a getter in my POJO would look like:

String getSomepropertyX()
{
   //type safety ftw!
   return (String) mypojo.mymap.get("SomePropertyX");
}

The table would have columns of "Property Name" and "Property Value"


So how would this be completed in my page spec? :

    <component id="table" type="Contrib:Table">
        <binding name="source" value="mypojo"/>
        <binding name="columns" value="?????????1, ????????2"/>
        <binding name="columnsClass" value="literal:title"/>
        <binding name="pageSize" value="10"/>
    </component>
    <component id="?????????????" type="Block"/>
    <component id="?????????" type="Insert">
         <binding name="value" value="components.table.tableRow.????????2"/>
    </component>


Thanks for any help,
Daniel

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
This e-mail may contain confidential and/or privileged information. If you are 
not the intended recipient (or have received this e-mail in error) please 
notify the sender immediately and destroy this e-mail. Any unauthorized 
copying, disclosure or distribution of the material in this e-mail is strictly 
forbidden.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to