[richfaces-issues] [JBoss JIRA] Created: (RF-7616) UITree does not accept datamodel as value

John Leed (JIRA) jira-events at lists.jboss.org
Tue Jul 28 15:28:29 EDT 2009


UITree does not accept datamodel as value
-----------------------------------------

                 Key: RF-7616
                 URL: https://jira.jboss.org/jira/browse/RF-7616
             Project: RichFaces
          Issue Type: Bug
          Components: component-tree
    Affects Versions: 3.3.1
            Reporter: John Leed


UIData accepts both data or a datamodel as its value, in the former case wrapping the data in a datamodel. As a subclass of UIData, UITree should behave the same way. Instead, if the value is set to a TreeDataModel, UITree tries wrapping it in a swingTreeDataModel. This presents a problem if a custom data model is desired.

Proposed fix:

protected ExtendedDataModel createDataModel() {
	Object value = this.getValue();
	if (value != null) {
		if (value instanceof TreeDataModel {
			return value;
		}
		else if (value instanceof TreeNode) {
			TreeDataModel<TreeNode> treeDataModel = new ClassicTreeDataModel();
			treeDataModel.setWrappedData(value);
				
			if (this.allowCachedModel && PRESERVE_MODEL_REQUEST.equals(getPreserveModel())) {
				treeDataModel = new ClassicCacheableTreeDataModel(treeDataModel);
			}

			return treeDataModel;
		} else {
			TreeDataModel<javax.swing.tree.TreeNode> swingTreeDataModel = new SwingTreeDataModel();
			swingTreeDataModel.setWrappedData(value);
			
			if (this.allowCachedModel && PRESERVE_MODEL_REQUEST.equals(getPreserveModel())) {
				swingTreeDataModel = new SwingCacheableTreeDataModel(swingTreeDataModel);
			}
			return swingTreeDataModel;
		}
	} else {
		//TODO implement request caching
		StackingTreeModel stackingTreeModel = new VisualStackingTreeModel(null);
		if (getChildCount() > 0) {
			Iterator children = getChildren().iterator();
			while (children.hasNext()) {
				UIComponent component = (UIComponent) children.next();
				if (component instanceof StackingTreeModelProvider) {
					StackingTreeModelProvider provider = (StackingTreeModelProvider) component;
				stackingTreeModel.addStackingModel(provider.getStackingModel());
				}
			}
		}
		
		return stackingTreeModel;
	}
}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the richfaces-issues mailing list