You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Christian Mühlethaler <ch...@freesurf.ch> on 2004/10/26 15:16:51 UTC

links in contrib:Table with a column model

Hi
I  display a list of objects in a table with the values of one column 
as links to the detail page.

Created By	information
admin		<link to detailPage>
ian			<link to detailPage>

When I specify the "column" binding of the table with a string 
representing the columns, it works fine.
When I use column model instead, the links don't get rendered.

The generated html code of the page is almost the same, specially the 
class parameter's value of the <td> that
should appear as a link is the same:"informationColumnValue"

In my Page.html file I have a Block with the id = 
informationColumnValue that should render the link.
This Block is within the table
       <span jwcid="informationColumnValue@Block">
	      <span jwcid="infoLink">
		     <span jwcid="infoText"/>
	      </span>
        </span>

I First thought the latter version (with the column model) does render 
the class parameter of the value <td> different.
But this isn't the case. The version with the column model renders a 
<tbody> </tbody> within <table>, but I think this
isn't relevant.
Do I miss something or is this probably a bug?
Thank you,
Christian


Here all related code:

Page.html:
      <table class="mytable" jwcid="table">
        <span jwcid="informationColumnValue@Block">
	      <span jwcid="infoLink">
		     <span jwcid="infoText"/>
	      </span>
        </span>
     </table>
Page.page:
>     <component id="table" type="contrib:Table">
>         <binding name="source" expression="notes"/>
>         <static-binding name="columns"
>         value="
>                 creator:Created By:user.concatenatedName,
>                 information:Info:information" />
>     </component>
	
This works fine. No the version with column model;

Page.html: the same as above


Page.page:
>     <component id="table" type="contrib:Table">
>         <binding name="source" expression="notes"/>
>         <binding name="columns" expression="columnModel"/>
>    </component>
>


Page.java:
> ....
>    public ITableColumnModel getColumnModel(){
>         return new ColumnModel();
>     }
> ....
>
>
> class ColumnModel implements ITableColumnModel{
>
>     private HashMap columns;
>
>     public ColumnModel(){
>         this.columns = new HashMap();
>
>         ITableColumn column1 = new SimpleTableColumn("information", 
> "Info",
>                 new ITableColumnEvaluator(){
>             			public Object getColumnValue(ITableColumn objColumn, 
> Object objRow) {
>             			    return ((Note)objRow).getInformation();
>             			}
>         	},true);
>
>
>         ITableColumn column2 = new SimpleTableColumn("creator", "von",
>                 new ITableColumnEvaluator(){
>                     public Object getColumnValue(ITableColumn 
> objColumn, Object objRow) {
>                         return 
> ((Note)objRow).getUser().getConcatenatedName();
>                     }
>
>         },true);
>
>         columns.put(column1.getColumnName(),column2);
>         columns.put(column2.getColumnName(), column3);
>     }

>     public int getColumnCount() {
>         return this.columns.size();
>     }
>
>     public ITableColumn getColumn(String strName){
>         return (ITableColumn)columns.get(strName);
>     }
>
>     public Iterator getColumns() {
>         return columns.values().iterator();
>     }
> }
>
>

Re: links in contrib:Table with a column model

Posted by christian mühlethaler <ch...@freesurf.ch>.
Thank you John, it works now as expected.

Thank you for your TapestryTables.war as well, I learned a lot about  
contrib:Table!

...
> SimpleTableColumn has a default ValueRenderer, and that's what's
> generating the HTML.  You need to override the default ValueRenderer:
...

This is exactly what I missed.
Christian

