You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2006/11/15 12:10:19 UTC
svn commit: r475201 - in /myfaces/tobago/trunk:
core/src/main/java/org/apache/myfaces/tobago/component/
core/src/main/java/org/apache/myfaces/tobago/taglib/component/
core/src/main/java/org/apache/myfaces/tobago/taglib/decl/
theme/scarborough/src/main/...
Author: lofwyr
Date: Wed Nov 15 03:10:18 2006
New Revision: 475201
URL: http://svn.apache.org/viewvc?view=rev&rev=475201
Log:
woring on TOBAGO-18
Modified:
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UITreeNode.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UITreeNodes.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeNodesTag.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeNodesTagDeclaration.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/HasVar.java
myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java
myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodesRenderer.java
myfaces/tobago/trunk/tobago-tool/gendoc/src/main/webapp/screenshot/tree.jsp
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UITreeNode.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UITreeNode.java?view=diff&rev=475201&r1=475200&r2=475201
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UITreeNode.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UITreeNode.java Wed Nov 15 03:10:18 2006
@@ -80,7 +80,10 @@
public Object getValue() {
TreeNode value = null;
- UITree root = findTreeRoot();
+ UITreeNodes root = findTreeNodesRoot();
+ if (root == null) {
+ return null;
+ }
String subReference = getSubReference();
if (LOG.isDebugEnabled()) {
LOG.debug("root = '" + root + "'");
@@ -160,7 +163,7 @@
@SuppressWarnings("unchecked")
private Object getReference(TreeNode treeNode, String key) {
Object value = null;
- UITree root = findTreeRoot();
+ UITreeNodes root = findTreeNodesRoot();
String reference = (String) root.getAttributes().get(key);
if (reference != null) {
try {
@@ -182,11 +185,23 @@
public UITree findTreeRoot() {
UIComponent ancestor = getParent();
- while (ancestor != null && ancestor instanceof UITreeNode) {
+ while (ancestor != null
+ && (ancestor instanceof UITreeNode || ancestor instanceof UITreeNodes)) {
ancestor = ancestor.getParent();
}
if (ancestor instanceof UITree) {
return (UITree) ancestor;
+ }
+ return null;
+ }
+
+ public UITreeNodes findTreeNodesRoot() {
+ UIComponent ancestor = getParent();
+ while (ancestor != null && ancestor instanceof UITreeNode) {
+ ancestor = ancestor.getParent();
+ }
+ if (ancestor instanceof UITreeNodes) {
+ return (UITreeNodes) ancestor;
}
return null;
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UITreeNodes.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UITreeNodes.java?view=diff&rev=475201&r1=475200&r2=475201
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UITreeNodes.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UITreeNodes.java Wed Nov 15 03:10:18 2006
@@ -20,7 +20,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.swing.tree.TreeNode;
@@ -33,6 +32,9 @@
public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.TreeNodes";
+ private String var;
+
+/*
public void encodeBegin(FacesContext facesContext)
throws IOException {
recreateTreeNodes();
@@ -65,6 +67,7 @@
LOG.error(e, e);
}
}
+*/
public UITreeNode getRoot() {
// find the UITreeNode in the childen.
@@ -122,4 +125,21 @@
// TODO: updateing the model here and *NOT* in the decode phase
}
+ public UITreeNode getTemplateComponent() {
+ for (Object child : getChildren()) {
+ if (child instanceof UITreeNode) {
+ return (UITreeNode) child;
+ }
+ }
+ return null;
+ }
+
+
+ public String getVar() {
+ return var;
+ }
+
+ public void setVar(String var) {
+ this.var = var;
+ }
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeNodesTag.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeNodesTag.java?view=diff&rev=475201&r1=475200&r2=475201
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeNodesTag.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeNodesTag.java Wed Nov 15 03:10:18 2006
@@ -17,21 +17,17 @@
* limitations under the License.
*/
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.myfaces.tobago.component.UITree;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_VALUE;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_VAR;
import org.apache.myfaces.tobago.component.ComponentUtil;
import org.apache.myfaces.tobago.component.UITreeNodes;
-import org.apache.myfaces.tobago.TobagoConstants;
import javax.faces.component.UIComponent;
-import javax.faces.component.ActionSource;
public class TreeNodesTag extends TobagoTag implements TreeNodesTagDeclaration {
- private static final Log LOG = LogFactory.getLog(TreeNodesTag.class);
-
private String value;
+ private String var;
public String getComponentType() {
return UITreeNodes.COMPONENT_TYPE;
@@ -40,12 +36,14 @@
protected void setProperties(UIComponent component) {
super.setProperties(component);
- ComponentUtil.setStringProperty(component, TobagoConstants.ATTR_VALUE, value);
+ ComponentUtil.setStringProperty(component, ATTR_VALUE, value);
+ ComponentUtil.setStringProperty(component, ATTR_VAR, var);
}
public void release() {
super.release();
value = null;
+ var = null;
}
public String getValue() {
@@ -56,4 +54,11 @@
this.value = value;
}
+ public String getVar() {
+ return var;
+ }
+
+ public void setVar(String var) {
+ this.var = var;
+ }
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeNodesTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeNodesTagDeclaration.java?view=diff&rev=475201&r1=475200&r2=475201
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeNodesTagDeclaration.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeNodesTagDeclaration.java Wed Nov 15 03:10:18 2006
@@ -17,19 +17,13 @@
* limitations under the License.
*/
-import org.apache.myfaces.tobago.apt.annotation.Tag;
import org.apache.myfaces.tobago.apt.annotation.BodyContentDescription;
import org.apache.myfaces.tobago.apt.annotation.Preliminary;
+import org.apache.myfaces.tobago.apt.annotation.Tag;
import org.apache.myfaces.tobago.apt.annotation.UIComponentTag;
-import org.apache.myfaces.tobago.apt.annotation.TagAttribute;
-import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
import org.apache.myfaces.tobago.taglib.decl.HasIdBindingAndRendered;
import org.apache.myfaces.tobago.taglib.decl.HasTreeNodeValue;
-import org.apache.myfaces.tobago.taglib.decl.HasState;
-import org.apache.myfaces.tobago.taglib.decl.HasIdReference;
-import org.apache.myfaces.tobago.taglib.decl.HasActionListener;
-import org.apache.myfaces.tobago.taglib.decl.HasNameReference;
-import org.apache.myfaces.tobago.taglib.decl.IsRequired;
+import org.apache.myfaces.tobago.taglib.decl.HasVar;
/**
* Describes a subtree of nodes.
@@ -42,6 +36,6 @@
uiComponent = "org.apache.myfaces.tobago.component.UITreeNodes",
rendererType = "TreeNodes")
public interface TreeNodesTagDeclaration extends TobagoTagDeclaration,
- HasIdBindingAndRendered, HasTreeNodeValue {
+ HasIdBindingAndRendered, HasTreeNodeValue, HasVar {
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/HasVar.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/HasVar.java?view=diff&rev=475201&r1=475200&r2=475201
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/HasVar.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/HasVar.java Wed Nov 15 03:10:18 2006
@@ -24,12 +24,10 @@
* $Id$
*/
public interface HasVar {
+
/**
- *
- * Name of a request-scope attribute under which the model data for the row
- * selected by the current value of the "rowIndex" property
- * (i.e. also the current value of the "rowData" property) will be exposed.
- *
+ * Name of a request-scope attribute under which the model data for
+ * for each subobject is accessible.
*/
@TagAttribute(required = true)
@UIComponentTagAttribute()
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java?view=diff&rev=475201&r1=475200&r2=475201
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java Wed Nov 15 03:10:18 2006
@@ -32,6 +32,7 @@
import org.apache.myfaces.tobago.component.ComponentUtil;
import org.apache.myfaces.tobago.component.UITree;
import org.apache.myfaces.tobago.component.UITreeNode;
+import org.apache.myfaces.tobago.component.UITreeNodes;
import org.apache.myfaces.tobago.model.TreeState;
import org.apache.myfaces.tobago.renderkit.RendererBase;
@@ -158,6 +159,8 @@
String parentClientId = null;
if (parent != null && parent instanceof UITreeNode) { // if not the root node
parentClientId = treeNode.getParent().getClientId(facesContext);
+ } else if (parent != null && parent instanceof UITreeNodes) {
+ parentClientId = treeNode.getParent().getParent().getClientId(facesContext);
}
UITree root = treeNode.findTreeRoot();
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodesRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodesRenderer.java?view=diff&rev=475201&r1=475200&r2=475201
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodesRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodesRenderer.java Wed Nov 15 03:10:18 2006
@@ -18,13 +18,21 @@
*/
import org.apache.myfaces.tobago.renderkit.RendererBase;
+import org.apache.myfaces.tobago.component.UITreeNodes;
+import org.apache.myfaces.tobago.component.UITreeNode;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import javax.swing.tree.DefaultMutableTreeNode;
import java.io.IOException;
+import java.util.Enumeration;
public class TreeNodesRenderer extends RendererBase {
+ private static final Log LOG = LogFactory.getLog(TreeNodesRenderer.class);
+
@Override
public void decode(FacesContext facesContext, UIComponent component) {
}
@@ -32,6 +40,26 @@
@Override
public void encodeEnd(FacesContext facesContext,
UIComponent component) throws IOException {
- }
+ UITreeNodes nodes = (UITreeNodes) component;
+ String var = nodes.getVar();
+
+ DefaultMutableTreeNode tree = (DefaultMutableTreeNode) nodes.getValue();
+
+ for (Enumeration e = tree.depthFirstEnumeration(); e.hasMoreElements(); ) {
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.nextElement();
+
+ if (node == null) { // XXX hotfix
+ LOG.warn("node is null");
+ continue;
+ }
+ // todo put into var (request context)
+ facesContext.getExternalContext().getRequestMap().put(var, node);
+ UITreeNode template = nodes.getTemplateComponent();
+ template.encodeBegin(facesContext);
+ template.encodeChildren(facesContext);
+ template.encodeEnd(facesContext);
+ facesContext.getExternalContext().getRequestMap().remove(var);
+ }
+ }
}
Modified: myfaces/tobago/trunk/tobago-tool/gendoc/src/main/webapp/screenshot/tree.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/gendoc/src/main/webapp/screenshot/tree.jsp?view=diff&rev=475201&r1=475200&r2=475201
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/gendoc/src/main/webapp/screenshot/tree.jsp (original)
+++ myfaces/tobago/trunk/tobago-tool/gendoc/src/main/webapp/screenshot/tree.jsp Wed Nov 15 03:10:18 2006
@@ -59,6 +59,9 @@
<%--<tc:gridLayout rows="300px;1*" />--%>
<tc:gridLayout rows="200px;300px;1*" />
</f:facet>
+
+ <tc:out value="Under construction"/>
+
<tc:tree state="#{treeState}" id="screenshotTree"
idReference="userObject"
nameReference="userObject"
@@ -69,7 +72,9 @@
selectable="single"
mutable="false">
<tc:treeNode label="Root">
- <tc:treeNodes value="#{tree}"/>
+ <tc:treeNodes value="#{tree}" var="node">
+ <tc:treeNode label="#{node.userObject}"/>
+ </tc:treeNodes>
<tc:treeNode label="Sub 1"/>
<tc:treeNode label="Sub 2"/>
<tc:treeNode label="Sub 3">
@@ -91,7 +96,6 @@
mode="menu"
/>
--%>
- <tc:out value="Under construction"/>
<tc:cell/>