I just noticed that the method getValue()

public String getValue(){
        // get the current row object from the DataModel and get the value
for this column (via this.gegenstand) from the row object
        return ((NotenErfassenStandardRow)
this.model.getRowData()).getColumnValue(this.gegenstand);
 }

should have been in NotenErfassenColumn instead of NotenErfassenDataModel.
Sorry for that!!

Regards,
Jakob


2010/2/28 Jakob Korherr <[email protected]>

> Hi Andrea,
>
> I used it once and I also needed some time to figure it out :D
>
> Here's some code, which shows t:columns in action:
>
> The View:
> <t:dataTable var="row" value="#{pageBean.dataModel}">
>            <t:columns value="#{pageBean.dataModel.columns}" var="column">
>
>                     <f:facet name="header">
>                         <h:outputText value="#{column.headertext}" />
>                     </f:facet>
>
>                     <f:facet name="footer">
>                         <h:outputText value="#{column.footertext}" />
>                     </f:facet>
>
>                     <t:outputText value="#{column.value}" />
>
>                 </t:columns>
> </t:dataTable>
>
> The DataModel:
> public class NotenErfassenDataModel extends DataModel implements
> Serializable{
>
>     private Map<Gegenstand,List<GueltigeNoten>> gegenstaende;
>     private List<NotenErfassenStandardRow> rows;
>     private List<NotenErfassenColumn> columns;
>     private int rowIndex;
>
>     public NotenErfassenDataModel(Map<Gegenstand,List<GueltigeNoten>>
> gegenstaende,List<NotenErfassenStandardRow> rows){
>         this.rowIndex = -1;
>         this.gegenstaende = gegenstaende;
>         this.rows = rows;
>
>         this.columns = new ArrayList<NotenErfassenColumn>();
>         for(Gegenstand geg : this.gegenstaende.keySet()){
>             this.columns.add(new NotenErfassenColumn(geg,this));
>         }
>     }
>
>     public List<NotenErfassenColumn> getColumns(){
>         return this.columns;
>     }
>
>     public List<NotenErfassenStandardRow> getRows() {
>         return this.rows;
>     }
>
>    public String getValue(){
>         // get the current row object from the DataModel and get the value
> for this column (via this.gegenstand) from the row object
>         return
> ((NotenErfassenStandardRow)this.model.getRowData()).getColumnValue(this.gegenstand);
>     }
>
>    // removed for clarity
>
> }
>
> The column implementation:
> public class NotenErfassenColumn implements Serializable{
>
>     private Gegenstand gegenstand;
>     private NotenErfassenDataModel model;
>
>     public NotenErfassenColumn(Gegenstand gegenstand,
> NotenErfassenDataModel model) {
>         super();
>         this.gegenstand = gegenstand;
>         this.model = model;
>     }
>
>   // cut for clarity
>
> }
>
> So to sum this up a bit, I have a DataModel implementation that consists of
> row objects and column objects. The row objects contain the data for all
> rows. The column objects are used to identify the different columns (in my
> example via the class Gegenstand as a "column identifier") and they also
> hold a reference back to the DataModel. So if I want to get the value for a
> specific column in a specific row I use the reference to the DataModel in
> the column object to get the current row object and then I use my "column
> identifier" Gegenstand to get the value for the column from the row object.
>
> I hope this helps to understand how t:columns works.
>
> Regards,
> Jakob
>
> 2010/2/28 Andrea Paternesi <[email protected]>
>
>
>> Hi all,
>>
>> is there someone who can share with me the backbean code to use the
>> tomahawk <t:columns> tag?
>> when we have variable columns to display?
>> We can assume the columns are read into an arraylist or from database as
>> well.
>> I found the crossDataTable example but it is not clear enought a more is
>> is not complete and does not compile.
>> i would like to have a very basic and simpe example.
>> Thanks in advance.
>>
>> Andrea.
>>
>> _________________________________________________________________
>> Parla, scrivi, gioca... Scopri le novità di Messenger
>> http://www.messenger.it/home_novita.aspx
>
>
>

Reply via email to