> I expanded my direct link example to demonstrate one way of doing this.
>
>
> https://bloggers.dev.java.net/files/documents/84/7378/ 
> TapestryTables.war
>
> Basically,
> When you specify the columns using strings, Tapestry contructs a
> TableColumn from everything it finds on your .page and .html.
>
> You have defined your column explicitly as a SimpleTableColumn.
> SimpleTableColumn has a default ValueRenderer, and that's what's
> generating the HTML.  You need to override the default ValueRenderer:
>
> SimpleTableColumn column1 = new SimpleTableColumn("SSN", "SSN",
>    new ITableColumnEvaluator()
>    {
>       public Object getColumnValue(ITableColumn objColumn, Object
> objRow)
>       {
>          return ((DataItem) objRow).getSSN();
>       }
>    }, true);
>
>    // The following overrides the default
> SimpleTableColumn.getColumnValue to
>    // render the Block component we defined on the HTML template
>    column1.setValueRendererSource(
>        new BlockTableRendererSource(
>          new ComponentAddress(getComponent("SSNColumnValue"))));
>
>
> I hope this helps.
>
> -----Original Message-----
> From: Christian Mühlethaler [mailto:chmuehlethaler@freesurf.ch]
> Sent: Tuesday, October 26, 2004 8:17 AM
> To: tapestry mailinglist
> Subject: links in contrib:Table with a column model
>
>
> Hi
> I  display a list of objects in a table with the values of one column
> as links to the detail page.
>
> Created By	information
> admin		<link to detailPage>
> ian			<link to detailPage>
>
> When I specify the "column" binding of the table with a string
> representing the columns, it works fine.
> When I use column model instead, the links don't get rendered.
>
> The generated html code of the page is almost the same, specially the
> class parameter's value of the <td> that
> should appear as a link is the same:"informationColumnValue"
>
> In my Page.html file I have a Block with the id =
> informationColumnValue that should render the link.
> This Block is within the table
>        <span jwcid="informationColumnValue@Block">
> 	      <span jwcid="infoLink">
> 		     <span jwcid="infoText"/>
> 	      </span>
>         </span>
>
> I First thought the latter version (with the column model) does render
> the class parameter of the value <td> different.
> But this isn't the case. The version with the column model renders a
> <tbody> </tbody> within <table>, but I think this
> isn't relevant.
> Do I miss something or is this probably a bug?
> Thank you,
> Christian
>
>
> Here all related code:
>
> Page.html:
>       <table class="mytable" jwcid="table">
>         <span jwcid="informationColumnValue@Block">
> 	      <span jwcid="infoLink">
> 		     <span jwcid="infoText"/>
> 	      </span>
>         </span>
>      </table>
> Page.page:
>>     <component id="table" type="contrib:Table">
>>         <binding name="source" expression="notes"/>
>>         <static-binding name="columns"
>>         value="
>>                 creator:Created By:user.concatenatedName,
>>                 information:Info:information" />
>>     </component>
> 	
> This works fine. No the version with column model;
>
> Page.html: the same as above
>
>
> Page.page:
>>     <component id="table" type="contrib:Table">
>>         <binding name="source" expression="notes"/>
>>         <binding name="columns" expression="columnModel"/>
>>    </component>
>>
>
>
> Page.java:
>> ....
>>    public ITableColumnModel getColumnModel(){
>>         return new ColumnModel();
>>     }
>> ....
>>
>>
>> class ColumnModel implements ITableColumnModel{
>>
>>     private HashMap columns;
>>
>>     public ColumnModel(){
>>         this.columns = new HashMap();
>>
>>         ITableColumn column1 = new SimpleTableColumn("information",
>> "Info",
>>                 new ITableColumnEvaluator(){
>>             			public Object
> getColumnValue(ITableColumn objColumn,
>> Object objRow) {
>>             			    return
> ((Note)objRow).getInformation();
>>             			}
>>         	},true);
>>
>>
>>         ITableColumn column2 = new SimpleTableColumn("creator", "von",
>>                 new ITableColumnEvaluator(){
>>                     public Object getColumnValue(ITableColumn
>> objColumn, Object objRow) {
>>                         return
>> ((Note)objRow).getUser().getConcatenatedName();
>>                     }
>>
>>         },true);
>>
>>         columns.put(column1.getColumnName(),column2);
>>         columns.put(column2.getColumnName(), column3);
>>     }
>
>>     public int getColumnCount() {
>>         return this.columns.size();
>>     }
>>
>>     public ITableColumn getColumn(String strName){
>>         return (ITableColumn)columns.get(strName);
>>     }
>>
>>     public Iterator getColumns() {
>>         return columns.values().iterator();
>>     }
>> }
>>
>>
>
>
> ---------------------------------------------------------------------
> 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: links in contrib:Table with a column model

Posted by John Reynolds <jo...@austin.rr.com>.
Christian,

