On 3/31/06, fischman_98 <[EMAIL PROTECTED]> 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.