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 2012/03/06 12:49:18 UTC
svn commit: r1297434 - in /myfaces/tobago/branches/tobago-tree-table:
tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/
tobago-example/tobago-example-test/src/main/webapp/tc/sheet/
tobago-theme/tobago-theme-scarborough/src/main/ja...
Author: lofwyr
Date: Tue Mar 6 11:49:17 2012
New Revision: 1297434
URL: http://svn.apache.org/viewvc?rev=1297434&view=rev
Log:
TOBAGO-1049: Tree inside of the Sheet (aka TreeTable)
- expanded field for a tree in a sheet
Modified:
myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIData.java
myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-tree.xhtml
myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-tree.js
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIData.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIData.java?rev=1297434&r1=1297433&r2=1297434&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIData.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIData.java Tue Mar 6 11:49:17 2012
@@ -54,8 +54,23 @@ public abstract class AbstractUIData ext
@Deprecated
private List<Integer> submittedExpanded;
+ public boolean isTreeModel() {
+ init();
+ return dataModel != null;
+ }
+
@Override
protected DataModel getDataModel() {
+ init();
+
+ if (dataModel != null) {
+ return dataModel;
+ } else {
+ return super.getDataModel();
+ }
+ }
+
+ private void init() {
if (!initialized) {
Object value = getValue();
boolean showRoot = isShowRoot();
@@ -64,12 +79,6 @@ public abstract class AbstractUIData ext
}
initialized = true;
}
-
- if (dataModel != null) {
- return dataModel;
- } else {
- return super.getDataModel();
- }
}
public boolean hasRows() {
@@ -77,6 +86,7 @@ public abstract class AbstractUIData ext
}
public boolean isRowVisible() {
+ init();
if (dataModel != null) {
return dataModel.isRowVisible();
} else {
@@ -85,10 +95,12 @@ public abstract class AbstractUIData ext
}
public String getRowClientId() {
+ init();
return dataModel != null ? dataModel.getRowClientId() : null;
}
public String getRowParentClientId() {
+ init();
return dataModel != null ? dataModel.getRowParentClientId() : null;
}
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-tree.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-tree.xhtml?rev=1297434&r1=1297433&r2=1297434&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-tree.xhtml (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-tree.xhtml Tue Mar 6 11:49:17 2012
@@ -23,9 +23,12 @@
xmlns:f="http://java.sun.com/jsf/core">
<tc:page id="page">
- <tc:gridLayoutConstraint width="1200px" height="1205px"/>
+ <tc:gridLayoutConstraint width="900px" height="500px"/>
+ <f:facet name="layout">
+ <tc:gridLayout rows="*;auto"/>
+ </f:facet>
- <tc:sheet value="#{tree.tree}" id="row" columns="*;*" var="row" rows="14">
+ <tc:sheet value="#{tree.tree}" id="row" columns="*;*" var="row">
<tc:column label="Tree" id="tree">
<tc:treeNode expanded="#{row.level le 1}">
@@ -44,15 +47,14 @@
</tc:sheet>
-<!--
- <tc:tree showRoot="true" value="#{tree.tree}" var="row">
-
- <tc:treeNode expanded="true">
- <tc:treeIndent/>
- <tc:treeLabel value="#{row.userObject.name}"/>
- </tc:treeNode>
- </tc:tree>
--->
+ <tc:panel>
+ <f:facet name="layout">
+ <tc:gridLayout columns="*;auto"/>
+ </f:facet>
+
+ <tc:panel/>
+ <tc:button label="Submit" id="submit"/>
+ </tc:panel>
</tc:page>
</f:view>
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java?rev=1297434&r1=1297433&r2=1297434&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java Tue Mar 6 11:49:17 2012
@@ -36,6 +36,8 @@ import org.apache.myfaces.tobago.context
import org.apache.myfaces.tobago.context.ResourceManager;
import org.apache.myfaces.tobago.context.ResourceManagerUtils;
import org.apache.myfaces.tobago.event.PageAction;
+import org.apache.myfaces.tobago.internal.component.AbstractUIData;
+import org.apache.myfaces.tobago.internal.component.AbstractUITree;
import org.apache.myfaces.tobago.internal.context.ResourceManagerFactory;
import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
import org.apache.myfaces.tobago.internal.util.StringUtils;
@@ -212,6 +214,19 @@ public class SheetRenderer extends Layou
writer.endElement(HtmlElements.INPUT);
}
+ if (sheet.isTreeModel()) {
+ writer.startElement(HtmlElements.INPUT, sheet);
+ writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.HIDDEN, false);
+ final String expandedId = sheetId + ComponentUtils.SUB_SEPARATOR + AbstractUITree.SUFFIX_EXPANDED;
+ writer.writeNameAttribute(expandedId);
+ writer.writeIdAttribute(expandedId);
+ writer.writeClassAttribute(Classes.create(sheet, AbstractUITree.SUFFIX_EXPANDED));
+ final List<Integer> value = sheet.getSubmittedExpanded();
+ writer.writeAttribute(
+ HtmlAttributes.VALUE, value != null ? StringUtils.joinWithSurroundingSeparator(value) : "", false);
+ writer.endElement(HtmlElements.INPUT);
+ }
+
final boolean showHeader = sheet.isShowHeader();
final boolean ie6SelectOneFix = showHeader
&& ClientProperties.getInstance(facesContext).getUserAgent().isMsie6()
@@ -554,17 +569,19 @@ public class SheetRenderer extends Layou
public void decode(FacesContext facesContext, UIComponent component) {
super.decode(facesContext, component);
- String key = component.getClientId(facesContext) + WIDTHS_POSTFIX;
+ UISheet sheet = (UISheet) component;
+
+ String key = sheet.getClientId(facesContext) + WIDTHS_POSTFIX;
Map requestParameterMap = facesContext.getExternalContext().getRequestParameterMap();
if (requestParameterMap.containsKey(key)) {
String widths = (String) requestParameterMap.get(key);
if (widths.trim().length() > 0) {
- component.getAttributes().put(Attributes.WIDTH_LIST_STRING, widths);
+ sheet.getAttributes().put(Attributes.WIDTH_LIST_STRING, widths);
}
}
- key = component.getClientId(facesContext) + SELECTED_POSTFIX;
+ key = sheet.getClientId(facesContext) + SELECTED_POSTFIX;
if (requestParameterMap.containsKey(key)) {
String selected = (String) requestParameterMap.get(key);
if (LOG.isDebugEnabled()) {
@@ -578,19 +595,30 @@ public class SheetRenderer extends Layou
selectedRows = Collections.emptyList();
}
- component.getAttributes().put(Attributes.SELECTED_LIST_STRING, selectedRows);
+ sheet.getAttributes().put(Attributes.SELECTED_LIST_STRING, selectedRows);
}
- key = component.getClientId(facesContext) + SCROLL_POSTFIX;
+ key = sheet.getClientId(facesContext) + SCROLL_POSTFIX;
String value = (String) requestParameterMap.get(key);
if (value != null) {
Integer[] scrollPosition = SheetState.parseScrollPosition(value);
if (scrollPosition != null) {
//noinspection unchecked
- component.getAttributes().put(Attributes.SCROLL_POSITION, scrollPosition);
+ sheet.getAttributes().put(Attributes.SCROLL_POSITION, scrollPosition);
}
}
+ if (sheet.isTreeModel()) {
+ // expanded
+ String expanded = (String) facesContext.getExternalContext().getRequestParameterMap()
+ .get(sheet.getClientId(facesContext) + ComponentUtils.SUB_SEPARATOR + AbstractUIData.SUFFIX_EXPANDED);
+ try {
+ sheet.setSubmittedExpanded(expanded != null ? StringUtils.parseIntegerList(expanded) : null);
+ } catch (NumberFormatException e) {
+ // should not happen
+ LOG.warn("Can't parse expanded: + " + expanded + "'", e);
+ }
+ }
}
private Measure getHeaderHeight(FacesContext facesContext, UISheet sheet) {
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-tree.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-tree.js?rev=1297434&r1=1297433&r2=1297434&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-tree.js (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-tree.js Tue Mar 6 11:49:17 2012
@@ -20,8 +20,9 @@ Tobago.Tree = {};
Tobago.Tree.toggleNode = function(element) {
var src;
var node = element.closest(".tobago-treeNode, .tobago-treeMenuNode");
- var expanded
- = node.closest(".tobago-treeMenu, .tobago-tree").children(".tobago-treeMenu-expanded, .tobago-tree-expanded");
+ var expanded = node
+ .closest(".tobago-treeMenu, .tobago-tree, .tobago-sheet-outer")
+ .children(".tobago-treeMenu-expanded, .tobago-tree-expanded, .tobago-sheet-expanded");
var toggle = node.find(".tobago-treeMenuNode-toggle, .tobago-treeNode-toggle");
var rowIndex = Tobago.Tree.rowIndex(node);
if (Tobago.Tree.isExpanded(node, expanded)) {
@@ -180,8 +181,8 @@ Tobago.Tree.init = function(elements) {
});
// init expanded field
- Tobago.Utils.selectWidthJQuery(elements, ".tobago-treeMenu, .tobago-tree").each(function() {
- var expanded = jQuery(this).children(".tobago-treeMenu-expanded, .tobago-tree-expanded");
+ Tobago.Utils.selectWidthJQuery(elements, ".tobago-treeMenu, .tobago-tree, .tobago-sheet").each(function() {
+ var expanded = jQuery(this).children(".tobago-treeMenu-expanded, .tobago-tree-expanded, .tobago-sheet-expanded");
var string = ",";
jQuery(this).children(".tobago-treeMenuNode-markup-expanded, .tobago-treeNode-markup-expanded").each(function() {
string += Tobago.Tree.rowIndex(jQuery(this)) + ",";