You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by fischman_98 <mf...@powerconsultantsinc.com> on 2006/04/01 00:05:16 UTC

Re: n x n dataTable (myFaces)

Thanks for the help.

So for this solution, I am locking in the three columns and go back to using
t:column (no s)....is that right?

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?
--
View this message in context: http://www.nabble.com/n-x-n-dataTable-%28myFaces%29-t1365618.html#a3697622
Sent from the MyFaces - Users forum at Nabble.com.


Re: n x n dataTable (myFaces)

Posted by Mike Kienenberger <mk...@gmail.com>.
On 3/31/06, fischman_98 <mf...@powerconsultantsinc.com> 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 =
rowAndColumnRelationshipData.getValueFor(rowItem.getObject(),
columnItem.getObject());
        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 =
rowAndColumnRelationshipData.getValueFor(rowItem.getObject(),
columnItem.getObject());

        if (oldValue == newValue)  return;

        rowAndColumnRelationshipData.setValueFor(newValue,
rowItem.getObject(), columnItem.getObject());
    }


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

http://issues.apache.org/jira/secure/attachment/12311217/RowAndColumnRelationshipComponent.zip

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.