I expanded my direct link example to demonstrate one way of doing this.

 
https://bloggers.dev.java.net/files/documents/84/7378/TapestryTables.war

Basically, 
When you specify the columns using strings, Tapestry contructs a
TableColumn from everything it finds on your .page and .html.

You have defined your column explicitly as a SimpleTableColumn.
SimpleTableColumn has a default ValueRenderer, and that's what's
generating the HTML.  You need to override the default ValueRenderer:

SimpleTableColumn column1 = new SimpleTableColumn("SSN", "SSN",
   new ITableColumnEvaluator() 
   {
      public Object getColumnValue(ITableColumn objColumn, Object
objRow) 
      {
         return ((DataItem) objRow).getSSN();
      }
   }, true);

   // The following overrides the default
SimpleTableColumn.getColumnValue to
   // render the Block component we defined on the HTML template
   column1.setValueRendererSource(
       new BlockTableRendererSource(
         new ComponentAddress(getComponent("SSNColumnValue"))));
            

I hope this helps.

-----Original Message-----
From: Christian Mühlethaler [mailto:chmuehlethaler@freesurf.ch] 
Sent: Tuesday, October 26, 2004 8:17 AM
To: tapestry mailinglist
Subject: links in contrib:Table with a column model


Hi
I  display a list of objects in a table with the values of one column 
as links to the detail page.

Created By	information
admin		<link to detailPage>
ian			<link to detailPage>

When I specify the "column" binding of the table with a string 
representing the columns, it works fine.
When I use column model instead, the links don't get rendered.

The generated html code of the page is almost the same, specially the 
class parameter's value of the <td> that
should appear as a link is the same:"informationColumnValue"

In my Page.html file I have a Block with the id = 
informationColumnValue that should render the link.
This Block is within the table
       <span jwcid="informationColumnValue@Block">
	      <span jwcid="infoLink">
		     <span jwcid="infoText"/>
	      </span>
        </span>

I First thought the latter version (with the column model) does render 
the class parameter of the value <td> different.
But this isn't the case. The version with the column model renders a 
<tbody> </tbody> within <table>, but I think this
isn't relevant.
Do I miss something or is this probably a bug?
Thank you,
Christian


Here all related code:

Page.html:
      <table class="mytable" jwcid="table">
        <span jwcid="informationColumnValue@Block">
	      <span jwcid="infoLink">
		     <span jwcid="infoText"/>
	      </span>
        </span>
     </table>
Page.page:
>     <component id="table" type="contrib:Table">
>         <binding name="source" expression="notes"/>
>         <static-binding name="columns"
>         value="
>                 creator:Created By:user.concatenatedName,
>                 information:Info:information" />
>     </component>
	
This works fine. No the version with column model;

Page.html: the same as above


Page.page:
>     <component id="table" type="contrib:Table">
>         <binding name="source" expression="notes"/>
>         <binding name="columns" expression="columnModel"/>
>    </component>
>


Page.java:
> ....
>    public ITableColumnModel getColumnModel(){
>         return new ColumnModel();
>     }
> ....
>
>
> class ColumnModel implements ITableColumnModel{
>
>     private HashMap columns;
>
>     public ColumnModel(){
>         this.columns = new HashMap();
>
>         ITableColumn column1 = new SimpleTableColumn("information",
> "Info",
>                 new ITableColumnEvaluator(){
>             			public Object
getColumnValue(ITableColumn objColumn, 
> Object objRow) {
>             			    return
((Note)objRow).getInformation();
>             			}
>         	},true);
>
>
>         ITableColumn column2 = new SimpleTableColumn("creator", "von",
>                 new ITableColumnEvaluator(){
>                     public Object getColumnValue(ITableColumn
> objColumn, Object objRow) {
>                         return 
> ((Note)objRow).getUser().getConcatenatedName();
>                     }
>
>         },true);
>
>         columns.put(column1.getColumnName(),column2);
>         columns.put(column2.getColumnName(), column3);
>     }

>     public int getColumnCount() {
>         return this.columns.size();
>     }
>
>     public ITableColumn getColumn(String strName){
>         return (ITableColumn)columns.get(strName);
>     }
>
>     public Iterator getColumns() {
>         return columns.values().iterator();
>     }
> }
>
>


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