Hi,

i have a strange behaviour with the treeTable and the disclosedRowKeys.
In detail i want to expand specific nodes programaticaly and this should
be the initial state of the treeTable. This works fine for the first
render time. Now the trouble: In the action facet i have a commandLink
that should reset the nodes to the initial state. All that i can see is
that the treeTable is completely collapsed after you have clicked the
commandLink. If you force a refresh in the browser the initial state is
displayed again. In the other hand if you expand the nodes manually and
force a refresh in the browser the same state of the nodes are
displayed. In other words it is no request scope problem. For better
understanding i will provide some code snippets:

<!-- faces-config -->
    <managed-bean>
        <managed-bean-name>activityInstanceDetails</managed-bean-name>
        <managed-bean-class>
            local.jsf.beans.ActivityInstanceDetailsBean
        </managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
<!-- end faces-config -->

<!-- treeTable page -->
<tr:treeTable
disclosedRowKeys="#{activityInstanceDetails.disclosedRowKeys}"
  value="#{activityInstanceDetails.dataModel}" var="row"
id="activityTree"
 
rowDisclosureListener="#{activityInstanceDetails.rowDisclosureListener}"
  partialTriggers=":activityTree:collapseUninterested">
  <f:facet name="actions">
    <tr:commandLink text="Expand only current activity path"
id="collapseUninterested"
       action="#{activityInstanceDetails.resetDisclosedRowKeys}"
       partialSubmit="true" immediate="true"/>
    </f:facet>
    <f:facet name="nodeStamp">
      <tr:column noWrap="true">
        <f:facet name="header">
          <tr:outputText value="#{bundle.name}"/>
        </f:facet>
        <tr:outputText value="#{row.runtimeObject.activity.name}"
          inlineStyle="font-weight:bold" />
      </tr:column>
    </f:facet>
<!-- end treeTable page -->

<!-- activityInstanceDetails -->
public class ActivityInstanceDetailsBean {
  private RowKeySet disclosedEntries;
  private TreeModel dataModel;

  public ActivityInstanceDetailsBean()
  {
    SessionContext ctx = SessionContext.findSessionContext();
    disclosedEntries = (RowKeySet)ctx.lookup(DISCLOSED_ENTRIES);
    dataModel = (TreeModel)ctx.lookup(DATA_MODEL);
  }

  public TreeModel getDataModel()
  {
    return dataModel;
  }

  private RowKeySet getInitialDisclosedRowKeys()
  {
    RowKeySet disclosedEntries = new RowKeySetTreeImpl();
    TreeModel treeModel = getDataModel();
    disclosedEntries.setCollectionModel(treeModel);
    if (treeModel != null && treeModel.getRowCount() > 0) {
       setActivityInstancePath(disclosedEntries, treeModel,
getActivityInstance());
    }
    return disclosedEntries;
  }
    
  public RowKeySet getDisclosedRowKeys() 
  {
    if (disclosedEntries == null) {
      disclosedEntries = getInitialDisclosedRowKeys();
      SessionContext.findSessionContext().bind(
        DISCLOSED_ENTRIES, disclosedEntries);
    }
    return disclosedEntries;
  }

  public void setDisclosedRowKeys(RowKeySet disclosedEntries) {
    this.disclosedEntries = disclosedEntries;
    SessionContext.findSessionContext().bind(DISCLOSED_ENTRIES,
disclosedEntries);
  }
    
  public void resetDisclosedRowKeys() {
    setDisclosedRowKeys(getInitialDisclosedRowKeys());
  }
    
  public void rowDisclosureListener(RowDisclosureEvent event)
  {
    RowKeySet added = event.getAddedSet();
    RowKeySet removed = event.getRemovedSet();
    if(disclosedEntries == null)
    {
      disclosedEntries = added;
    }
    else
    {
      if(!added.isEmpty())
      {
        disclosedEntries.addAll(added);
      }
      if(!removed.isEmpty())
      {
        disclosedEntries.removeAll(removed);
      }
    }
  }
}
<!-- end activityInstanceDetails -->

Hope that anybody can help me to solve this problem.

Regars,

Sven

Reply via email to