You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Andrea Paternesi <pa...@hotmail.it> on 2010/02/28 12:40:04 UTC

[TOMAHAWK] usage backbean example

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

Re: [TOMAHAWK] usage backbean example

Posted by Jakob Korherr <ja...@gmail.com>.
You're welcome!

Of course, here's the snippet:

public class NotenErfassenStandardRow implements Serializable,
NotenErfassenRow{

    private Schueler schueler;
    private Map<Gegenstand,GueltigeNoten> noten;

    public NotenErfassenStandardRow(Schueler schueler,
            Map<Gegenstand,GueltigeNoten> noten) {
        super();
        this.schueler = schueler;
        this.noten = noten;
    }

    public GueltigeNoten getColumnValue(Gegenstand geg){
        return this.noten.get(geg);
    }

    // cut for clarity
}

Hope this helps!

Regards,
Jakob

2010/3/1 Andrea Paternesi <pa...@hotmail.it>

>
> Hi thanks for the snippets.
> Can i ask you to post also the NotenErfassenStandardRow snippet?
> I am trying to figure out the minimal code needed to implement a base
> skeleton.
>
> Thank you anyay for you help.
> This is much appreciated.
>
>
> Regards.
> Andrea.
>
> _________________________________________________________________
> Tutto lo spazio che ti serve, lo trovi su Hotmail
> http://www.windowslive.it/hotmail/SpazioDisponibile.aspx
>

RE: [TOMAHAWK] usage backbean example

Posted by Andrea Paternesi <pa...@hotmail.it>.
Hi thanks for the snippets.
Can i ask you to post also the NotenErfassenStandardRow snippet?
I am trying to figure out the minimal code needed to implement a base skeleton.

Thank you anyay for you help.
This is much appreciated.


Regards.
Andrea.
 		 	   		  
_________________________________________________________________
Tutto lo spazio che ti serve, lo trovi su Hotmail
http://www.windowslive.it/hotmail/SpazioDisponibile.aspx

Re: [TOMAHAWK] usage backbean example

Posted by Jakob Korherr <ja...@gmail.com>.
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 <ja...@gmail.com>

> 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 <pa...@hotmail.it>
>
>
>> 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
>
>
>

Re: [TOMAHAWK] usage backbean example

Posted by Jakob Korherr <ja...@gmail.com>.
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 <pa...@hotmail.it>

>
> 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