JBoss Rich Faces SVN: r20373 - in trunk/ui/output/ui/src/main: java/org/richfaces/renderkit/html and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-12-03 12:21:42 -0500 (Fri, 03 Dec 2010)
New Revision: 20373
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractToolbar.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolbarGroupRenderer.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolbarRendererBase.java
trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml
trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml
Log:
add itemClass, itemStyle attributes RF-9883
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractToolbar.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractToolbar.java 2010-12-03 17:10:51 UTC (rev 20372)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractToolbar.java 2010-12-03 17:21:42 UTC (rev 20373)
@@ -47,6 +47,12 @@
public abstract String getWidth();
@Attribute
+ public abstract String getItemClass();
+
+ @Attribute
+ public abstract String getItemStyle();
+
+ @Attribute
public abstract String getItemSeparator();
@Attribute(events=@EventName("itemclick"))
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolbarGroupRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolbarGroupRenderer.java 2010-12-03 17:10:51 UTC (rev 20372)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolbarGroupRenderer.java 2010-12-03 17:21:42 UTC (rev 20373)
@@ -74,9 +74,9 @@
private void writeStyleValue(AbstractToolbarGroup toolbarGroup, ResponseWriter writer) throws IOException {
String style = getStringAttribute(toolbarGroup, HtmlConstants.STYLE_ATTRIBUTE);
- String contentStyle = getStringAttribute(getParentToolBar(toolbarGroup), "contentStyle");
+ String itemStyle = getStringAttribute(getParentToolBar(toolbarGroup), "itemStyle");
- String value = concatStyles(contentStyle, style);
+ String value = concatStyles(itemStyle, style);
if (isPropertyRendered(value)) {
writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, value, null);
@@ -86,13 +86,13 @@
private void writeClassValue(AbstractToolbarGroup toolbarGroup, ResponseWriter writer) throws IOException {
String styleClass = getStringAttribute(toolbarGroup, HtmlConstants.STYLE_CLASS_ATTR);
AbstractToolbar toolbar = getParentToolBar(toolbarGroup);
- String contentClass = null;
+ String itemClass = null;
if(toolbar != null) {
- contentClass = getStringAttribute(toolbar, "contentClass");
+ itemClass = getStringAttribute(toolbar, "itemClass");
}
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, concatClasses("rf-tb-itm", contentClass, styleClass), null);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, concatClasses("rf-tb-itm", itemClass, styleClass), null);
}
private String getStringAttribute(UIComponent toolbarGroup, String attribute) {
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolbarRendererBase.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolbarRendererBase.java 2010-12-03 17:10:51 UTC (rev 20372)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolbarRendererBase.java 2010-12-03 17:21:42 UTC (rev 20373)
@@ -92,8 +92,8 @@
@Override
public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
AbstractToolbar toolbar = (AbstractToolbar) component;
- String contentClass = (String) toolbar.getAttributes().get("contentClass");
- String contentStyle = (String) toolbar.getAttributes().get("contentStyle");
+ String itemClass = (String) toolbar.getAttributes().get("itemClass");
+ String itemStyle = (String) toolbar.getAttributes().get("itemStyle");
List<UIComponent> children = toolbar.getChildren();
@@ -123,9 +123,9 @@
if (!(child instanceof AbstractToolbarGroup)) {
writer.startElement(HtmlConstants.TD_ELEM, component);
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, concatClasses("rf-tb-itm", contentClass), null);
- if (isPropertyRendered(contentStyle)) {
- writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, contentStyle, null);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, concatClasses("rf-tb-itm", itemClass), null);
+ if (isPropertyRendered(itemStyle)) {
+ writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, itemStyle, null);
}
encodeEventsAttributes(context, toolbar);
}
@@ -156,24 +156,7 @@
}
}
}
-
- public void encodeItem(FacesContext facesContext, UIComponent component, ResponseWriter writer, String contentStyle, String contentClass) throws IOException {
- if (!(component instanceof AbstractToolbarGroup)) {
- writer.startElement(HtmlConstants.TD_ELEM, component);
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, concatClasses("rf-tb-itm", contentClass), null);
- if (isPropertyRendered(contentStyle)) {
- writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, contentStyle, null);
- }
- encodeEventsAttributes(facesContext, component);
- }
-
- component.encodeAll(facesContext);
-
- if (!(component instanceof AbstractToolbarGroup)) {
- writer.endElement(HtmlConstants.TD_ELEM);
- }
- }
-
+
/**
* Inserts separator between toolbar items. Uses facet "itemSeparator" if it
* is set and default separator implementation if facet is not set.
Modified: trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml 2010-12-03 17:10:51 UTC (rev 20372)
+++ trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml 2010-12-03 17:21:42 UTC (rev 20373)
@@ -239,6 +239,30 @@
</property-extension>
</property>
<property>
+ <property-name>itemClass</property-name>
+ <property-class>java.lang.String</property-class>
+ <property-extension>
+ <cdk:generate>true</cdk:generate>
+ <cdk:hidden>false</cdk:hidden>
+ <cdk:literal>false</cdk:literal>
+ <cdk:pass-through>false</cdk:pass-through>
+ <cdk:read-only>false</cdk:read-only>
+ <cdk:required>false</cdk:required>
+ </property-extension>
+ </property>
+ <property>
+ <property-name>itemStyle</property-name>
+ <property-class>java.lang.String</property-class>
+ <property-extension>
+ <cdk:generate>true</cdk:generate>
+ <cdk:hidden>false</cdk:hidden>
+ <cdk:literal>false</cdk:literal>
+ <cdk:pass-through>false</cdk:pass-through>
+ <cdk:read-only>false</cdk:read-only>
+ <cdk:required>false</cdk:required>
+ </property-extension>
+ </property>
+ <property>
<property-name>onitemkeydown</property-name>
<property-class>java.lang.String</property-class>
<property-extension>
@@ -429,6 +453,30 @@
</property-extension>
</property>
<property>
+ <property-name>itemClass</property-name>
+ <property-class>java.lang.String</property-class>
+ <property-extension>
+ <cdk:generate>true</cdk:generate>
+ <cdk:hidden>false</cdk:hidden>
+ <cdk:literal>false</cdk:literal>
+ <cdk:pass-through>false</cdk:pass-through>
+ <cdk:read-only>false</cdk:read-only>
+ <cdk:required>false</cdk:required>
+ </property-extension>
+ </property>
+ <property>
+ <property-name>itemStyle</property-name>
+ <property-class>java.lang.String</property-class>
+ <property-extension>
+ <cdk:generate>true</cdk:generate>
+ <cdk:hidden>false</cdk:hidden>
+ <cdk:literal>false</cdk:literal>
+ <cdk:pass-through>false</cdk:pass-through>
+ <cdk:read-only>false</cdk:read-only>
+ <cdk:required>false</cdk:required>
+ </property-extension>
+ </property>
+ <property>
<description>
The number of child components associated with
this component.
Modified: trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml 2010-12-03 17:10:51 UTC (rev 20372)
+++ trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml 2010-12-03 17:21:42 UTC (rev 20373)
@@ -29,7 +29,15 @@
<name>id</name>
<type>java.lang.String</type>
</attribute>
+ <attribute>
+ <name>itemClass</name>
+ <type>java.lang.String</type>
+ </attribute>
<attribute>
+ <name>itemStyle</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
<name>itemSeparator</name>
<type>java.lang.String</type>
</attribute>
@@ -104,7 +112,15 @@
<name>id</name>
<type>java.lang.String</type>
</attribute>
+ <attribute>
+ <name>itemClass</name>
+ <type>java.lang.String</type>
+ </attribute>
<attribute>
+ <name>itemStyle</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
<name>itemSeparator</name>
<type>java.lang.String</type>
</attribute>
14 years, 1 month
JBoss Rich Faces SVN: r20372 - in trunk: examples/iteration-demo/src/main/webapp and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-12-03 12:10:51 -0500 (Fri, 03 Dec 2010)
New Revision: 20372
Modified:
trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeBean.java
trunk/examples/iteration-demo/src/main/webapp/tree.xhtml
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
Log:
https://jira.jboss.org/browse/RF-9719
Modified: trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeBean.java
===================================================================
--- trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeBean.java 2010-12-03 16:58:10 UTC (rev 20371)
+++ trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeBean.java 2010-12-03 17:10:51 UTC (rev 20372)
@@ -22,8 +22,10 @@
package org.richfaces.demo;
import java.io.Serializable;
+import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Date;
import java.util.List;
import javax.annotation.PostConstruct;
@@ -111,6 +113,8 @@
private String toggleNodeEvent = "";
+ private String executeTestText;
+
private static Object staticGetNodeData() {
FacesContext facesContext = FacesContext.getCurrentInstance();
return facesContext.getApplication().evaluateExpressionGet(facesContext, "#{node}", Object.class);
@@ -230,5 +234,15 @@
this.toggleNodeEvent = toggleNodeEvent;
}
+ public String getExecuteTestText() {
+ return executeTestText;
+ }
+
+ public void setExecuteTestText(String executeTestText) {
+ this.executeTestText = executeTestText;
+ }
+ public String getCurrentTimeAsString() {
+ return DateFormat.getTimeInstance().format(new Date());
+ }
}
Modified: trunk/examples/iteration-demo/src/main/webapp/tree.xhtml
===================================================================
--- trunk/examples/iteration-demo/src/main/webapp/tree.xhtml 2010-12-03 16:58:10 UTC (rev 20371)
+++ trunk/examples/iteration-demo/src/main/webapp/tree.xhtml 2010-12-03 17:10:51 UTC (rev 20372)
@@ -212,6 +212,38 @@
</it:treeNode>
</it:tree>
+ execute/render:
+ <h:panelGrid columns="2" id="executeRenderTreeGrid">
+ <it:tree var="node" value="#{treeBean.rootNodes}" execute="executeRenderTreeGrid" render="selectionIndicator"
+ selection="#{treeBean.selection}" selectionType="#{treeBean.selectionType}" toggleType="#{treeBean.toggleType}">
+ <it:treeNode>
+ #{node.data}
+ </it:treeNode>
+ </it:tree>
+
+ <h:panelGroup layout="block" id="selectionIndicator" style="margin-left: 50px;">
+ Current time: #{treeBean.currentTimeAsString}
+
+ <br />
+
+ Current selection: #{treeBean.selection}
+
+ <br />
+
+ Test text:
+ <h:inputText value="#{treeBean.executeTestText}" />
+
+ <br />
+
+ <a4j:outputPanel ajaxRendered="true">
+ Current time: #{treeBean.currentTimeAsString}
+ <br />
+ <h:outputText value="#{treeBean.executeTestText}" />
+ </a4j:outputPanel>
+
+ </h:panelGroup>
+ </h:panelGrid>
+
<a4j:log />
</h:form>
</h:body>
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-12-03 16:58:10 UTC (rev 20371)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-12-03 17:10:51 UTC (rev 20372)
@@ -192,6 +192,10 @@
public abstract String getToggleNodeEvent();
+ public abstract Object getExecute();
+
+ public abstract Object getRender();
+
@Override
public String getFamily() {
return COMPONENT_FAMILY;
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-12-03 16:58:10 UTC (rev 20371)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-12-03 17:10:51 UTC (rev 20372)
@@ -39,6 +39,7 @@
import javax.faces.context.PartialViewContext;
import javax.faces.context.ResponseWriter;
+import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSReference;
import org.richfaces.component.AbstractTree;
@@ -176,12 +177,10 @@
encodeSelectionStateInput(context, component);
writer.endUpdate();
- writer.startEval();
-
JSFunction function = new JSFunction("RichFaces.$", component.getClientId(context));
- writer.write(function.toScript() + ".__updateSelectionFromInput();");
-
- writer.endEval();
+
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ ajaxContext.appendOncomplete(function.toScript() + ".__updateSelectionFromInput();");
} else {
throw new IllegalArgumentException(metaComponentId);
}
Modified: trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
===================================================================
--- trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-12-03 16:58:10 UTC (rev 20371)
+++ trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-12-03 17:10:51 UTC (rev 20372)
@@ -347,8 +347,6 @@
},
destroy: function() {
- richfaces.ui.TreeNode.prototype.destroy.call(this);
-
if (this.__toggleNodeEvent) {
this.__treeRootElt.undelegate(".rf-trn", this.__toggleNodeEvent, this, this.__nodeToggleActivated);
}
14 years, 1 month
JBoss Rich Faces SVN: r20371 - trunk/examples/iteration-demo/src/main/webapp.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-12-03 11:58:10 -0500 (Fri, 03 Dec 2010)
New Revision: 20371
Modified:
trunk/examples/iteration-demo/src/main/webapp/dataTable.xhtml
Log:
rename subTable -> collapsibleSubTable
Modified: trunk/examples/iteration-demo/src/main/webapp/dataTable.xhtml
===================================================================
--- trunk/examples/iteration-demo/src/main/webapp/dataTable.xhtml 2010-12-03 16:53:35 UTC (rev 20370)
+++ trunk/examples/iteration-demo/src/main/webapp/dataTable.xhtml 2010-12-03 16:58:10 UTC (rev 20371)
@@ -32,8 +32,8 @@
<h:outputText id="columnHeader1" value="Column Header Facet" />
</f:facet>
- <!-- it:subTableToggleControl for="expandedSubTable">
- </it:subTableToggleControl -->
+ <it:collapsibleSubTableToggler for="collapsibleSubTable">
+ </it:collapsibleSubTableToggler>
<h:outputText value="#{record.name}" />
<f:facet name="footer">
@@ -55,11 +55,11 @@
<h:outputText value="#{record.EMail}" />
</it:column>
- <!-- it:subTable id="expandedSubTable" var="company"
+ <it:collapsibleSubTable id="collapsibleSubTable" var="company"
value="#{record.companies}" rows="1" switchType="ajax"
expanded="true">
<f:facet name="header">
- <it:dataScroller id="subscroller" for="expandedSubTable"
+ <it:dataScroller id="subscroller" for="collapsibleSubTable"
maxPages="3"></it:dataScroller>
</f:facet>
@@ -78,7 +78,7 @@
<it:column id="column_company_phone">
<h:outputText value="#{company.phone}" />
</it:column>
- </it:subTable -->
+ </it:collapsibleSubTable>
<f:facet name="footer">
<it:dataScroller id="scroller3" for="richTable" page="#{dataBean.page}" maxPages="7"></it:dataScroller>
14 years, 1 month
JBoss Rich Faces SVN: r20370 - trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2010-12-03 11:53:35 -0500 (Fri, 03 Dec 2010)
New Revision: 20370
Modified:
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/collapsible-subtable.js
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/datascroller.js
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/datatable.js
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
Log:
http://jira.jboss.com/jira/browse/RF-9858
iteration components code refactoring
Modified: trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/collapsible-subtable.js
===================================================================
--- trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/collapsible-subtable.js 2010-12-03 16:44:29 UTC (rev 20369)
+++ trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/collapsible-subtable.js 2010-12-03 16:53:35 UTC (rev 20370)
@@ -10,8 +10,7 @@
this.eventOptions = options.eventOptions;
this.formId = f;
- $super.constructor.call(this, id);
- this.attachToDom(id);
+ this.attachToDom();
};
$.extend(richfaces.ui.CollapsibleSubTable, {
@@ -20,12 +19,11 @@
MODE_CLNT: "client",
collapse: 0,
expand: 1
- })
-
- var $super = richfaces.BaseComponent.extend(richfaces.ui.CollapsibleSubTable);
- var $p = richfaces.BaseComponent.extend(richfaces.ui.CollapsibleSubTable, {});
- var $super = richfaces.ui.CollapsibleSubTable.$super;
+ });
+ richfaces.BaseComponent.extend(richfaces.ui.CollapsibleSubTable);
+ var $super = richfaces.ui.CollapsibleSubTable.$super;
+
$.extend(richfaces.ui.CollapsibleSubTable.prototype, (function () {
var element = function() {
@@ -62,7 +60,7 @@
return {
- name: "RichFaces.ui.CollapsibleSubTable",
+ name: "CollapsibleSubTable",
toggle: function(e, options) {
if(this.expandMode == richfaces.ui.CollapsibleSubTable.MODE_AJAX) {
@@ -107,7 +105,11 @@
getMode: function() {
return this.expandMode;
- }
+ },
+ destroy: function() {
+ this.detach();
+ $super.destroy.call(this);
+ }
};
})());
Modified: trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/datascroller.js
===================================================================
--- trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/datascroller.js 2010-12-03 16:44:29 UTC (rev 20369)
+++ trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/datascroller.js 2010-12-03 16:53:35 UTC (rev 20370)
@@ -52,9 +52,9 @@
richfaces.ui.DataScroller = function(id, submit, options) {
- $super.constructor.call(this,id);
+ $super.constructor.call(this, id);
- this.attachToDom(id);
+ this.attachToDom();
this.options = options;
this.currentPage = options.currentPage;
@@ -92,8 +92,7 @@
}
};
- var $super = richfaces.BaseComponent.extend(richfaces.ui.DataScroller);
- var $p = richfaces.BaseComponent.extend(richfaces.ui.DataScroller, {});
+ richfaces.BaseComponent.extend(richfaces.ui.DataScroller);
var $super = richfaces.ui.DataScroller.$super;
$.extend(richfaces.ui.DataScroller.prototype, (function (options) {
@@ -159,7 +158,11 @@
getScrollEventName: function() {
return scrollEventName;
- }
+ },
+ destroy: function() {
+ this.detach();
+ $super.destroy.call(this);
+ }
}
})());
Modified: trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/datatable.js
===================================================================
--- trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/datatable.js 2010-12-03 16:44:29 UTC (rev 20369)
+++ trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/datatable.js 2010-12-03 16:53:35 UTC (rev 20370)
@@ -3,15 +3,13 @@
richfaces.ui = richfaces.ui || {};
richfaces.ui.DataTable = function(id, options) {
- this.id = id;
- this.options = options;
$super.constructor.call(this,id);
- this.attachToDom(id);
+ this.options = $.extend(this.options, options || {});
+ this.attachToDom();
};
- var $super = richfaces.BaseComponent.extend(richfaces.ui.DataTable);
- var $p = richfaces.BaseComponent.extend(richfaces.ui.DataTable, {});
+ richfaces.BaseComponent.extend(richfaces.ui.DataTable);
var $super = richfaces.ui.DataTable.$super;
$.extend(richfaces.ui.DataTable, {
@@ -96,7 +94,11 @@
func.call(component);
}
}
- }
+ },
+ destroy: function() {
+ this.detach();
+ $super.destroy.call(this);
+ }
}
})());
Modified: trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
===================================================================
--- trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-12-03 16:44:29 UTC (rev 20369)
+++ trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-12-03 16:53:35 UTC (rev 20370)
@@ -40,7 +40,8 @@
name: "TreeNode",
init: function (id, commonOptions) {
- this.__rootElt = $(this.attachToDom(id));
+ $superTreeNode.constructor.call(this, id);
+ this.__rootElt = $(this.attachToDom());
this.__children = new Array();
@@ -60,7 +61,6 @@
},
destroy: function() {
- richfaces.BaseComponent.prototype.destroy.call(this);
if (this.parent) {
this.parent.removeChild(this);
@@ -72,6 +72,9 @@
this.__clearChildren();
this.__rootElt = null;
+
+ this.detach();
+ $superTreeNode.destroy.call(this);
},
__initializeChildren: function(commonOptions) {
@@ -254,6 +257,9 @@
});
+ // define super class link for TreeNode
+ var $superTreeNode = richfaces.ui.TreeNode.$super;
+
richfaces.ui.TreeNode.initNodeByAjax = function(nodeId, commonOptions) {
var node = $(document.getElementById(nodeId));
@@ -303,7 +309,7 @@
commonOptions.clientEventHandlers = options.clientEventHandlers || {};
commonOptions.treeId = id;
- this.$super.init.call(this, this.__treeRootElt, commonOptions);
+ $superTree.constructor.call(this, this.__treeRootElt, commonOptions);
this.__toggleType = options.toggleType || 'ajax';
this.__selectionType = options.selectionType || 'client';
@@ -355,6 +361,7 @@
this.__selectionInput = null;
this.__ajaxSubmitFunction = null;
+ $superTree.destroy.call(this);
},
__nodeToggleActivated: function(event) {
@@ -462,6 +469,9 @@
}
});
+ // define super class link for Tree
+ var $superTree = richfaces.ui.Tree.$super;
+
richfaces.ui.TreeNodeSet = function() {
this.init.apply(this, arguments);
};
14 years, 1 month
JBoss Rich Faces SVN: r20369 - in trunk/ui/iteration/ui/src/main: java/org/richfaces/renderkit and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-12-03 11:44:29 -0500 (Fri, 03 Dec 2010)
New Revision: 20369
Added:
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractCollapsibleSubTable.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractCollapsibleSubTableToggler.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/CollapsibleSubTableRenderer.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/CollapsibleSubTableTogglerRendererBase.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/taglib/CollapsibleSubTableHandler.java
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/collapsible-subtable-toggler.js
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/collapsible-subtable.ecss
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/collapsible-subtable.js
Removed:
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractSubTable.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractSubTableToggleControl.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/taglib/SubTableHandler.java
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/subtable-toggler.js
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/subtable.js
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/datatable.ecss
trunk/ui/iteration/ui/src/main/templates/toggle-control.template.xml
Log:
rename SubTable to the CollapsibleSubTable, SubTableToggler -> CollapsibleSubTableToggler
Added: trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractCollapsibleSubTable.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractCollapsibleSubTable.java (rev 0)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractCollapsibleSubTable.java 2010-12-03 16:44:29 UTC (rev 20369)
@@ -0,0 +1,161 @@
+/*
+* JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.component;
+
+import javax.el.ELContext;
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.cdk.annotations.TagType;
+import org.richfaces.event.ToggleEvent;
+import org.richfaces.event.ToggleListener;
+
+
+/**
+ * @author Anton Belevich
+ *
+ */
+@JsfComponent(
+ type = AbstractCollapsibleSubTable.COMPONENT_TYPE,
+ family = AbstractCollapsibleSubTable.COMPONENT_FAMILY,
+ generate = "org.richfaces.component.UICollapsibleSubTable",
+ renderer = @JsfRenderer(type = "org.richfaces.CollapsibleSubTableRenderer"),
+ tag = @Tag(name = "collapsibleSubTable", handler = "org.richfaces.taglib.CollapsibleSubTableHandler", type = TagType.Facelets)
+)
+public abstract class AbstractCollapsibleSubTable extends UIDataTableBase implements Column, Expandable {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.CollapsibleSubTable";
+
+ public static final String COMPONENT_FAMILY = UIDataTableBase.COMPONENT_FAMILY;
+
+ public static final String MODE_AJAX = "ajax";
+
+ public static final String MODE_SERVER = "server";
+
+ public static final String MODE_CLIENT = "client";
+
+ public static final int EXPAND_STATE = 1;
+
+ public static final int COLLAPSE_STATE = 0;
+
+
+ enum PropertyKeys {
+ expanded
+ }
+
+ public boolean isExpanded() {
+ return (Boolean)getStateHelper().eval(PropertyKeys.expanded, true);
+ }
+
+ public void setExpanded(boolean expanded) {
+ getStateHelper().put(PropertyKeys.expanded, expanded);
+ }
+
+ @Attribute(defaultValue = MODE_CLIENT)
+ public abstract String getExpandMode();
+
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ if (event instanceof ToggleEvent) {
+ ToggleEvent toggleEvent = (ToggleEvent) event;
+ boolean newValue = toggleEvent.isExpanded();
+
+ getStateHelper().put(PropertyKeys.expanded, newValue);
+
+ FacesContext facesContext = getFacesContext();
+ ELContext elContext = facesContext.getELContext();
+
+ ValueExpression valueExpression = getValueExpression(PropertyKeys.expanded.toString());
+ if (valueExpression != null && !valueExpression.isReadOnly(elContext)) {
+ valueExpression.setValue(elContext, newValue);
+ }
+
+ if(getFacesContext().getPartialViewContext().isAjaxRequest()) {
+ String render = resolveClientId(facesContext, this, BODY);
+
+ getFacesContext().getPartialViewContext().getRenderIds().add(render);
+
+ String togglerId = toggleEvent.getTogglerId();
+ if(togglerId != null) {
+ getFacesContext().getPartialViewContext().getRenderIds().add(togglerId);
+ }
+ }
+
+ }
+ super.broadcast(event);
+ }
+
+ public boolean isBreakBefore() {
+ return true;
+ }
+
+ public void setBreakBefore(boolean newBreakBefore) {
+ throw new IllegalStateException("Property 'breakBefore' for subtable is read-only");
+ }
+
+ public String getSortExpression() {
+ // SubTable is not sortable element.
+ return null;
+ }
+
+ public void setSortExpression(String sortExpression) {
+ throw new IllegalArgumentException("subtable is not sortable element");
+ }
+
+ public void addToggleListener(ToggleListener listener) {
+ addFacesListener(listener);
+ }
+
+ public void removeToggleListener(ToggleListener listener) {
+ removeFacesListener(listener);
+ }
+
+ public ToggleListener[] getToggleListeners() {
+ return (ToggleListener[]) getFacesListeners(ToggleListener.class);
+ }
+
+ public void setIterationState(Object stateObject) {
+ Object[] state = (Object[]) stateObject;
+ if (state != null) {
+ super.setIterationState(state[0]);
+ getStateHelper().put(PropertyKeys.expanded, state[1]);
+ } else {
+ super.setIterationState(null);
+ getStateHelper().put(PropertyKeys.expanded, null);
+ }
+ }
+
+ public Object getIterationState() {
+ Object [] state = new Object[2];
+ state[0] = super.getIterationState();
+ state[1] = getStateHelper().get(PropertyKeys.expanded);
+ return state;
+ }
+}
+
+
Added: trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractCollapsibleSubTableToggler.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractCollapsibleSubTableToggler.java (rev 0)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractCollapsibleSubTableToggler.java 2010-12-03 16:44:29 UTC (rev 20369)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.component;
+
+import javax.faces.component.UIComponentBase;
+
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.cdk.annotations.Tag;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+
+@JsfComponent(
+ type = AbstractCollapsibleSubTableToggler.COMPONENT_TYPE,
+ family = AbstractCollapsibleSubTableToggler.COMPONENT_FAMILY,
+ generate = "org.richfaces.component.UICollapsibleSubTableToggleControl",
+ renderer = @JsfRenderer(type = "org.richfaces.CollapsibleSubTableTogglerRenderer"),
+ tag = @Tag( name = "collapsibleSubTableToggler")
+ )
+public abstract class AbstractCollapsibleSubTableToggler extends UIComponentBase {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.CollapsibleSubTableToggler";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.CollapsibleSubTableToggler";
+
+ public static final String DEFAULT_EVENT = "onclick";
+
+ enum PropertyKeys {
+ forId
+ }
+
+ @Attribute
+ public abstract String getExpandLabel();
+
+ @Attribute
+ public abstract String getCollapseLabel();
+
+ @Attribute
+ public abstract String getExpandIcon();
+
+ @Attribute
+ public abstract String getCollapseIcon();
+
+ @Attribute(defaultValue = DEFAULT_EVENT)
+ public abstract String getEvent();
+
+ public String getFor() {
+ return (String)getStateHelper().eval(PropertyKeys.forId);
+ }
+
+ public void setFor(String forId) {
+ getStateHelper().put(PropertyKeys.forId, forId);
+ }
+}
Deleted: trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractSubTable.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractSubTable.java 2010-12-03 16:30:40 UTC (rev 20368)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractSubTable.java 2010-12-03 16:44:29 UTC (rev 20369)
@@ -1,161 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.richfaces.component;
-
-import javax.el.ELContext;
-import javax.el.ValueExpression;
-import javax.faces.context.FacesContext;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.FacesEvent;
-
-import org.richfaces.cdk.annotations.Attribute;
-import org.richfaces.cdk.annotations.JsfComponent;
-import org.richfaces.cdk.annotations.JsfRenderer;
-import org.richfaces.cdk.annotations.Tag;
-import org.richfaces.cdk.annotations.TagType;
-import org.richfaces.event.ToggleEvent;
-import org.richfaces.event.ToggleListener;
-
-
-/**
- * @author Anton Belevich
- *
- */
-@JsfComponent(
- type = AbstractSubTable.COMPONENT_TYPE,
- family = AbstractSubTable.COMPONENT_FAMILY,
- generate = "org.richfaces.component.UISubTable",
- renderer = @JsfRenderer(type = "org.richfaces.SubTableRenderer"),
- tag = @Tag(name = "subTable", handler = "org.richfaces.taglib.SubTableHandler", type = TagType.Facelets)
-)
-public abstract class AbstractSubTable extends UIDataTableBase implements Column, Expandable {
-
- public static final String COMPONENT_TYPE = "org.richfaces.SubTable";
-
- public static final String COMPONENT_FAMILY = UIDataTableBase.COMPONENT_FAMILY;
-
- public static final String MODE_AJAX = "ajax";
-
- public static final String MODE_SERVER = "server";
-
- public static final String MODE_CLIENT = "client";
-
- public static final int EXPAND_STATE = 1;
-
- public static final int COLLAPSE_STATE = 0;
-
-
- enum PropertyKeys {
- expanded
- }
-
- public boolean isExpanded() {
- return (Boolean)getStateHelper().eval(PropertyKeys.expanded, true);
- }
-
- public void setExpanded(boolean expanded) {
- getStateHelper().put(PropertyKeys.expanded, expanded);
- }
-
- @Attribute(defaultValue = MODE_CLIENT)
- public abstract String getExpandMode();
-
- public void broadcast(FacesEvent event) throws AbortProcessingException {
- if (event instanceof ToggleEvent) {
- ToggleEvent toggleEvent = (ToggleEvent) event;
- boolean newValue = toggleEvent.isExpanded();
-
- getStateHelper().put(PropertyKeys.expanded, newValue);
-
- FacesContext facesContext = getFacesContext();
- ELContext elContext = facesContext.getELContext();
-
- ValueExpression valueExpression = getValueExpression(PropertyKeys.expanded.toString());
- if (valueExpression != null && !valueExpression.isReadOnly(elContext)) {
- valueExpression.setValue(elContext, newValue);
- }
-
- if(getFacesContext().getPartialViewContext().isAjaxRequest()) {
- String render = resolveClientId(facesContext, this, BODY);
-
- getFacesContext().getPartialViewContext().getRenderIds().add(render);
-
- String togglerId = toggleEvent.getTogglerId();
- if(togglerId != null) {
- getFacesContext().getPartialViewContext().getRenderIds().add(togglerId);
- }
- }
-
- }
- super.broadcast(event);
- }
-
- public boolean isBreakBefore() {
- return true;
- }
-
- public void setBreakBefore(boolean newBreakBefore) {
- throw new IllegalStateException("Property 'breakBefore' for subtable is read-only");
- }
-
- public String getSortExpression() {
- // SubTable is not sortable element.
- return null;
- }
-
- public void setSortExpression(String sortExpression) {
- throw new IllegalArgumentException("subtable is not sortable element");
- }
-
- public void addToggleListener(ToggleListener listener) {
- addFacesListener(listener);
- }
-
- public void removeToggleListener(ToggleListener listener) {
- removeFacesListener(listener);
- }
-
- public ToggleListener[] getToggleListeners() {
- return (ToggleListener[]) getFacesListeners(ToggleListener.class);
- }
-
- public void setIterationState(Object stateObject) {
- Object[] state = (Object[]) stateObject;
- if (state != null) {
- super.setIterationState(state[0]);
- getStateHelper().put(PropertyKeys.expanded, state[1]);
- } else {
- super.setIterationState(null);
- getStateHelper().put(PropertyKeys.expanded, null);
- }
- }
-
- public Object getIterationState() {
- Object [] state = new Object[2];
- state[0] = super.getIterationState();
- state[1] = getStateHelper().get(PropertyKeys.expanded);
- return state;
- }
-}
-
-
Deleted: trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractSubTableToggleControl.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractSubTableToggleControl.java 2010-12-03 16:30:40 UTC (rev 20368)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractSubTableToggleControl.java 2010-12-03 16:44:29 UTC (rev 20369)
@@ -1,77 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.component;
-
-import javax.faces.component.UIComponentBase;
-
-import org.richfaces.cdk.annotations.Attribute;
-import org.richfaces.cdk.annotations.JsfComponent;
-import org.richfaces.cdk.annotations.JsfRenderer;
-import org.richfaces.cdk.annotations.Tag;
-
-/**
- * @author Anton Belevich
- *
- */
-
-@JsfComponent(
- type = AbstractSubTableToggleControl.COMPONENT_TYPE,
- family = AbstractSubTableToggleControl.COMPONENT_FAMILY,
- generate = "org.richfaces.component.UISubTableToggleControl",
- renderer = @JsfRenderer(type = "org.richfaces.SubTableToggleControlRenderer"),
- tag = @Tag( name = "subTableToggleControl")
- )
-public abstract class AbstractSubTableToggleControl extends UIComponentBase {
-
- public static final String COMPONENT_TYPE = "org.richfaces.SubTableToggleControl";
-
- public static final String COMPONENT_FAMILY = "org.richfaces.SubTableToggleControl";
-
- public static final String DEFAULT_EVENT = "onclick";
-
- enum PropertyKeys {
- forId
- }
-
- @Attribute
- public abstract String getExpandLabel();
-
- @Attribute
- public abstract String getCollapseLabel();
-
- @Attribute
- public abstract String getExpandIcon();
-
- @Attribute
- public abstract String getCollapseIcon();
-
- @Attribute(defaultValue = DEFAULT_EVENT)
- public abstract String getEvent();
-
- public String getFor() {
- return (String)getStateHelper().eval(PropertyKeys.forId);
- }
-
- public void setFor(String forId) {
- getStateHelper().put(PropertyKeys.forId, forId);
- }
-}
Added: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/CollapsibleSubTableRenderer.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/CollapsibleSubTableRenderer.java (rev 0)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/CollapsibleSubTableRenderer.java 2010-12-03 16:44:29 UTC (rev 20369)
@@ -0,0 +1,413 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.faces.application.ResourceDependencies;
+import javax.faces.application.ResourceDependency;
+import javax.faces.component.UIColumn;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.event.AbortProcessingException;
+
+import org.ajax4jsf.javascript.JSFunction;
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.component.AbstractDataTable;
+import org.richfaces.component.AbstractCollapsibleSubTable;
+import org.richfaces.component.Row;
+import org.richfaces.component.UIDataTableBase;
+import org.richfaces.event.ToggleEvent;
+import org.richfaces.renderkit.util.AjaxRendererUtils;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+
+@JsfRenderer(type = "org.richfaces.CollapsibleSubTableRenderer", family = AbstractCollapsibleSubTable.COMPONENT_FAMILY)
+@ResourceDependencies({
+ @ResourceDependency(name = "jquery.js"),
+ @ResourceDependency(name = "richfaces.js"),
+ @ResourceDependency(library="org.richfaces", name = "collapsible-subtable.ecss"),
+ @ResourceDependency(library="org.richfaces", name = "collapsible-subtable.js")
+})
+public class CollapsibleSubTableRenderer extends AbstractTableRenderer {
+
+ public static final String TB_ROW = ":c";
+
+ private static final String STATE = ":state";
+
+ private static final String OPTIONS = ":options";
+
+ private static final String DISPLAY_NONE = "display: none;";
+
+ private class CollapsibleSubTableHiddenEncodeStrategy implements EncodeStrategy {
+
+ public void begin(ResponseWriter writer, FacesContext context, UIComponent component, Object[] params) throws IOException {
+ AbstractCollapsibleSubTable subTable = (AbstractCollapsibleSubTable)component;
+ writer.startElement(HtmlConstants.TR_ELEMENT, subTable);
+ writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, subTable.getClientId(context) + HIDDEN_CONTAINER_ID, null);
+ writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, DISPLAY_NONE, null);
+ writer.startElement(HtmlConstants.TD_ELEM, subTable);
+ }
+
+ public void end(ResponseWriter writer, FacesContext context, UIComponent component, Object[] params) throws IOException {
+ writer.endElement(HtmlConstants.TD_ELEM);
+ writer.endElement(HtmlConstants.TR_ELEMENT);
+
+ if(params != null && params.length ==1) {
+ boolean endTbody = (Boolean)params[0];
+ if(endTbody) {
+ encodeTableBodyEnd(writer);
+ }
+ }
+ }
+
+ };
+
+ protected void doDecode(FacesContext facesContext, UIComponent component) {
+ AbstractCollapsibleSubTable subTable = (AbstractCollapsibleSubTable)component;
+
+ String clientId = subTable.getClientId(facesContext);
+ Map<String, String> requestMap = facesContext.getExternalContext().getRequestParameterMap();
+
+ String optionsId = clientId + OPTIONS;
+ String togglerId = requestMap.get(optionsId);
+
+ String stateId = clientId + STATE;
+ String state = (String)requestMap.get(stateId);
+
+ boolean isExpand = true;
+ if(state != null) {
+ int newValue = Integer.parseInt(state);
+
+ if(newValue < 1) {
+ isExpand = false;
+ }
+
+ if(subTable.isExpanded() != isExpand) {
+ new ToggleEvent(subTable, isExpand, togglerId).queue();
+ }
+ }
+ }
+
+ @Override
+ public void encodeFirstRowStart(ResponseWriter writer, FacesContext context, String parentId, int currentRow, UIComponent component) throws IOException {
+ writer.startElement(HtmlConstants.TR_ELEMENT, component);
+ writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, parentId + ":" + currentRow + ":b", null);
+ String styleClass = getFirstRowClass(context, parentId);
+ encodeStyleClass(writer, context, component, HtmlConstants.STYLE_CLASS_ATTR, styleClass);
+ }
+
+ @Override
+ public void encodeRowStart(ResponseWriter writer, FacesContext context, String parentId, int currentRow, UIComponent component) throws IOException {
+ writer.startElement(HtmlConstants.TR_ELEMENT, component);
+ writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, parentId + ":" + currentRow + ":b", null);
+ String styleClass = getRowClass(context, parentId);
+ encodeStyleClass(writer, context, component, HtmlConstants.STYLE_CLASS_ATTR, styleClass);
+ }
+
+ public void encodeTableFacets(ResponseWriter writer, FacesContext context, UIDataTableBase dataTable) throws IOException {
+ AbstractCollapsibleSubTable subTable = (AbstractCollapsibleSubTable)dataTable;
+
+ encodeHeaderFacet(writer, context, subTable, false);
+
+ String rowClass = getRowSkinClass();
+ String cellClass = getCellSkinClass();
+ String firstClass = getFirstRowSkinClass();
+
+ rowClass = mergeStyleClasses("rowClass", rowClass, subTable);
+ cellClass = mergeStyleClasses("cellClass", cellClass, subTable);
+ firstClass = mergeStyleClasses("firstRowClass", firstClass, subTable);
+
+ saveRowStyles(context, subTable.getClientId(context), firstClass, rowClass, cellClass);
+ }
+
+ @Override
+ public void encodeTableBodyStart(ResponseWriter writer, FacesContext facesContext, UIDataTableBase dataTableBase) throws IOException {
+ AbstractCollapsibleSubTable subTable = (AbstractCollapsibleSubTable)dataTableBase;
+
+ UIDataTableBase component = findParent(subTable);
+ if(component instanceof AbstractDataTable) {
+ writer.startElement(HtmlConstants.TBODY_ELEMENT, null);
+ writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, component.getRelativeClientId(facesContext) + ":" + subTable.getId() + TB_ROW, null);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, getTableSkinClass(), null);
+
+ String predefinedStyles = !subTable.isExpanded() ? DISPLAY_NONE : null;
+ encodeStyle(writer, facesContext, subTable, predefinedStyles);
+ }
+ }
+
+ @Override
+ public void encodeBeforeRows(ResponseWriter writer, FacesContext facesContext, UIDataTableBase dataTableBase, boolean encodeParentTBody, boolean partialUpdate) throws IOException {
+ AbstractCollapsibleSubTable subTable = (AbstractCollapsibleSubTable)dataTableBase;
+ encodeTableBodyStart(writer, facesContext, subTable);
+ encodeSubTableDomElement(writer, facesContext, subTable);
+ setupTableStartElement(facesContext, subTable);
+ encodeHeaderFacet(writer, facesContext, subTable, false);
+ }
+
+ private void encodeSubTableDomElement(ResponseWriter writer, FacesContext facesContext, AbstractCollapsibleSubTable subTable) throws IOException{
+ writer.startElement(HtmlConstants.TR_ELEMENT, subTable);
+ writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, DISPLAY_NONE, null);
+ writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, subTable.getClientId(facesContext), null);
+ writer.startElement(HtmlConstants.TD_ELEM, subTable);
+ writer.endElement(HtmlConstants.TD_ELEM);
+ writer.endElement(HtmlConstants.TR_ELEMENT);
+ }
+
+ public void encodeRow(ResponseWriter writer, FacesContext facesContext, RowHolderBase holder) throws IOException {
+ RowHolder rowHolder = (RowHolder)holder;
+ Row row = rowHolder.getRow();
+
+ rowHolder.setRowStart(true);
+ Iterator<UIComponent> components = row.columns();
+ if (rowHolder.isUpdatePartial()) {
+ partialStart(facesContext,((AbstractCollapsibleSubTable) row).getRelativeClientId(facesContext) + ":b");
+ }
+
+ while (components.hasNext()) {
+ UIComponent component = components.next();
+ if(component.isRendered()) {
+ if(component instanceof UIColumn ) {
+ encodeColumn(facesContext, writer, (UIColumn)component , rowHolder);
+
+ } else if (component instanceof AbstractCollapsibleSubTable) {
+ if(component.isRendered()) {
+ encodeRowEnd(writer);
+ }
+
+ component.encodeAll(facesContext);
+ rowHolder.setRowStart(true);
+ }
+ }
+ }
+
+ encodeRowEnd(writer);
+
+ if (rowHolder.isUpdatePartial()) {
+ partialEnd(facesContext);
+ }
+ }
+
+ @Override
+ public void encodeAfterRows(ResponseWriter writer, FacesContext facesContext, UIDataTableBase dataTableBase,
+ boolean encodeParentTBody, boolean partialUpdate) throws IOException {
+ AbstractCollapsibleSubTable subTable = (AbstractCollapsibleSubTable)dataTableBase;
+ encodeFooterFacet(writer, facesContext, subTable, false);
+ }
+
+ @Override
+ public boolean encodeParentTBody(UIDataTableBase dataTableBase) {
+ UIDataTableBase parent = findParent((AbstractCollapsibleSubTable)dataTableBase);
+ return (parent instanceof AbstractDataTable);
+ }
+
+ public void encodeHiddenInput(ResponseWriter writer, FacesContext facesContext, UIDataTableBase dataTableBase)
+ throws IOException {
+ AbstractCollapsibleSubTable subTable = (AbstractCollapsibleSubTable) dataTableBase;
+
+ String stateId = subTable.getClientId(facesContext) + STATE;
+
+ writer.startElement(HtmlConstants.INPUT_ELEM, subTable);
+ writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, stateId, null);
+ writer.writeAttribute(HtmlConstants.NAME_ATTRIBUTE, stateId, null);
+ writer.writeAttribute(HtmlConstants.TYPE_ATTR, HtmlConstants.INPUT_TYPE_HIDDEN, null);
+
+ int state = subTable.isExpanded() ? AbstractCollapsibleSubTable.EXPAND_STATE : AbstractCollapsibleSubTable.COLLAPSE_STATE;
+
+ writer.writeAttribute(HtmlConstants.VALUE_ATTRIBUTE, state, null);
+ writer.endElement(HtmlConstants.INPUT_ELEM);
+
+ String optionsId = subTable.getClientId(facesContext) + OPTIONS;
+ writer.startElement(HtmlConstants.INPUT_ELEM, subTable);
+ writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, optionsId, null);
+ writer.writeAttribute(HtmlConstants.NAME_ATTRIBUTE, optionsId, null);
+ writer.writeAttribute(HtmlConstants.TYPE_ATTR, HtmlConstants.INPUT_TYPE_HIDDEN, null);
+ writer.endElement(HtmlConstants.INPUT_ELEM);
+
+ }
+
+ public boolean containsThead() {
+ return false;
+ }
+
+ public EncodeStrategy getHeaderEncodeStrategy(UIComponent column, String tableFacetName) {
+ //TODO: anton -> use RichHeaderEncodeStrategy for our columns ???
+ return new SimpleHeaderEncodeStrategy();
+
+ }
+
+ public void encodeClientScript(ResponseWriter writer, FacesContext facesContext, UIDataTableBase component)
+ throws IOException {
+ AbstractCollapsibleSubTable subTable = (AbstractCollapsibleSubTable) component;
+
+ String id = subTable.getClientId(facesContext);
+
+ UIComponent nestingForm = getUtils().getNestingForm(facesContext, subTable);
+ String formId = nestingForm != null ? nestingForm.getClientId(facesContext) : "";
+
+ Map<String, Object> options = new HashMap<String, Object>();
+ options.put("stateInput", subTable.getClientId(facesContext) + STATE);
+ options.put("optionsInput", subTable.getClientId(facesContext) + OPTIONS);
+ options.put("expandMode", subTable.getExpandMode());
+ options.put("eventOptions", AjaxRendererUtils.buildEventOptions(facesContext, subTable));
+
+ JSFunction jsFunction = new JSFunction("new RichFaces.ui.CollapsibleSubTable");
+ jsFunction.addParameter(id);
+ jsFunction.addParameter(formId);
+ jsFunction.addParameter(options);
+
+ writer.startElement(HtmlConstants.SCRIPT_ELEM, subTable);
+ writer.writeAttribute(HtmlConstants.TYPE_ATTR, HtmlConstants.JAVASCRIPT_TYPE, null);
+ writer.writeText(jsFunction.toScript(), null);
+ writer.endElement(HtmlConstants.SCRIPT_ELEM);
+ }
+
+ public String getTableSkinClass() {
+ return "rf-cst";
+ }
+
+ public String getRowSkinClass() {
+ return "rf-cst-r";
+ }
+
+ public String getFirstRowSkinClass() {
+ return "rf-cst-fst-r";
+ }
+
+ public String getHeaderRowSkinClass() {
+ return "rf-cst-hdr-r";
+ }
+
+ public String getHeaderFirstRowSkinClass() {
+ return "rf-cst-hdr-fst-r";
+ }
+
+ public String getCellSkinClass() {
+ return "rf-cst-c";
+ }
+
+ public String getHeaderCellSkinClass() {
+ return "rf-cst-hdr-c";
+ }
+
+ public String getColumnHeaderCellSkinClass() {
+ return "rf-cst-shdr-c";
+ }
+
+ public String getColumnHeaderSkinClass() {
+ return "rf-cst-shdr";
+ }
+
+ public String getFooterSkinClass() {
+ return "rf-cst-ftr";
+ }
+
+ public String getFooterCellSkinClass() {
+ return "rf-cst-ftr-c";
+ }
+
+ public String getFooterFirstRowSkinClass() {
+ return "rf-cst-ftr-fst";
+ }
+
+ public String getColumnFooterCellSkinClass() {
+ return "rf-cst-sftr-c";
+ }
+
+ public String getColumnFooterSkinClass() {
+ return "rf-cst-sftr";
+ }
+
+ public String getColumnFooterFirstSkinClass() {
+ return "rf-cst-sftr-fst";
+ }
+
+ public String getColumnHeaderFirstSkinClass() {
+ return "rf-cst-shdr-fst";
+ }
+
+ public String getFooterFirstSkinClass() {
+ return "rf-cst-ftr-fst";
+ }
+
+ public String getHeaderFirstSkinClass() {
+ return "rf-cst-hdr-fst";
+ }
+
+ public String getHeaderSkinClass() {
+ return "rf-cst-hdr";
+ }
+
+ public String getNoDataClass() {
+ return "rf-cst-nd-c";
+ }
+
+ @Override
+ public void encodeMetaComponent(FacesContext facesContext, UIComponent component, String metaComponentId)
+ throws IOException {
+ AbstractCollapsibleSubTable subTable = (AbstractCollapsibleSubTable)component;
+ setupTableStartElement(facesContext, subTable);
+
+ if(AbstractCollapsibleSubTable.BODY.equals(metaComponentId)) {
+ ResponseWriter writer = facesContext.getResponseWriter();
+ UIDataTableBase dataTableBase = findParent(subTable);
+
+ String updateId = dataTableBase.getRelativeClientId(facesContext) + ":" + subTable.getId() + TB_ROW;
+
+ partialStart(facesContext, updateId);
+ encodeTableRows(writer, facesContext, subTable, false);
+ partialEnd(facesContext);
+ }
+ }
+
+ @Override
+ public EncodeStrategy getHiddenContainerStrategy(UIDataTableBase dataTableBase) {
+ return new CollapsibleSubTableHiddenEncodeStrategy();
+ }
+
+ protected void setupTableStartElement(FacesContext context, UIComponent component) {
+ setupTableStartElement(context, component, HtmlConstants.TD_ELEM);
+ }
+
+ protected UIDataTableBase findParent(AbstractCollapsibleSubTable subTable) {
+ UIComponent parent = subTable.getParent();
+
+ while(parent != null && !(parent instanceof UIDataTableBase)) {
+ parent = parent.getParent();
+ }
+
+ if(parent == null){
+ //TODO: anton -> do we need this?
+ throw new AbortProcessingException("UISubTable should be a child of UIDataTable or UISubTable");
+ }
+ return (UIDataTableBase)parent;
+ }
+}
Added: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/CollapsibleSubTableTogglerRendererBase.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/CollapsibleSubTableTogglerRendererBase.java (rev 0)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/CollapsibleSubTableTogglerRendererBase.java 2010-12-03 16:44:29 UTC (rev 20369)
@@ -0,0 +1,209 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.application.ResourceDependencies;
+import javax.faces.application.ResourceDependency;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.javascript.JSFunction;
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.component.AbstractCollapsibleSubTable;
+import org.richfaces.component.AbstractCollapsibleSubTableToggler;
+import org.richfaces.renderkit.util.RendererUtils;
+
+/**
+ * @author Anton Belevich
+ */
+
+
+@JsfRenderer(type = "org.richfaces.CollapsibleSubTableTogglerRenderer", family = AbstractCollapsibleSubTableToggler.COMPONENT_FAMILY)
+@ResourceDependencies(
+ {@ResourceDependency(library = "javax.faces", name = "jsf.js"),
+ @ResourceDependency(name = "richfaces.js"),
+ @ResourceDependency(name = "richfaces-event.js"),
+ @ResourceDependency(library="org.richfaces", name = "collapsible-subtable-toggler.js")
+})
+public class CollapsibleSubTableTogglerRendererBase extends RendererBase {
+
+ /**
+ *
+ */
+ private static final RendererUtils RENDERER_UTILS = RendererUtils.getInstance();
+
+ private static final String DISPLAY_NONE = "display: none;";
+
+ private static final String UP_ICON_URL = "org.richfaces/up_icon.gif";
+
+ private static final String DOWN_ICON_URL = "org.richfaces/down_icon.gif";
+
+ private static final String EXPAND_STATE = "expand";
+
+ private static final String COLLAPSE_STATE = "collapse";
+
+ @Override
+ protected void doDecode(FacesContext context, UIComponent component) {
+ context.getPartialViewContext().getRenderIds().add(component.getClientId(context));
+ }
+
+ protected void encodeControl(FacesContext context, UIComponent component) throws IOException {
+ AbstractCollapsibleSubTableToggler toggleControl = (AbstractCollapsibleSubTableToggler) component;
+ AbstractCollapsibleSubTable subTable = findComponent(context, toggleControl);
+
+ if (subTable != null) {
+ String switchType = subTable.getExpandMode();
+ boolean expanded = subTable.isExpanded();
+
+ ResponseWriter writer = context.getResponseWriter();
+ encodeControl(context, writer, toggleControl, switchType, expanded, false);
+ encodeControl(context, writer, toggleControl, switchType, !expanded, true);
+
+ JSFunction jsFunction = new JSFunction("new RichFaces.ui.CollapsibleSubTableToggler");
+ String toggleId = toggleControl.getClientId(context);
+ jsFunction.addParameter(toggleId);
+ Map<String, Object> options = encodeOptions(context, toggleControl, subTable);
+ jsFunction.addParameter(options);
+
+ writer.startElement(HtmlConstants.SCRIPT_ELEM, subTable);
+ writer.writeText(jsFunction.toScript(), null);
+ writer.endElement(HtmlConstants.SCRIPT_ELEM);
+ }
+ }
+
+ protected void encodeControl(FacesContext context, ResponseWriter writer, AbstractCollapsibleSubTableToggler control,
+ String switchType, boolean expanded, boolean visible) throws IOException {
+ String state = getState(expanded);
+ String styleClass = getStyleClass(context, control);
+ String style = getStyle(context, control);
+
+ writer.startElement(HtmlConstants.SPAN_ELEM, control);
+
+ if (!visible) {
+ writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, DISPLAY_NONE, null);
+ }
+
+ writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, control.getClientId() + ":" + state, null);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, styleClass, null);
+ writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, style, null);
+
+ boolean encodeDefault = true;
+
+ UIComponent controlFacet = control.getFacet(state);
+ if (controlFacet != null && controlFacet.isRendered()) {
+
+ if (!visible) {
+ String facetStyle = (String) controlFacet.getAttributes().get(HtmlConstants.STYLE_ATTRIBUTE);
+ facetStyle = facetStyle != null ? facetStyle + ";" + DISPLAY_NONE : DISPLAY_NONE;
+ controlFacet.getAttributes().put(HtmlConstants.STYLE_ATTRIBUTE, facetStyle);
+ }
+ controlFacet.encodeAll(context);
+ encodeDefault = false;
+ }
+
+ String expandIcon = control.getExpandIcon();
+ String collapseIcon = control.getCollapseIcon();
+
+ if ((expandIcon != null && collapseIcon != null)
+ && (expandIcon.trim().length() > 0 && collapseIcon.trim().length() > 0)) {
+
+ String image = expanded ? expandIcon : collapseIcon;
+ if (image != null && image.trim().length() > 0) {
+ writer.startElement(HtmlConstants.IMG_ELEMENT, control);
+ writer.writeAttribute(HtmlConstants.SRC_ATTRIBUTE, image, null);
+ writer.writeAttribute(HtmlConstants.ALT_ATTRIBUTE, "", null);
+ writer.endElement(HtmlConstants.IMG_ELEMENT);
+ }
+ encodeDefault = false;
+ }
+
+ String label = expanded ? control.getExpandLabel() : control.getCollapseLabel();
+ if (label != null && label.trim().length() > 0) {
+ writer.startElement(HtmlConstants.A_ELEMENT, control);
+ writer.writeAttribute(HtmlConstants.HREF_ATTR, "javascript:void(0);", null);
+ writer.writeText(label, null);
+ writer.endElement(HtmlConstants.A_ELEMENT);
+ encodeDefault = false;
+ }
+
+ if (encodeDefault) {
+ expandIcon = context.getApplication().getResourceHandler().createResource(UP_ICON_URL).getRequestPath();
+ collapseIcon = context.getApplication().getResourceHandler().createResource(DOWN_ICON_URL).getRequestPath();
+
+ String image = expanded ? expandIcon : collapseIcon;
+ if (image != null && image.trim().length() > 0) {
+ writer.startElement(HtmlConstants.IMG_ELEMENT, control);
+ writer.writeAttribute(HtmlConstants.SRC_ATTRIBUTE, image, null);
+ writer.writeAttribute(HtmlConstants.ALT_ATTRIBUTE, "", null);
+ writer.endElement(HtmlConstants.IMG_ELEMENT);
+ }
+ }
+
+ writer.endElement(HtmlConstants.SPAN_ELEM);
+ }
+
+ public HashMap<String, Object> encodeOptions(FacesContext context, AbstractCollapsibleSubTableToggler toggleControl, AbstractCollapsibleSubTable subTable) {
+ String forId = subTable.getClientId(context);
+ String toggleControlId = toggleControl.getClientId(context);
+
+ HashMap<String, Object> options = new HashMap<String, Object>();
+ options.put("forId", forId);
+ options.put("expandControl", toggleControlId + ":expand");
+ options.put("collapseControl", toggleControlId + ":collapse");
+
+ String eventName = toggleControl.getEvent();
+ eventName = eventName.trim().startsWith("on") ? eventName.substring(2) : eventName;
+ options.put("eventName", eventName);
+ return options;
+ }
+
+ public String getStyleClass(FacesContext context, AbstractCollapsibleSubTableToggler control) {
+ return null;
+ }
+
+ public String getStyle(FacesContext context, AbstractCollapsibleSubTableToggler control) {
+ return null;
+ }
+
+ protected AbstractCollapsibleSubTable findComponent(FacesContext context, AbstractCollapsibleSubTableToggler toggleControl) {
+ String forId = toggleControl.getFor();
+ if (forId != null && forId.length() > 0) {
+
+ UIComponent subTable = RENDERER_UTILS.findComponentFor(context, toggleControl, forId);
+ if (subTable instanceof AbstractCollapsibleSubTable) {
+ return (AbstractCollapsibleSubTable) subTable;
+ }
+ }
+ return null;
+ }
+
+ protected String getState(boolean expand) {
+ return expand ? EXPAND_STATE : COLLAPSE_STATE;
+ }
+
+}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-12-03 16:30:40 UTC (rev 20368)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-12-03 16:44:29 UTC (rev 20369)
@@ -37,7 +37,7 @@
import org.ajax4jsf.javascript.JSFunction;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.component.AbstractDataTable;
-import org.richfaces.component.AbstractSubTable;
+import org.richfaces.component.AbstractCollapsibleSubTable;
import org.richfaces.component.Row;
import org.richfaces.component.UIDataTableBase;
import org.richfaces.component.util.HtmlUtil;
@@ -158,7 +158,7 @@
UIComponent child = components.next();
if (child.isRendered()) {
if (child instanceof Row) {
- boolean isSubtable = (child instanceof AbstractSubTable);
+ boolean isSubtable = (child instanceof AbstractCollapsibleSubTable);
// new row -> close </tr>
if (rowHolder.getProcessCell() != 0) {
encodeRowEnd(writer);
Deleted: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2010-12-03 16:30:40 UTC (rev 20368)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2010-12-03 16:44:29 UTC (rev 20369)
@@ -1,412 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-
-package org.richfaces.renderkit;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.faces.application.ResourceDependencies;
-import javax.faces.application.ResourceDependency;
-import javax.faces.component.UIColumn;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.event.AbortProcessingException;
-
-import org.ajax4jsf.javascript.JSFunction;
-import org.richfaces.cdk.annotations.JsfRenderer;
-import org.richfaces.component.AbstractDataTable;
-import org.richfaces.component.AbstractSubTable;
-import org.richfaces.component.Row;
-import org.richfaces.component.UIDataTableBase;
-import org.richfaces.event.ToggleEvent;
-import org.richfaces.renderkit.util.AjaxRendererUtils;
-
-/**
- * @author Anton Belevich
- *
- */
-
-@JsfRenderer(type = "org.richfaces.SubTableRenderer", family = AbstractSubTable.COMPONENT_FAMILY)
-@ResourceDependencies({
- @ResourceDependency(name = "jquery.js"),
- @ResourceDependency(name = "richfaces.js"),
- @ResourceDependency(library="org.richfaces", name = "subtable.js")
-})
-public class SubTableRenderer extends AbstractTableRenderer {
-
- public static final String TB_ROW = ":c";
-
- private static final String STATE = ":state";
-
- private static final String OPTIONS = ":options";
-
- private static final String DISPLAY_NONE = "display: none;";
-
- private class SubTableHiddenEncodeStrategy implements EncodeStrategy {
-
- public void begin(ResponseWriter writer, FacesContext context, UIComponent component, Object[] params) throws IOException {
- AbstractSubTable subTable = (AbstractSubTable)component;
- writer.startElement(HtmlConstants.TR_ELEMENT, subTable);
- writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, subTable.getClientId(context) + HIDDEN_CONTAINER_ID, null);
- writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, DISPLAY_NONE, null);
- writer.startElement(HtmlConstants.TD_ELEM, subTable);
- }
-
- public void end(ResponseWriter writer, FacesContext context, UIComponent component, Object[] params) throws IOException {
- writer.endElement(HtmlConstants.TD_ELEM);
- writer.endElement(HtmlConstants.TR_ELEMENT);
-
- if(params != null && params.length ==1) {
- boolean endTbody = (Boolean)params[0];
- if(endTbody) {
- encodeTableBodyEnd(writer);
- }
- }
- }
-
- };
-
- protected void doDecode(FacesContext facesContext, UIComponent component) {
- AbstractSubTable subTable = (AbstractSubTable)component;
-
- String clientId = subTable.getClientId(facesContext);
- Map<String, String> requestMap = facesContext.getExternalContext().getRequestParameterMap();
-
- String optionsId = clientId + OPTIONS;
- String togglerId = requestMap.get(optionsId);
-
- String stateId = clientId + STATE;
- String state = (String)requestMap.get(stateId);
-
- boolean isExpand = true;
- if(state != null) {
- int newValue = Integer.parseInt(state);
-
- if(newValue < 1) {
- isExpand = false;
- }
-
- if(subTable.isExpanded() != isExpand) {
- new ToggleEvent(subTable, isExpand, togglerId).queue();
- }
- }
- }
-
- @Override
- public void encodeFirstRowStart(ResponseWriter writer, FacesContext context, String parentId, int currentRow, UIComponent component) throws IOException {
- writer.startElement(HtmlConstants.TR_ELEMENT, component);
- writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, parentId + ":" + currentRow + ":b", null);
- String styleClass = getFirstRowClass(context, parentId);
- encodeStyleClass(writer, context, component, HtmlConstants.STYLE_CLASS_ATTR, styleClass);
- }
-
- @Override
- public void encodeRowStart(ResponseWriter writer, FacesContext context, String parentId, int currentRow, UIComponent component) throws IOException {
- writer.startElement(HtmlConstants.TR_ELEMENT, component);
- writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, parentId + ":" + currentRow + ":b", null);
- String styleClass = getRowClass(context, parentId);
- encodeStyleClass(writer, context, component, HtmlConstants.STYLE_CLASS_ATTR, styleClass);
- }
-
- public void encodeTableFacets(ResponseWriter writer, FacesContext context, UIDataTableBase dataTable) throws IOException {
- AbstractSubTable subTable = (AbstractSubTable)dataTable;
-
- encodeHeaderFacet(writer, context, subTable, false);
-
- String rowClass = getRowSkinClass();
- String cellClass = getCellSkinClass();
- String firstClass = getFirstRowSkinClass();
-
- rowClass = mergeStyleClasses("rowClass", rowClass, subTable);
- cellClass = mergeStyleClasses("cellClass", cellClass, subTable);
- firstClass = mergeStyleClasses("firstRowClass", firstClass, subTable);
-
- saveRowStyles(context, subTable.getClientId(context), firstClass, rowClass, cellClass);
- }
-
- @Override
- public void encodeTableBodyStart(ResponseWriter writer, FacesContext facesContext, UIDataTableBase dataTableBase) throws IOException {
- AbstractSubTable subTable = (AbstractSubTable)dataTableBase;
-
- UIDataTableBase component = findParent(subTable);
- if(component instanceof AbstractDataTable) {
- writer.startElement(HtmlConstants.TBODY_ELEMENT, null);
- writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, component.getRelativeClientId(facesContext) + ":" + subTable.getId() + TB_ROW, null);
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, getTableSkinClass(), null);
-
- String predefinedStyles = !subTable.isExpanded() ? DISPLAY_NONE : null;
- encodeStyle(writer, facesContext, subTable, predefinedStyles);
- }
- }
-
- @Override
- public void encodeBeforeRows(ResponseWriter writer, FacesContext facesContext, UIDataTableBase dataTableBase, boolean encodeParentTBody, boolean partialUpdate) throws IOException {
- AbstractSubTable subTable = (AbstractSubTable)dataTableBase;
- encodeTableBodyStart(writer, facesContext, subTable);
- encodeSubTableDomElement(writer, facesContext, subTable);
- setupTableStartElement(facesContext, subTable);
- encodeHeaderFacet(writer, facesContext, subTable, false);
- }
-
- private void encodeSubTableDomElement(ResponseWriter writer, FacesContext facesContext, AbstractSubTable subTable) throws IOException{
- writer.startElement(HtmlConstants.TR_ELEMENT, subTable);
- writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, DISPLAY_NONE, null);
- writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, subTable.getClientId(facesContext), null);
- writer.startElement(HtmlConstants.TD_ELEM, subTable);
- writer.endElement(HtmlConstants.TD_ELEM);
- writer.endElement(HtmlConstants.TR_ELEMENT);
- }
-
- public void encodeRow(ResponseWriter writer, FacesContext facesContext, RowHolderBase holder) throws IOException {
- RowHolder rowHolder = (RowHolder)holder;
- Row row = rowHolder.getRow();
-
- rowHolder.setRowStart(true);
- Iterator<UIComponent> components = row.columns();
- if (rowHolder.isUpdatePartial()) {
- partialStart(facesContext,((AbstractSubTable) row).getRelativeClientId(facesContext) + ":b");
- }
-
- while (components.hasNext()) {
- UIComponent component = components.next();
- if(component.isRendered()) {
- if(component instanceof UIColumn ) {
- encodeColumn(facesContext, writer, (UIColumn)component , rowHolder);
-
- } else if (component instanceof AbstractSubTable) {
- if(component.isRendered()) {
- encodeRowEnd(writer);
- }
-
- component.encodeAll(facesContext);
- rowHolder.setRowStart(true);
- }
- }
- }
-
- encodeRowEnd(writer);
-
- if (rowHolder.isUpdatePartial()) {
- partialEnd(facesContext);
- }
- }
-
- @Override
- public void encodeAfterRows(ResponseWriter writer, FacesContext facesContext, UIDataTableBase dataTableBase,
- boolean encodeParentTBody, boolean partialUpdate) throws IOException {
- AbstractSubTable subTable = (AbstractSubTable)dataTableBase;
- encodeFooterFacet(writer, facesContext, subTable, false);
- }
-
- @Override
- public boolean encodeParentTBody(UIDataTableBase dataTableBase) {
- UIDataTableBase parent = findParent((AbstractSubTable)dataTableBase);
- return (parent instanceof AbstractDataTable);
- }
-
- public void encodeHiddenInput(ResponseWriter writer, FacesContext facesContext, UIDataTableBase dataTableBase)
- throws IOException {
- AbstractSubTable subTable = (AbstractSubTable) dataTableBase;
-
- String stateId = subTable.getClientId(facesContext) + STATE;
-
- writer.startElement(HtmlConstants.INPUT_ELEM, subTable);
- writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, stateId, null);
- writer.writeAttribute(HtmlConstants.NAME_ATTRIBUTE, stateId, null);
- writer.writeAttribute(HtmlConstants.TYPE_ATTR, HtmlConstants.INPUT_TYPE_HIDDEN, null);
-
- int state = subTable.isExpanded() ? AbstractSubTable.EXPAND_STATE : AbstractSubTable.COLLAPSE_STATE;
-
- writer.writeAttribute(HtmlConstants.VALUE_ATTRIBUTE, state, null);
- writer.endElement(HtmlConstants.INPUT_ELEM);
-
- String optionsId = subTable.getClientId(facesContext) + OPTIONS;
- writer.startElement(HtmlConstants.INPUT_ELEM, subTable);
- writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, optionsId, null);
- writer.writeAttribute(HtmlConstants.NAME_ATTRIBUTE, optionsId, null);
- writer.writeAttribute(HtmlConstants.TYPE_ATTR, HtmlConstants.INPUT_TYPE_HIDDEN, null);
- writer.endElement(HtmlConstants.INPUT_ELEM);
-
- }
-
- public boolean containsThead() {
- return false;
- }
-
- public EncodeStrategy getHeaderEncodeStrategy(UIComponent column, String tableFacetName) {
- //TODO: anton -> use RichHeaderEncodeStrategy for our columns ???
- return new SimpleHeaderEncodeStrategy();
-
- }
-
- public void encodeClientScript(ResponseWriter writer, FacesContext facesContext, UIDataTableBase component)
- throws IOException {
- AbstractSubTable subTable = (AbstractSubTable) component;
-
- String id = subTable.getClientId(facesContext);
-
- UIComponent nestingForm = getUtils().getNestingForm(facesContext, subTable);
- String formId = nestingForm != null ? nestingForm.getClientId(facesContext) : "";
-
- Map<String, Object> options = new HashMap<String, Object>();
- options.put("stateInput", subTable.getClientId(facesContext) + STATE);
- options.put("optionsInput", subTable.getClientId(facesContext) + OPTIONS);
- options.put("expandMode", subTable.getExpandMode());
- options.put("eventOptions", AjaxRendererUtils.buildEventOptions(facesContext, subTable));
-
- JSFunction jsFunction = new JSFunction("new RichFaces.ui.SubTable");
- jsFunction.addParameter(id);
- jsFunction.addParameter(formId);
- jsFunction.addParameter(options);
-
- writer.startElement(HtmlConstants.SCRIPT_ELEM, subTable);
- writer.writeAttribute(HtmlConstants.TYPE_ATTR, HtmlConstants.JAVASCRIPT_TYPE, null);
- writer.writeText(jsFunction.toScript(), null);
- writer.endElement(HtmlConstants.SCRIPT_ELEM);
- }
-
- public String getTableSkinClass() {
- return "rf-st";
- }
-
- public String getRowSkinClass() {
- return "rf-st-r";
- }
-
- public String getFirstRowSkinClass() {
- return "rf-st-fst-r";
- }
-
- public String getHeaderRowSkinClass() {
- return "rf-st-hdr-r";
- }
-
- public String getHeaderFirstRowSkinClass() {
- return "rf-st-hdr-fst-r";
- }
-
- public String getCellSkinClass() {
- return "rf-st-c";
- }
-
- public String getHeaderCellSkinClass() {
- return "rf-st-hdr-c";
- }
-
- public String getColumnHeaderCellSkinClass() {
- return "rf-st-shdr-c";
- }
-
- public String getColumnHeaderSkinClass() {
- return "rf-st-shdr";
- }
-
- public String getFooterSkinClass() {
- return "rf-st-ftr";
- }
-
- public String getFooterCellSkinClass() {
- return "rf-st-ftr-c";
- }
-
- public String getFooterFirstRowSkinClass() {
- return "rf-st-ftr-fst";
- }
-
- public String getColumnFooterCellSkinClass() {
- return "rf-st-sftr-c";
- }
-
- public String getColumnFooterSkinClass() {
- return "rf-st-sftr";
- }
-
- public String getColumnFooterFirstSkinClass() {
- return "rf-st-sftr-fst";
- }
-
- public String getColumnHeaderFirstSkinClass() {
- return "rf-st-shdr-fst";
- }
-
- public String getFooterFirstSkinClass() {
- return "rf-st-ftr-fst";
- }
-
- public String getHeaderFirstSkinClass() {
- return "rf-st-hdr-fst";
- }
-
- public String getHeaderSkinClass() {
- return "rf-st-hdr";
- }
-
- public String getNoDataClass() {
- return "rf-st-nd-c";
- }
-
- @Override
- public void encodeMetaComponent(FacesContext facesContext, UIComponent component, String metaComponentId)
- throws IOException {
- AbstractSubTable subTable = (AbstractSubTable)component;
- setupTableStartElement(facesContext, subTable);
-
- if(AbstractSubTable.BODY.equals(metaComponentId)) {
- ResponseWriter writer = facesContext.getResponseWriter();
- UIDataTableBase dataTableBase = findParent(subTable);
-
- String updateId = dataTableBase.getRelativeClientId(facesContext) + ":" + subTable.getId() + TB_ROW;
-
- partialStart(facesContext, updateId);
- encodeTableRows(writer, facesContext, subTable, false);
- partialEnd(facesContext);
- }
- }
-
- @Override
- public EncodeStrategy getHiddenContainerStrategy(UIDataTableBase dataTableBase) {
- return new SubTableHiddenEncodeStrategy();
- }
-
- protected void setupTableStartElement(FacesContext context, UIComponent component) {
- setupTableStartElement(context, component, HtmlConstants.TD_ELEM);
- }
-
- protected UIDataTableBase findParent(AbstractSubTable subTable) {
- UIComponent parent = subTable.getParent();
-
- while(parent != null && !(parent instanceof UIDataTableBase)) {
- parent = parent.getParent();
- }
-
- if(parent == null){
- //TODO: anton -> do we need this?
- throw new AbortProcessingException("UISubTable should be a child of UIDataTable or UISubTable");
- }
- return (UIDataTableBase)parent;
- }
-}
Deleted: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java 2010-12-03 16:30:40 UTC (rev 20368)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java 2010-12-03 16:44:29 UTC (rev 20369)
@@ -1,209 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.richfaces.renderkit;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.application.ResourceDependencies;
-import javax.faces.application.ResourceDependency;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.javascript.JSFunction;
-import org.richfaces.cdk.annotations.JsfRenderer;
-import org.richfaces.component.AbstractSubTable;
-import org.richfaces.component.AbstractSubTableToggleControl;
-import org.richfaces.renderkit.util.RendererUtils;
-
-/**
- * @author Anton Belevich
- */
-
-
-@JsfRenderer(type = "org.richfaces.SubTableToggleControlRenderer", family = AbstractSubTableToggleControl.COMPONENT_FAMILY)
-@ResourceDependencies(
- {@ResourceDependency(library = "javax.faces", name = "jsf.js"),
- @ResourceDependency(name = "richfaces.js"),
- @ResourceDependency(name = "richfaces-event.js"),
- @ResourceDependency(library="org.richfaces", name = "subtable-toggler.js")
-})
-public class SubTableToggleControlRendererBase extends RendererBase {
-
- /**
- *
- */
- private static final RendererUtils RENDERER_UTILS = RendererUtils.getInstance();
-
- private static final String DISPLAY_NONE = "display: none;";
-
- private static final String UP_ICON_URL = "org.richfaces/up_icon.gif";
-
- private static final String DOWN_ICON_URL = "org.richfaces/down_icon.gif";
-
- private static final String EXPAND_STATE = "expand";
-
- private static final String COLLAPSE_STATE = "collapse";
-
- @Override
- protected void doDecode(FacesContext context, UIComponent component) {
- context.getPartialViewContext().getRenderIds().add(component.getClientId(context));
- }
-
- protected void encodeControl(FacesContext context, UIComponent component) throws IOException {
- AbstractSubTableToggleControl toggleControl = (AbstractSubTableToggleControl) component;
- AbstractSubTable subTable = findComponent(context, toggleControl);
-
- if (subTable != null) {
- String switchType = subTable.getExpandMode();
- boolean expanded = subTable.isExpanded();
-
- ResponseWriter writer = context.getResponseWriter();
- encodeControl(context, writer, toggleControl, switchType, expanded, false);
- encodeControl(context, writer, toggleControl, switchType, !expanded, true);
-
- JSFunction jsFunction = new JSFunction("new RichFaces.ui.SubTableToggler");
- String toggleId = toggleControl.getClientId(context);
- jsFunction.addParameter(toggleId);
- Map<String, Object> options = encodeOptions(context, toggleControl, subTable);
- jsFunction.addParameter(options);
-
- writer.startElement(HtmlConstants.SCRIPT_ELEM, subTable);
- writer.writeText(jsFunction.toScript(), null);
- writer.endElement(HtmlConstants.SCRIPT_ELEM);
- }
- }
-
- protected void encodeControl(FacesContext context, ResponseWriter writer, AbstractSubTableToggleControl control,
- String switchType, boolean expanded, boolean visible) throws IOException {
- String state = getState(expanded);
- String styleClass = getStyleClass(context, control);
- String style = getStyle(context, control);
-
- writer.startElement(HtmlConstants.SPAN_ELEM, control);
-
- if (!visible) {
- writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, DISPLAY_NONE, null);
- }
-
- writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, control.getClientId() + ":" + state, null);
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, styleClass, null);
- writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, style, null);
-
- boolean encodeDefault = true;
-
- UIComponent controlFacet = control.getFacet(state);
- if (controlFacet != null && controlFacet.isRendered()) {
-
- if (!visible) {
- String facetStyle = (String) controlFacet.getAttributes().get(HtmlConstants.STYLE_ATTRIBUTE);
- facetStyle = facetStyle != null ? facetStyle + ";" + DISPLAY_NONE : DISPLAY_NONE;
- controlFacet.getAttributes().put(HtmlConstants.STYLE_ATTRIBUTE, facetStyle);
- }
- controlFacet.encodeAll(context);
- encodeDefault = false;
- }
-
- String expandIcon = control.getExpandIcon();
- String collapseIcon = control.getCollapseIcon();
-
- if ((expandIcon != null && collapseIcon != null)
- && (expandIcon.trim().length() > 0 && collapseIcon.trim().length() > 0)) {
-
- String image = expanded ? expandIcon : collapseIcon;
- if (image != null && image.trim().length() > 0) {
- writer.startElement(HtmlConstants.IMG_ELEMENT, control);
- writer.writeAttribute(HtmlConstants.SRC_ATTRIBUTE, image, null);
- writer.writeAttribute(HtmlConstants.ALT_ATTRIBUTE, "", null);
- writer.endElement(HtmlConstants.IMG_ELEMENT);
- }
- encodeDefault = false;
- }
-
- String label = expanded ? control.getExpandLabel() : control.getCollapseLabel();
- if (label != null && label.trim().length() > 0) {
- writer.startElement(HtmlConstants.A_ELEMENT, control);
- writer.writeAttribute(HtmlConstants.HREF_ATTR, "javascript:void(0);", null);
- writer.writeText(label, null);
- writer.endElement(HtmlConstants.A_ELEMENT);
- encodeDefault = false;
- }
-
- if (encodeDefault) {
- expandIcon = context.getApplication().getResourceHandler().createResource(UP_ICON_URL).getRequestPath();
- collapseIcon = context.getApplication().getResourceHandler().createResource(DOWN_ICON_URL).getRequestPath();
-
- String image = expanded ? expandIcon : collapseIcon;
- if (image != null && image.trim().length() > 0) {
- writer.startElement(HtmlConstants.IMG_ELEMENT, control);
- writer.writeAttribute(HtmlConstants.SRC_ATTRIBUTE, image, null);
- writer.writeAttribute(HtmlConstants.ALT_ATTRIBUTE, "", null);
- writer.endElement(HtmlConstants.IMG_ELEMENT);
- }
- }
-
- writer.endElement(HtmlConstants.SPAN_ELEM);
- }
-
- public HashMap<String, Object> encodeOptions(FacesContext context, AbstractSubTableToggleControl toggleControl, AbstractSubTable subTable) {
- String forId = subTable.getClientId(context);
- String toggleControlId = toggleControl.getClientId(context);
-
- HashMap<String, Object> options = new HashMap<String, Object>();
- options.put("forId", forId);
- options.put("expandControl", toggleControlId + ":expand");
- options.put("collapseControl", toggleControlId + ":collapse");
-
- String eventName = toggleControl.getEvent();
- eventName = eventName.trim().startsWith("on") ? eventName.substring(2) : eventName;
- options.put("eventName", eventName);
- return options;
- }
-
- public String getStyleClass(FacesContext context, AbstractSubTableToggleControl control) {
- return null;
- }
-
- public String getStyle(FacesContext context, AbstractSubTableToggleControl control) {
- return null;
- }
-
- protected AbstractSubTable findComponent(FacesContext context, AbstractSubTableToggleControl toggleControl) {
- String forId = toggleControl.getFor();
- if (forId != null && forId.length() > 0) {
-
- UIComponent subTable = RENDERER_UTILS.findComponentFor(context, toggleControl, forId);
- if (subTable instanceof AbstractSubTable) {
- return (AbstractSubTable) subTable;
- }
- }
- return null;
- }
-
- protected String getState(boolean expand) {
- return expand ? EXPAND_STATE : COLLAPSE_STATE;
- }
-
-}
Added: trunk/ui/iteration/ui/src/main/java/org/richfaces/taglib/CollapsibleSubTableHandler.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/taglib/CollapsibleSubTableHandler.java (rev 0)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/taglib/CollapsibleSubTableHandler.java 2010-12-03 16:44:29 UTC (rev 20369)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+package org.richfaces.taglib;
+
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRule;
+import javax.faces.view.facelets.MetaRuleset;
+import javax.faces.view.facelets.Metadata;
+import javax.faces.view.facelets.MetadataTarget;
+import javax.faces.view.facelets.TagAttribute;
+
+import org.richfaces.component.AbstractCollapsibleSubTable;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public class CollapsibleSubTableHandler extends ComponentHandler {
+
+ private static final CollapsibleSubTableHandlerMetaRule METARULE = new CollapsibleSubTableHandlerMetaRule();
+
+
+ public CollapsibleSubTableHandler(ComponentConfig config) {
+ super(config);
+ }
+
+ protected MetaRuleset createMetaRuleset(Class type) {
+ MetaRuleset m = super.createMetaRuleset(type);
+ m.addRule(METARULE);
+ return m;
+ }
+
+ static class CollapsibleSubTableHandlerMetaRule extends MetaRule {
+
+ public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
+ if (meta.isTargetInstanceOf(AbstractCollapsibleSubTable.class) && "toggleListener".equals(name)) {
+ return new CollapsibleSubTableMapper(attribute);
+ }
+ return null;
+ }
+
+ }
+
+ static class CollapsibleSubTableMapper extends Metadata {
+
+ private static final Class[] SIGNATURE = new Class[] { org.richfaces.event.ToggleEvent.class };
+
+ private final TagAttribute attribute;
+
+ public CollapsibleSubTableMapper(TagAttribute attribute) {
+ this.attribute = attribute;
+ }
+
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((AbstractCollapsibleSubTable) instance).addToggleListener((new MethodExpressionToggleListener(this.attribute.getMethodExpression(ctx, null, SIGNATURE))));
+ }
+ }
+}
Deleted: trunk/ui/iteration/ui/src/main/java/org/richfaces/taglib/SubTableHandler.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/taglib/SubTableHandler.java 2010-12-03 16:30:40 UTC (rev 20368)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/taglib/SubTableHandler.java 2010-12-03 16:44:29 UTC (rev 20369)
@@ -1,81 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-
-package org.richfaces.taglib;
-
-import javax.faces.view.facelets.ComponentConfig;
-import javax.faces.view.facelets.ComponentHandler;
-import javax.faces.view.facelets.FaceletContext;
-import javax.faces.view.facelets.MetaRule;
-import javax.faces.view.facelets.MetaRuleset;
-import javax.faces.view.facelets.Metadata;
-import javax.faces.view.facelets.MetadataTarget;
-import javax.faces.view.facelets.TagAttribute;
-
-import org.richfaces.component.AbstractSubTable;
-
-/**
- * @author Anton Belevich
- *
- */
-public class SubTableHandler extends ComponentHandler {
-
- private static final SubTableHandlerMetaRule METARULE = new SubTableHandlerMetaRule();
-
-
- public SubTableHandler(ComponentConfig config) {
- super(config);
- }
-
- protected MetaRuleset createMetaRuleset(Class type) {
- MetaRuleset m = super.createMetaRuleset(type);
- m.addRule(METARULE);
- return m;
- }
-
- static class SubTableHandlerMetaRule extends MetaRule {
-
- public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
- if (meta.isTargetInstanceOf(AbstractSubTable.class) && "toggleListener".equals(name)) {
- return new SubTableMapper(attribute);
- }
- return null;
- }
-
- }
-
- static class SubTableMapper extends Metadata {
-
- private static final Class[] SIGNATURE = new Class[] { org.richfaces.event.ToggleEvent.class };
-
- private final TagAttribute attribute;
-
- public SubTableMapper(TagAttribute attribute) {
- this.attribute = attribute;
- }
-
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((AbstractSubTable) instance).addToggleListener((new MethodExpressionToggleListener(this.attribute.getMethodExpression(ctx, null, SIGNATURE))));
- }
- }
-}
Added: trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/collapsible-subtable-toggler.js
===================================================================
--- trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/collapsible-subtable-toggler.js (rev 0)
+++ trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/collapsible-subtable-toggler.js 2010-12-03 16:44:29 UTC (rev 20369)
@@ -0,0 +1,57 @@
+(function ($, richfaces) {
+
+ richfaces.ui = richfaces.ui || {};
+
+ richfaces.ui.CollapsibleSubTableToggler = function(id, options) {
+ this.id = id;
+ this.eventName = options.eventName;
+ this.expandControl = options.expandControl;
+ this.collapseControl = options.collapseControl;
+ this.forId = options.forId;
+ this.element = $(document.getElementById(this.id));
+
+ if(this.element && this.eventName) {
+ this.element.bind(this.eventName, $.proxy(this.toggle, this));
+ }
+ };
+
+ $.extend(richfaces.ui.CollapsibleSubTableToggler.prototype, (function () {
+
+ var getElementById= function(id) {
+ return $(document.getElementById(id))
+ }
+
+ return {
+
+ toggle: function(e) {
+ var subtable = richfaces.$(this.forId);
+ if(subtable) {
+ var mode = subtable.getMode();
+
+ if(richfaces.ui.CollapsibleSubTable.MODE_CLNT == mode) {
+ this.toggleControl(subtable.isExpand());
+ }
+
+ subtable.setOption(this.id);
+ subtable.toggle(e);
+ }
+ },
+
+ toggleControl: function(expanded) {
+ var expandControl = getElementById(this.expandControl);
+ var collapseControl = getElementById(this.collapseControl);
+
+ if(expanded) {
+ collapseControl.hide();
+ expandControl.show();
+ } else {
+ expandControl.hide();
+ collapseControl.show();
+ }
+ }
+
+ };
+
+ })());
+
+})(jQuery, window.RichFaces);
\ No newline at end of file
Added: trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/collapsible-subtable.ecss
===================================================================
--- trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/collapsible-subtable.ecss (rev 0)
+++ trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/collapsible-subtable.ecss 2010-12-03 16:44:29 UTC (rev 20369)
@@ -0,0 +1,113 @@
+.rf-cst{
+}
+
+.rf-cst-r{
+}
+
+.rf-cst-fst-r{
+}
+
+.rf-cst-hdr-r{
+}
+
+.rf-cst-hdr-fst-r{
+}
+
+.rf-cst-c{
+ border-bottom-width:'#{richSkin.tableBorderWidth}';
+ border-bottom-style:solid;
+ border-bottom-color:'#{richSkin.tableBorderColor}';
+ border-right-width:'#{richSkin.tableBorderWidth}';
+ border-right-style:solid;
+ border-right-color:'#{richSkin.tableBorderColor}';
+ color:'#{richSkin.generalTextColor}';
+ background-color:'#{richSkin.tableBackgroundColor}';
+ font-family:'#{richSkin.generalFamilyFont}';
+ font-size:'#{richSkin.generalSizeFont}';
+ padding:4px;
+}
+
+.rf-cst-hdr-c{
+ border-bottom-width:'#{richSkin.tableBorderWidth}';
+ border-bottom-style:solid;
+ border-bottom-color:'#{richSkin.tableBorderColor}';
+ border-right-width:'#{richSkin.tableBorderWidth}';
+ border-right-style:solid;
+ border-right-color:'#{richSkin.tableBorderColor}';
+ color:'#{richSkin.generalTextColor}';
+ background-color:'#{richSkin.tableSubHeaderBackgroundColor}';
+ font-family:'#{richSkin.generalFamilyFont}';
+ font-size:'#{richSkin.generalSizeFont}';
+ font-weight:bold;
+ padding:4px;
+ text-align:left;
+}
+
+.rf-cst-shdr-c{
+ border-bottom-width:'#{richSkin.tableBorderWidth}';
+ border-bottom-style:solid;
+ border-bottom-color:'#{richSkin.tableBorderColor}';
+ border-right-width:'#{richSkin.tableBorderWidth}';
+ border-right-style:solid;
+ border-right-color:'#{richSkin.tableBorderColor}';
+ background-color:'#{richSkin.tableSubHeaderBackgroundColor}';
+ color:'#{richSkin.generalTextColor}';
+ font-family:'#{richSkin.generalFamilyFont}';
+ font-size:'#{richSkin.generalSizeFont}';
+ font-weight:bold;
+ padding:4px;
+}
+
+.rf-cst-shdr{
+}
+
+.rf-cst-ftr {
+}
+
+.rf-cst-ftr-c{
+ border-bottom-width:3px;
+ border-bottom-style:solid;
+ border-bottom-color:'#{richSkin.tableBorderColor}';
+ border-right-width:'#{richSkin.tableBorderWidth}';
+ border-right-style:solid;
+ border-right-color:'#{richSkin.tableBorderColor}';
+ background-color:'#{richSkin.tableSubfooterBackgroundColor}';
+ color:'#{richSkin.generalTextColor}';
+ font-family:'#{richSkin.generalFamilyFont}';
+ font-size: '#{richSkin.generalSizeFont}';
+ font-weight:bold;
+ padding:4px;
+ text-align:left;
+}
+
+.rf-cst-sftr-c{
+ border-bottom-width:'#{richSkin.tableBorderWidth}';
+ border-bottom-style:solid;
+ border-bottom-color:'#{richSkin.tableBorderColor}';
+ border-right-width:'#{richSkin.tableBorderWidth}';
+ border-right-style:solid;
+ border-right-color:'#{richSkin.tableBorderColor}';
+ background-color:'#{richSkin.tableSubfooterBackgroundColor}';
+ color:'#{richSkin.generalTextColor}';
+ font-family:'#{richSkin.generalFamilyFont}';
+ font-size:'#{richSkin.generalSizeFont}';
+ padding:4px;
+}
+
+.rf-cst-sftr{
+}
+
+.rf-cst-sftr-fst{
+}
+
+.rf-cst-shdr-fst{
+}
+
+.rf-cst-ftr-fst{
+}
+
+.rf-cst-hdr-fst{
+}
+
+.rf-cst-hdr{
+}
Added: trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/collapsible-subtable.js
===================================================================
--- trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/collapsible-subtable.js (rev 0)
+++ trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/collapsible-subtable.js 2010-12-03 16:44:29 UTC (rev 20369)
@@ -0,0 +1,115 @@
+(function ($, richfaces) {
+
+ richfaces.ui = richfaces.ui || {};
+
+ richfaces.ui.CollapsibleSubTable = function(id, f, options) {
+ this.id = id;
+ this.stateInput = options.stateInput;
+ this.optionsInput = options.optionsInput;
+ this.expandMode = options.expandMode;
+ this.eventOptions = options.eventOptions;
+ this.formId = f;
+
+ $super.constructor.call(this, id);
+ this.attachToDom(id);
+ };
+
+ $.extend(richfaces.ui.CollapsibleSubTable, {
+ MODE_AJAX: "ajax",
+ MODE_SRV: "server",
+ MODE_CLNT: "client",
+ collapse: 0,
+ expand: 1
+ })
+
+ var $super = richfaces.BaseComponent.extend(richfaces.ui.CollapsibleSubTable);
+ var $p = richfaces.BaseComponent.extend(richfaces.ui.CollapsibleSubTable, {});
+ var $super = richfaces.ui.CollapsibleSubTable.$super;
+
+ $.extend(richfaces.ui.CollapsibleSubTable.prototype, (function () {
+
+ var element = function() {
+ //use parent tbody as parent dom elem
+ return $(document.getElementById(this.id)).parent();
+ };
+
+ var stateInputElem = function() {
+ return $(document.getElementById(this.stateInput));
+ };
+
+ var optionsInputElem = function() {
+ return $(document.getElementById(this.optionsInput));
+ };
+
+ var ajax = function(e, options) {
+ this.switchState();
+ richfaces.ajax(this.id, e, options);
+ };
+
+ var server = function(options) {
+ this.switchState();
+ $(document.getElementById(this.formId)).submit();
+ };
+
+ var client = function(options) {
+ if(this.isExpand()) {
+ this.collapse(options);
+ } else {
+ this.expand(options);
+ }
+ };
+
+
+ return {
+
+ name: "RichFaces.ui.CollapsibleSubTable",
+
+ toggle: function(e, options) {
+ if(this.expandMode == richfaces.ui.CollapsibleSubTable.MODE_AJAX) {
+ ajax.call(this, e, this.eventOptions, options);
+ }else if(this.expandMode == richfaces.ui.CollapsibleSubTable.MODE_SRV) {
+ server.call(this, options);
+ }else if(this.expandMode == richfaces.ui.CollapsibleSubTable.MODE_CLNT) {
+ client.call(this, options);
+ }
+ },
+
+ collapse: function(options) {
+ this.setState(richfaces.ui.CollapsibleSubTable.collapse);
+ element.call(this).hide();
+ },
+
+ expand: function(options) {
+ this.setState(richfaces.ui.CollapsibleSubTable.expand);
+ element.call(this).show();
+ },
+
+ isExpand: function() {
+ return (parseInt(this.getState()) == richfaces.ui.CollapsibleSubTable.expand);
+ },
+
+ switchState: function(options) {
+ var state = this.isExpand() ? richfaces.ui.CollapsibleSubTable.collapse : richfaces.ui.CollapsibleSubTable.expand;
+ this.setState(state);
+ },
+
+ getState: function() {
+ return stateInputElem.call(this).val();
+ },
+
+ setState: function(state) {
+ stateInputElem.call(this).val(state)
+ },
+
+ setOption: function(option) {
+ optionsInputElem.call(this).val(option);
+ },
+
+ getMode: function() {
+ return this.expandMode;
+ }
+ };
+
+ })());
+
+})(jQuery, window.RichFaces);
\ No newline at end of file
Modified: trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/datatable.ecss
===================================================================
--- trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/datatable.ecss 2010-12-03 16:30:40 UTC (rev 20368)
+++ trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/datatable.ecss 2010-12-03 16:44:29 UTC (rev 20369)
@@ -146,121 +146,6 @@
text-align:center;
}
-.rf-st{
-}
-
-.rf-st-r{
-}
-
-.rf-st-fst-r{
-}
-
-.rf-st-hdr-r{
-}
-
-.rf-st-hdr-fst-r{
-}
-
-.rf-st-c{
- border-bottom-width:'#{richSkin.tableBorderWidth}';
- border-bottom-style:solid;
- border-bottom-color:'#{richSkin.tableBorderColor}';
- border-right-width:'#{richSkin.tableBorderWidth}';
- border-right-style:solid;
- border-right-color:'#{richSkin.tableBorderColor}';
- color:'#{richSkin.generalTextColor}';
- background-color:'#{richSkin.tableBackgroundColor}';
- font-family:'#{richSkin.generalFamilyFont}';
- font-size:'#{richSkin.generalSizeFont}';
- padding:4px;
-}
-
-.rf-st-hdr-c{
- border-bottom-width:'#{richSkin.tableBorderWidth}';
- border-bottom-style:solid;
- border-bottom-color:'#{richSkin.tableBorderColor}';
- border-right-width:'#{richSkin.tableBorderWidth}';
- border-right-style:solid;
- border-right-color:'#{richSkin.tableBorderColor}';
- color:'#{richSkin.generalTextColor}';
- background-color:'#{richSkin.tableSubHeaderBackgroundColor}';
- font-family:'#{richSkin.generalFamilyFont}';
- font-size:'#{richSkin.generalSizeFont}';
- font-weight:bold;
- padding:4px;
- text-align:left;
-}
-
-.rf-st-shdr-c{
- border-bottom-width:'#{richSkin.tableBorderWidth}';
- border-bottom-style:solid;
- border-bottom-color:'#{richSkin.tableBorderColor}';
- border-right-width:'#{richSkin.tableBorderWidth}';
- border-right-style:solid;
- border-right-color:'#{richSkin.tableBorderColor}';
- background-color:'#{richSkin.tableSubHeaderBackgroundColor}';
- color:'#{richSkin.generalTextColor}';
- font-family:'#{richSkin.generalFamilyFont}';
- font-size:'#{richSkin.generalSizeFont}';
- font-weight:bold;
- padding:4px;
-}
-
-.rf-st-shdr{
-}
-
-.rf-st-ftr {
-}
-
-.rf-st-ftr-c{
- border-bottom-width:3px;
- border-bottom-style:solid;
- border-bottom-color:'#{richSkin.tableBorderColor}';
- border-right-width:'#{richSkin.tableBorderWidth}';
- border-right-style:solid;
- border-right-color:'#{richSkin.tableBorderColor}';
- background-color:'#{richSkin.tableSubfooterBackgroundColor}';
- color:'#{richSkin.generalTextColor}';
- font-family:'#{richSkin.generalFamilyFont}';
- font-size: '#{richSkin.generalSizeFont}';
- font-weight:bold;
- padding:4px;
- text-align:left;
-}
-
-.rf-st-sftr-c{
- border-bottom-width:'#{richSkin.tableBorderWidth}';
- border-bottom-style:solid;
- border-bottom-color:'#{richSkin.tableBorderColor}';
- border-right-width:'#{richSkin.tableBorderWidth}';
- border-right-style:solid;
- border-right-color:'#{richSkin.tableBorderColor}';
- background-color:'#{richSkin.tableSubfooterBackgroundColor}';
- color:'#{richSkin.generalTextColor}';
- font-family:'#{richSkin.generalFamilyFont}';
- font-size:'#{richSkin.generalSizeFont}';
- padding:4px;
-}
-
-.rf-st-sftr{
-}
-
-.rf-st-sftr-fst{
-}
-
-.rf-st-shdr-fst{
-}
-
-.rf-st-ftr-fst{
-}
-
-.rf-st-hdr-fst{
-}
-
-.rf-st-hdr{
-}
-
-
/*should be generated in M1*/
.rf-stt-exp{
background-image: url("#{resource['org.richfaces:up_icon.gif']}");
Deleted: trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/subtable-toggler.js
===================================================================
--- trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/subtable-toggler.js 2010-12-03 16:30:40 UTC (rev 20368)
+++ trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/subtable-toggler.js 2010-12-03 16:44:29 UTC (rev 20369)
@@ -1,57 +0,0 @@
-(function ($, richfaces) {
-
- richfaces.ui = richfaces.ui || {};
-
- richfaces.ui.SubTableToggler = function(id, options) {
- this.id = id;
- this.eventName = options.eventName;
- this.expandControl = options.expandControl;
- this.collapseControl = options.collapseControl;
- this.forId = options.forId;
- this.element = $(document.getElementById(this.id));
-
- if(this.element && this.eventName) {
- this.element.bind(this.eventName, $.proxy(this.toggle, this));
- }
- };
-
- $.extend(richfaces.ui.SubTableToggler.prototype, (function () {
-
- var getElementById= function(id) {
- return $(document.getElementById(id))
- }
-
- return {
-
- toggle: function(e) {
- var subtable = richfaces.$(this.forId);
- if(subtable) {
- var mode = subtable.getMode();
-
- if(richfaces.ui.SubTable.MODE_CLNT == mode) {
- this.toggleControl(subtable.isExpand());
- }
-
- subtable.setOption(this.id);
- subtable.toggle(e);
- }
- },
-
- toggleControl: function(expanded) {
- var expandControl = getElementById(this.expandControl);
- var collapseControl = getElementById(this.collapseControl);
-
- if(expanded) {
- collapseControl.hide();
- expandControl.show();
- } else {
- expandControl.hide();
- collapseControl.show();
- }
- }
-
- };
-
- })());
-
-})(jQuery, window.RichFaces);
\ No newline at end of file
Deleted: trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/subtable.js
===================================================================
--- trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/subtable.js 2010-12-03 16:30:40 UTC (rev 20368)
+++ trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/subtable.js 2010-12-03 16:44:29 UTC (rev 20369)
@@ -1,115 +0,0 @@
-(function ($, richfaces) {
-
- richfaces.ui = richfaces.ui || {};
-
- richfaces.ui.SubTable = function(id, f, options) {
- this.id = id;
- this.stateInput = options.stateInput;
- this.optionsInput = options.optionsInput;
- this.expandMode = options.expandMode;
- this.eventOptions = options.eventOptions;
- this.formId = f;
-
- $super.constructor.call(this, id);
- this.attachToDom(id);
- };
-
- $.extend(richfaces.ui.SubTable, {
- MODE_AJAX: "ajax",
- MODE_SRV: "server",
- MODE_CLNT: "client",
- collapse: 0,
- expand: 1
- })
-
- var $super = richfaces.BaseComponent.extend(richfaces.ui.SubTable);
- var $p = richfaces.BaseComponent.extend(richfaces.ui.SubTable, {});
- var $super = richfaces.ui.SubTable.$super;
-
- $.extend(richfaces.ui.SubTable.prototype, (function () {
-
- var element = function() {
- //use parent tbody as parent dom elem
- return $(document.getElementById(this.id)).parent();
- };
-
- var stateInputElem = function() {
- return $(document.getElementById(this.stateInput));
- };
-
- var optionsInputElem = function() {
- return $(document.getElementById(this.optionsInput));
- };
-
- var ajax = function(e, options) {
- this.switchState();
- richfaces.ajax(this.id, e, options);
- };
-
- var server = function(options) {
- this.switchState();
- $(document.getElementById(this.formId)).submit();
- };
-
- var client = function(options) {
- if(this.isExpand()) {
- this.collapse(options);
- } else {
- this.expand(options);
- }
- };
-
-
- return {
-
- name: "RichFaces.ui.SubTable",
-
- toggle: function(e, options) {
- if(this.expandMode == richfaces.ui.SubTable.MODE_AJAX) {
- ajax.call(this, e, this.eventOptions, options);
- }else if(this.expandMode == richfaces.ui.SubTable.MODE_SRV) {
- server.call(this, options);
- }else if(this.expandMode == richfaces.ui.SubTable.MODE_CLNT) {
- client.call(this, options);
- }
- },
-
- collapse: function(options) {
- this.setState(richfaces.ui.SubTable.collapse);
- element.call(this).hide();
- },
-
- expand: function(options) {
- this.setState(richfaces.ui.SubTable.expand);
- element.call(this).show();
- },
-
- isExpand: function() {
- return (parseInt(this.getState()) == richfaces.ui.SubTable.expand);
- },
-
- switchState: function(options) {
- var state = this.isExpand() ? richfaces.ui.SubTable.collapse : richfaces.ui.SubTable.expand;
- this.setState(state);
- },
-
- getState: function() {
- return stateInputElem.call(this).val();
- },
-
- setState: function(state) {
- stateInputElem.call(this).val(state)
- },
-
- setOption: function(option) {
- optionsInputElem.call(this).val(option);
- },
-
- getMode: function() {
- return this.expandMode;
- }
- };
-
- })());
-
-})(jQuery, window.RichFaces);
\ No newline at end of file
Modified: trunk/ui/iteration/ui/src/main/templates/toggle-control.template.xml
===================================================================
--- trunk/ui/iteration/ui/src/main/templates/toggle-control.template.xml 2010-12-03 16:30:40 UTC (rev 20368)
+++ trunk/ui/iteration/ui/src/main/templates/toggle-control.template.xml 2010-12-03 16:44:29 UTC (rev 20369)
@@ -6,10 +6,10 @@
xmlns:javaee="http://java.sun.com/xml/ns/javaee">
<cc:interface>
- <cdk:class>org.richfaces.renderkit.html.SubTableToggleControlRenderer</cdk:class>
- <cdk:superclass>org.richfaces.renderkit.SubTableToggleControlRendererBase</cdk:superclass>
- <cdk:component-family>org.richfaces.SubTableToggleControl</cdk:component-family>
- <cdk:renderer-type>org.richfaces.SubTableToggleControlRenderer</cdk:renderer-type>
+ <cdk:class>org.richfaces.renderkit.html.CollapsibleSubTableTogglerRenderer</cdk:class>
+ <cdk:superclass>org.richfaces.renderkit.CollapsibleSubTableTogglerRendererBase</cdk:superclass>
+ <cdk:component-family>org.richfaces.CollapsibleSubTableToggler</cdk:component-family>
+ <cdk:renderer-type>org.richfaces.CollapsibleSubTableTogglerRenderer</cdk:renderer-type>
</cc:interface>
<cc:implementation>
14 years, 1 month
JBoss Rich Faces SVN: r20368 - trunk/core/impl/src/main/resources/META-INF/resources.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2010-12-03 11:30:40 -0500 (Fri, 03 Dec 2010)
New Revision: 20368
Modified:
trunk/core/impl/src/main/resources/META-INF/resources/richfaces-base-component.js
Log:
http://jira.jboss.com/jira/browse/RF-9858
Modified: trunk/core/impl/src/main/resources/META-INF/resources/richfaces-base-component.js
===================================================================
--- trunk/core/impl/src/main/resources/META-INF/resources/richfaces-base-component.js 2010-12-03 16:30:19 UTC (rev 20367)
+++ trunk/core/impl/src/main/resources/META-INF/resources/richfaces-base-component.js 2010-12-03 16:30:40 UTC (rev 20368)
@@ -244,7 +244,7 @@
detach: function(source) {
source = source || this.id;
var element = richfaces.getDomElement(source);
- element && element.richfaces && (element.richfaces.component=null);
+ element && element[richfaces.RICH_CONTAINER] && (element[richfaces.RICH_CONTAINER].component=null);
},
/** TODO: add jsdocs and qunit tests
14 years, 1 month
JBoss Rich Faces SVN: r20367 - trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2010-12-03 11:30:19 -0500 (Fri, 03 Dec 2010)
New Revision: 20367
Modified:
trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.js
trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/push.js
Log:
http://jira.jboss.com/jira/browse/RF-9858
core components code refactoring
Modified: trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.js
===================================================================
--- trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.js 2010-12-03 16:16:57 UTC (rev 20366)
+++ trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.js 2010-12-03 16:30:19 UTC (rev 20367)
@@ -169,7 +169,7 @@
},
init: function(options) {
- this.$super.constructor.call(this, 'richfaces.log');
+ $super.constructor.call(this, 'richfaces.log');
this.attachToDom();
richfaces.setLog(this);
@@ -200,7 +200,8 @@
}
this.__contentsElement = null;
- this.$super.destroy.call(this);
+ this.detach();
+ $super.destroy.call(this);
},
setLevel: function(level) {
@@ -229,6 +230,8 @@
}
richfaces.HtmlLog = richfaces.BaseComponent.extendClass(logClassMethods);
+ // define super class link
+ var $super = richfaces.HtmlLog.$super;
}(jQuery, RichFaces));
if (typeof jsf != 'undefined') {
Modified: trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/push.js
===================================================================
--- trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/push.js 2010-12-03 16:16:57 UTC (rev 20366)
+++ trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/push.js 2010-12-03 16:30:19 UTC (rev 20367)
@@ -179,7 +179,7 @@
name: COMPONENT_NAME,
init: function (id, options) {
- this.id = id;
+ $super.constructor.call(this, id);
this.attachToDom();
this.__address = options.address;
@@ -231,7 +231,12 @@
this.__unbindErrorHandler();
richfaces.Push.decreaseSubscriptionCounters(this.__address);
+ this.detach();
+ $super.destroy.call(this);
}
});
+ // define super class link
+ var $super = richfaces.ui.Push.$super;
+
}(jsf, window.RichFaces, jQuery));
\ No newline at end of file
14 years, 1 month
JBoss Rich Faces SVN: r20366 - trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2010-12-03 11:16:57 -0500 (Fri, 03 Dec 2010)
New Revision: 20366
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputBase.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSpinner.js
Log:
http://jira.jboss.com/jira/browse/RF-9858
input components code refactoring
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js 2010-12-03 16:00:27 UTC (rev 20365)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js 2010-12-03 16:16:57 UTC (rev 20366)
@@ -98,7 +98,7 @@
this.options = {};
// call constructor of parent class
$super.constructor.call(this, componentId, componentId+ID.SELECT, fieldId, options);
- this.attachToDom(componentId);
+ this.attachToDom();
this.options = $.extend(this.options, defaultOptions, options);
this.value = this.__getSubValue();
this.index = -1;
@@ -460,6 +460,7 @@
var itemsContainer = rf.getDomElement(this.id+ID.ITEMS);
$(itemsContainer).removeData();
rf.Event.unbind(itemsContainer.parentNode, this.namespace);
+ this.detach()
$super.destroy.call(this);
}
};
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js 2010-12-03 16:00:27 UTC (rev 20365)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js 2010-12-03 16:16:57 UTC (rev 20366)
@@ -480,7 +480,7 @@
var div = rf.getDomElement(this.CALENDAR_CONTENT);
div = $(div).replaceWith(htmlTextHeader+htmlHeaderOptional+htmlControlsHeader+htmlTextWeekDayBar.join('')+htmlTextWeek.join('')+htmlControlsFooter+htmlFooterOptional+htmlTextFooter);
- this.attachToDom(this.id); // TODO: optimize double $
+ this.attachToDom(); // TODO: optimize double $
// memory leaks fix // from old 3.3.x code, may be not needed now
div = null;
@@ -530,7 +530,7 @@
*/
$.extend(rf.ui.Calendar.prototype, {
name: "Calendar",
- destructor: function()
+ destroy: function()
{
if (this.params.popup && this.isVisible)
{
@@ -538,6 +538,8 @@
this.scrollElements = null;
rf.Event.unbind(window.document, "click"+this.namespace);
}
+ this.detach();
+ $super.destroy.call(this);
},
dateEditorSelectYear: function(value)
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputBase.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputBase.js 2010-12-03 16:00:27 UTC (rev 20365)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputBase.js 2010-12-03 16:16:57 UTC (rev 20366)
@@ -6,17 +6,22 @@
$super.constructor.call(this, id);
this.namespace = this.getNamespace() || "." + rf.Event.createNamespace(this.getName(), this.getId());
- this.id = id;
+ this.namespace = this.namespace || "."+rf.Event.createNamespace(this.name, this.id);
+
this.input = $(document.getElementById(id + "Input"));
- this.attachToDom(id);
-
- this.input.bind("keydown", $.proxy(this.__keydownHandler, this));
- this.input.bind("blur", $.proxy(this.__blurHandler, this));
- this.input.bind("change", $.proxy(this.__changeHandler, this));
- this.input.bind("focus", $.proxy(this.__focusHandler, this));
+ this.attachToDom();
+
+ var inputEventHandlers = {};
+ inputEventHandlers["keydown"+this.namespace] = this.__keydownHandler;
+ inputEventHandlers["blur"+this.namespace] = this.__blurHandler;
+ inputEventHandlers["change"+this.namespace] = this.__changeHandler;
+ inputEventHandlers["focus"+this.namespace] = this.__focusHandler;
+ rf.Event.bind(this.input, inputEventHandlers, this);
};
rf.BaseComponent.extend(rf.ui.InputBase);
+
+ // define super class link
var $super = rf.ui.InputBase.$super;
$.extend(rf.ui.InputBase.prototype, ( function () {
@@ -64,7 +69,13 @@
getId: function() {
return this.id;
- }
+ },
+ destroy: function() {
+ rf.Event.unbindById(this.input, this.namespace);
+ this.input = null;
+ this.detach();
+ $super.destroy.call(this);
+ }
}
})());
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSpinner.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSpinner.js 2010-12-03 16:00:27 UTC (rev 20365)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSpinner.js 2010-12-03 16:16:57 UTC (rev 20366)
@@ -33,8 +33,8 @@
step: 1,
init: function (id, options) {
- jQuery.extend(this, options);
- this.id = id;
+ $super.constructor.call(this, id);
+ jQuery.extend(this, options);
this.element = jQuery(this.attachToDom());
this.input = this.element.children(".rf-insp-inp");
@@ -94,6 +94,8 @@
.unbind("mouseup", this.destroy);
this.intervalId = null;
}
+ this.detach();
+ $super.destroy.call(this);
},
__setValue: function (value, event, skipOnchange) {
@@ -157,4 +159,7 @@
event.preventDefault();
}
});
+
+ // define super class link
+ var $super = richfaces.ui.InputNumberSpinner.$super;
}(window.RichFaces, jQuery));
\ No newline at end of file
14 years, 1 month
JBoss Rich Faces SVN: r20365 - trunk/core/impl/src/main/resources/META-INF/resources.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2010-12-03 11:00:27 -0500 (Fri, 03 Dec 2010)
New Revision: 20365
Modified:
trunk/core/impl/src/main/resources/META-INF/resources/richfaces-event.js
Log:
http://jira.jboss.com/jira/browse/RF-9858
Modified: trunk/core/impl/src/main/resources/META-INF/resources/richfaces-event.js
===================================================================
--- trunk/core/impl/src/main/resources/META-INF/resources/richfaces-event.js 2010-12-03 15:36:35 UTC (rev 20364)
+++ trunk/core/impl/src/main/resources/META-INF/resources/richfaces-event.js 2010-12-03 16:00:27 UTC (rev 20365)
@@ -94,9 +94,14 @@
* */
bind : function(selector, eventType, fn, component, data) {
// eventType: namespace can be used, like onclick.rf.conponentName
- var f = getHandlerWrapper(component, fn);
- getEventElement(selector).bind(eventType, data, f);
- return f;
+ if (typeof eventType == "object") {
+ // in this case fn == component object
+ getEventElement(selector).bind(getMultipleHandlerWrapper(eventType, fn), data);
+ } else {
+ var f = getHandlerWrapper(component, fn);
+ getEventElement(selector).bind(eventType, data, f);
+ return f;
+ }
},
/**
14 years, 1 month
JBoss Rich Faces SVN: r20364 - in trunk/ui/iteration/ui/src/main: java/org/richfaces/convert and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-12-03 10:36:35 -0500 (Fri, 03 Dec 2010)
New Revision: 20364
Added:
trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelSequenceKeyConverter.java
Removed:
trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelKeySequenceRowKeyConverter.java
Modified:
trunk/ui/iteration/ui/src/main/config/faces-config.xml
trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/IntegerSequenceRowKeyConverter.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/ObjectSequenceRowKeyConverter.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelImpl.java
Log:
- https://jira.jboss.org/browse/RF-9729
- Fixed incorrect condition in isLeaf()
Modified: trunk/ui/iteration/ui/src/main/config/faces-config.xml
===================================================================
--- trunk/ui/iteration/ui/src/main/config/faces-config.xml 2010-12-03 15:35:08 UTC (rev 20363)
+++ trunk/ui/iteration/ui/src/main/config/faces-config.xml 2010-12-03 15:36:35 UTC (rev 20364)
@@ -6,6 +6,21 @@
xmlns:cdk="http://jboss.org/schema/richfaces/cdk/extensions"
version="2.0">
+ <converter>
+ <converter-id>org.richfaces.DeclarativeModelSequenceKeyConverter</converter-id>
+ <converter-class>org.richfaces.convert.DeclarativeModelSequenceKeyConverter</converter-class>
+ </converter>
+
+ <converter>
+ <converter-id>org.richfaces.IntegerSequenceRowKeyConverter</converter-id>
+ <converter-class>org.richfaces.convert.IntegerSequenceRowKeyConverter</converter-class>
+ </converter>
+
+ <converter>
+ <converter-id>org.richfaces.ObjectSequenceRowKeyConverter</converter-id>
+ <converter-class>org.richfaces.convert.ObjectSequenceRowKeyConverter</converter-class>
+ </converter>
+
<faces-config-extension>
<cdk:faces-event>
<cdk:event-class>org.richfaces.event.TreeToggleEvent</cdk:event-class>
Deleted: trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelKeySequenceRowKeyConverter.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelKeySequenceRowKeyConverter.java 2010-12-03 15:35:08 UTC (rev 20363)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelKeySequenceRowKeyConverter.java 2010-12-03 15:36:35 UTC (rev 20364)
@@ -1,103 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.convert;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.convert.ConverterException;
-import javax.faces.convert.IntegerConverter;
-
-import org.richfaces.component.AbstractTree;
-import org.richfaces.component.DeclarativeTreeDataModelWalker;
-import org.richfaces.model.DeclarativeModelKey;
-import org.richfaces.model.SequenceRowKey;
-/**
- * @author Nick Belaevski
- *
- */
-public class DeclarativeModelKeySequenceRowKeyConverter extends SequenceRowKeyConverter<DeclarativeModelKey> {
-
- private final class KeyConvertingWalker extends DeclarativeTreeDataModelWalker {
-
- private final FacesContext context;
-
- private DeclarativeModelKey[] convertedSimpleKeys;
-
- private int keysIdx;
-
- private KeyConvertingWalker(AbstractTree rootComponent, FacesContext context) {
- super(rootComponent);
- this.context = context;
- }
-
- @Override
- protected DeclarativeModelKey convertKey(Object nodes, DeclarativeModelKey declarativeModelKey) {
- DeclarativeModelKey convertedKey;
-
- if (nodes instanceof Iterable<?>) {
- String modelKeyAsString = (String) declarativeModelKey.getModelKey();
- Object modelKey = INTEGER_CONVERTER.getAsObject(context, getRootComponent(), modelKeyAsString);
- convertedKey = new DeclarativeModelKey(declarativeModelKey.getModelId(), modelKey);
- } else {
- convertedKey = declarativeModelKey;
- }
-
- convertedSimpleKeys[keysIdx++] = convertedKey;
-
- return super.convertKey(nodes, convertedKey);
- }
-
- @Override
- public void walk(SequenceRowKey key) {
- convertedSimpleKeys = new DeclarativeModelKey[key.getSimpleKeys().length];
- keysIdx = 0;
- super.walk(key);
- }
-
- public DeclarativeModelKey[] getConvertedSimpleKeys() {
- return convertedSimpleKeys;
- }
- }
-
- private static final Converter INTEGER_CONVERTER = new IntegerConverter();
-
- public DeclarativeModelKeySequenceRowKeyConverter() {
- super(DeclarativeModelKey.class, new DeclarativeModelKeyConverter(ConverterUtil.stringConverter()));
- }
-
- @Override
- public Object getAsObject(FacesContext context, UIComponent component, String value) throws ConverterException {
- SequenceRowKey key = (SequenceRowKey) super.getAsObject(context, component, value);
-
- if (key != null) {
-
- KeyConvertingWalker walker = new KeyConvertingWalker((AbstractTree) component, context);
- walker.walk(key);
-
- key = new SequenceRowKey((Object[]) walker.getConvertedSimpleKeys());
- }
-
- return key;
- }
-
-}
Copied: trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelSequenceKeyConverter.java (from rev 20337, trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelKeySequenceRowKeyConverter.java)
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelSequenceKeyConverter.java (rev 0)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelSequenceKeyConverter.java 2010-12-03 15:36:35 UTC (rev 20364)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.convert;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.convert.IntegerConverter;
+
+import org.richfaces.component.AbstractTree;
+import org.richfaces.component.DeclarativeTreeDataModelWalker;
+import org.richfaces.model.DeclarativeModelKey;
+import org.richfaces.model.SequenceRowKey;
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class DeclarativeModelSequenceKeyConverter extends SequenceRowKeyConverter<DeclarativeModelKey> {
+
+ private final class KeyConvertingWalker extends DeclarativeTreeDataModelWalker {
+
+ private final FacesContext context;
+
+ private DeclarativeModelKey[] convertedSimpleKeys;
+
+ private int keysIdx;
+
+ private KeyConvertingWalker(AbstractTree rootComponent, FacesContext context) {
+ super(rootComponent);
+ this.context = context;
+ }
+
+ @Override
+ protected DeclarativeModelKey convertKey(Object nodes, DeclarativeModelKey declarativeModelKey) {
+ DeclarativeModelKey convertedKey;
+
+ if (nodes instanceof Iterable<?>) {
+ String modelKeyAsString = (String) declarativeModelKey.getModelKey();
+ Object modelKey = INTEGER_CONVERTER.getAsObject(context, getRootComponent(), modelKeyAsString);
+ convertedKey = new DeclarativeModelKey(declarativeModelKey.getModelId(), modelKey);
+ } else {
+ convertedKey = declarativeModelKey;
+ }
+
+ convertedSimpleKeys[keysIdx++] = convertedKey;
+
+ return super.convertKey(nodes, convertedKey);
+ }
+
+ @Override
+ public void walk(SequenceRowKey key) {
+ convertedSimpleKeys = new DeclarativeModelKey[key.getSimpleKeys().length];
+ keysIdx = 0;
+ super.walk(key);
+ }
+
+ public DeclarativeModelKey[] getConvertedSimpleKeys() {
+ return convertedSimpleKeys;
+ }
+ }
+
+ public static final String CONVERTER_ID = "org.richfaces.DeclarativeModelSequenceKeyConverter";
+
+ private static final Converter INTEGER_CONVERTER = new IntegerConverter();
+
+ public DeclarativeModelSequenceKeyConverter() {
+ super(DeclarativeModelKey.class, new DeclarativeModelKeyConverter(ConverterUtil.stringConverter()));
+ }
+
+ @Override
+ public Object getAsObject(FacesContext context, UIComponent component, String value) throws ConverterException {
+ SequenceRowKey key = (SequenceRowKey) super.getAsObject(context, component, value);
+
+ if (key != null) {
+
+ KeyConvertingWalker walker = new KeyConvertingWalker((AbstractTree) component, context);
+ walker.walk(key);
+
+ key = new SequenceRowKey((Object[]) walker.getConvertedSimpleKeys());
+ }
+
+ return key;
+ }
+
+}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/IntegerSequenceRowKeyConverter.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/IntegerSequenceRowKeyConverter.java 2010-12-03 15:35:08 UTC (rev 20363)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/IntegerSequenceRowKeyConverter.java 2010-12-03 15:36:35 UTC (rev 20364)
@@ -29,6 +29,8 @@
*/
public class IntegerSequenceRowKeyConverter extends SequenceRowKeyConverter<Integer> {
+ public static final String CONVERTER_ID = "org.richfaces.IntegerSequenceRowKeyConverter";
+
public IntegerSequenceRowKeyConverter() {
super(Integer.class, new IntegerConverter());
}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/ObjectSequenceRowKeyConverter.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/ObjectSequenceRowKeyConverter.java 2010-12-03 15:35:08 UTC (rev 20363)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/ObjectSequenceRowKeyConverter.java 2010-12-03 15:36:35 UTC (rev 20364)
@@ -31,6 +31,8 @@
*/
public class ObjectSequenceRowKeyConverter extends SequenceRowKeyConverter<Object> {
+ public static final String CONVERTER_ID = "org.richfaces.ObjectSequenceRowKeyConverter";
+
private static final Converter NO_OP_CONVERTER = new Converter() {
public String getAsString(FacesContext context, UIComponent component, Object value) {
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelImpl.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelImpl.java 2010-12-03 15:35:08 UTC (rev 20363)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelImpl.java 2010-12-03 15:36:35 UTC (rev 20364)
@@ -30,7 +30,7 @@
import org.richfaces.component.DeclarativeTreeDataModelWalker;
import org.richfaces.component.TreeModelAdaptor;
import org.richfaces.component.TreeModelRecursiveAdaptor;
-import org.richfaces.convert.DeclarativeModelKeySequenceRowKeyConverter;
+import org.richfaces.convert.DeclarativeModelSequenceKeyConverter;
import org.richfaces.model.iterators.DeclarativeTreeDataModelCompositeTuplesIterator;
import com.google.common.base.Predicates;
@@ -42,7 +42,7 @@
*/
public class DeclarativeTreeDataModelImpl extends TreeSequenceKeyModel<Object> implements DeclarativeTreeModel<Object> {
- private static final Converter DEFAULT_CONVERTER = new DeclarativeModelKeySequenceRowKeyConverter();
+ private static final Converter DEFAULT_CONVERTER = new DeclarativeModelSequenceKeyConverter();
private AbstractTree tree;
@@ -67,7 +67,7 @@
return true;
}
- return Iterables.contains(currentComponent.getChildren(), Predicates.instanceOf(TreeModelAdaptor.class));
+ return !Iterables.contains(currentComponent.getChildren(), Predicates.instanceOf(TreeModelAdaptor.class));
}
public Iterator<TreeDataModelTuple> children() {
14 years, 1 month