myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Kienenberger" <>
Subject Re: n x n dataTable (myFaces)
Date Wed, 05 Apr 2006 01:08:44 GMT
On 3/31/06, fischman_98 <> wrote:
> Was trying to make it dymamic for the future, but can't figure out how to
> make the row and column data work in conjunction with one another.  Need to
> somehow iterate through row objects that contain lists of column objects.
> if the var in the t:table could be related to in the t:columns, that would
> work.  Anyhow...any other thoughts on the topic?

Sure, that's possible.   dataTable contains a list of rows.  
t:columns contains a list of columns.   All you have to do is to
implement a getter/setter for your displayed item that reads the
current value of each list and does the right thing.  For example, a
table containing an n x m set of boolean values can be implemented
like this.

    // Call end-user model's getValueFor() method.
    public Boolean getRelationshipValue()
        RowItem rowItem = (RowItem) rowDataModel.getRowData();
        ColumnItem columnItem = (ColumnItem) columnDataModel.getRowData();
        boolean value =
        return Boolean.valueOf(value);

    // Call end-user model's setValueFor() method if data has changed.
    public void setRelationshipValue(Boolean newValueBoolean)
        boolean newValue = newValueBoolean.booleanValue();

        RowItem rowItem = (RowItem) rowDataModel.getRowData();
        ColumnItem columnItem = (ColumnItem) columnDataModel.getRowData();
        boolean oldValue =

        if (oldValue == newValue)  return;

rowItem.getObject(), columnItem.getObject());

You can find a early version of something using this code here:

However, I would not try to use any of the dynamic custom component
code.  It hasn't been touched since I moved to facelets.   Just use
t:dataTable and t:columns tags directly.

The RowAndColumnRelationshipsDataModel interface and
RowAndColumnRelationshipsBackingBean class demonstrate one clean way
to manage an n x n dataTable/columns combination.   I don't think I've
changed these classes significantly since I posted them last July.

View raw message