Author: abelevich
Date: 2010-05-28 06:40:38 -0400 (Fri, 28 May 2010)
New Revision: 17345
Added:
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/component/UISubTableToggleControl.java
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/component/html/HtmlSubTableToggleControl.java
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java
root/ui-sandbox/tables/trunk/ui/src/main/resources/META-INF/resources/down_icon.gif
root/ui-sandbox/tables/trunk/ui/src/main/resources/META-INF/resources/up_icon.gif
Removed:
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/component/UIToggleControl.java
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/component/html/HtmlToggleControl.java
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java
root/ui-sandbox/tables/trunk/ui/src/main/resources/META-INF/resources/toggler.js
Modified:
root/ui-sandbox/tables/trunk/ui/src/main/config/faces-config.xml
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
root/ui-sandbox/tables/trunk/ui/src/main/resources/META-INF/resources/datatable.ecss
root/ui-sandbox/tables/trunk/ui/src/main/resources/META-INF/resources/subtable.js
root/ui-sandbox/tables/trunk/ui/src/main/resources/META-INF/tables.faces-config.xml
root/ui-sandbox/tables/trunk/ui/src/main/resources/META-INF/tables.taglib.xml
root/ui-sandbox/tables/trunk/ui/src/main/templates/org/richfaces/renderkit/html/toggle-control.template.xml
Log:
RF-8687, RF-8688, RF-8689
Modified: root/ui-sandbox/tables/trunk/ui/src/main/config/faces-config.xml
===================================================================
--- root/ui-sandbox/tables/trunk/ui/src/main/config/faces-config.xml 2010-05-28 10:40:04
UTC (rev 17344)
+++ root/ui-sandbox/tables/trunk/ui/src/main/config/faces-config.xml 2010-05-28 10:40:38
UTC (rev 17345)
@@ -63,8 +63,8 @@
</component-extension>
</component>
<component>
- <component-type>org.richfaces.ToggleControl</component-type>
- <component-class>org.richfaces.component.html.HtmlToggleControl</component-class>
+ <component-type>org.richfaces.SubTableToggleControl</component-type>
+ <component-class>org.richfaces.component.html.HtmlSubTableToggleControl</component-class>
<component-extension>
<cdk:generate
xmlns:cdk="http://richfaces.org/cdk/extensions">false</cd...
</component-extension>
Added:
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/component/UISubTableToggleControl.java
===================================================================
---
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/component/UISubTableToggleControl.java
(rev 0)
+++
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/component/UISubTableToggleControl.java 2010-05-28
10:40:38 UTC (rev 17345)
@@ -0,0 +1,108 @@
+/*
+ * 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 java.io.IOException;
+
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.event.ToggleEvent;
+import org.richfaces.event.ToggleListener;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public class UISubTableToggleControl extends UIComponentBase implements ToggleListener {
+
+ public static final String COMPONENT_TYPE =
"org.richfaces.SubTableToggleControl";
+
+ public static final String COMPONENT_FAMILY =
"org.richfaces.SubTableToggleControl";
+
+ enum PropertyKeys {
+ expandIcon, collapseIcon, expandLabel, collapseLabel, forId, switchType, event
+ }
+
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ public String getExpandLabel() {
+ return (String)getStateHelper().eval(PropertyKeys.expandLabel);
+ }
+
+ public void setExpandLabel(String expandLabel) {
+ getStateHelper().put(PropertyKeys.expandLabel, expandLabel);
+ }
+
+ public String getCollapseLabel() {
+ return (String)getStateHelper().eval(PropertyKeys.collapseLabel);
+ }
+
+ public void setCollapseLabel(String collapseLabel) {
+ getStateHelper().put(PropertyKeys.collapseLabel, collapseLabel);
+ }
+
+ public String getExpandIcon() {
+ return (String) getStateHelper().eval(PropertyKeys.expandIcon, null);
+ }
+
+ public void setExpandIcon(String expandIcon) {
+ getStateHelper().put(PropertyKeys.expandIcon, expandIcon);
+ }
+
+ public String getCollapseIcon() {
+ return (String) getStateHelper().eval(PropertyKeys.collapseIcon, null);
+ }
+
+ public void setCollapseIcon(String collapseIcon) {
+ getStateHelper().put(PropertyKeys.collapseIcon, collapseIcon);
+ }
+
+ public String getFor() {
+ return (String) getStateHelper().eval(PropertyKeys.forId, null);
+ }
+
+ public void setFor(String forId) {
+ getStateHelper().put(PropertyKeys.forId, forId);
+ }
+
+ public String getEvent() {
+ return (String) getStateHelper().eval(PropertyKeys.event, "onclick");
+
+ }
+
+ public void setEvent(String event) {
+ getStateHelper().put(PropertyKeys.event, event);
+ }
+
+ @Override
+ public void encodeEnd(FacesContext context) throws IOException {
+ // TODO Auto-generated method stub
+ super.encodeEnd(context);
+ }
+
+ public void processToggle(ToggleEvent event) {
+
getFacesContext().getPartialViewContext().getRenderIds().add(getClientId(getFacesContext()));
+ }
+}
Deleted:
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/component/UIToggleControl.java
===================================================================
---
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/component/UIToggleControl.java 2010-05-28
10:40:04 UTC (rev 17344)
+++
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/component/UIToggleControl.java 2010-05-28
10:40:38 UTC (rev 17345)
@@ -1,73 +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;
-
-public class UIToggleControl extends UIComponentBase {
-
- public static final String COMPONENT_TYPE = "org.richfaces.ToggleControl";
-
- public static final String COMPONENT_FAMILY =
"org.richfaces.ToggleControl";
-
- enum PropertyKeys {
- expandControl, collapseControl, forId, switchType, event
- }
-
- public String getFamily() {
- return COMPONENT_FAMILY;
- }
-
- public String getExpandControl() {
- return (String) getStateHelper().eval(PropertyKeys.expandControl, null);
- }
-
- public void setExpandControl(String expandControl) {
- getStateHelper().put(PropertyKeys.expandControl, expandControl);
- }
-
- public String getCollapseControl() {
- return (String) getStateHelper().eval(PropertyKeys.collapseControl, null);
- }
-
- public void setCollapseControl(String collapseControl) {
- getStateHelper().put(PropertyKeys.collapseControl, collapseControl);
- }
-
- public String getFor() {
- return (String) getStateHelper().eval(PropertyKeys.forId, null);
- }
-
- public void setFor(String forId) {
- getStateHelper().put(PropertyKeys.forId, forId);
- }
-
- public String getEvent() {
- return (String) getStateHelper().eval(PropertyKeys.event, "onclick");
-
- }
-
- public void setEvent(String event) {
- getStateHelper().put(PropertyKeys.event, event);
- }
-
-}
Added:
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/component/html/HtmlSubTableToggleControl.java
===================================================================
---
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/component/html/HtmlSubTableToggleControl.java
(rev 0)
+++
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/component/html/HtmlSubTableToggleControl.java 2010-05-28
10:40:38 UTC (rev 17345)
@@ -0,0 +1,7 @@
+package org.richfaces.component.html;
+
+import org.richfaces.component.UISubTableToggleControl;
+
+//TODO nick - behavior support
+public class HtmlSubTableToggleControl extends UISubTableToggleControl {
+}
Deleted:
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/component/html/HtmlToggleControl.java
===================================================================
---
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/component/html/HtmlToggleControl.java 2010-05-28
10:40:04 UTC (rev 17344)
+++
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/component/html/HtmlToggleControl.java 2010-05-28
10:40:38 UTC (rev 17345)
@@ -1,7 +0,0 @@
-package org.richfaces.component.html;
-
-import org.richfaces.component.UIToggleControl;
-
-//TODO nick - behavior support
-public class HtmlToggleControl extends UIToggleControl {
-}
Modified:
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
===================================================================
---
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2010-05-28
10:40:04 UTC (rev 17344)
+++
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2010-05-28
10:40:38 UTC (rev 17345)
@@ -135,7 +135,7 @@
if(encodeParentTBody((UIDataTableBase)row)) {
encodeTableBodyEnd(writer);
- encodeScriptContainer(writer, facesContext, (UIDataTableBase)row);
+ encodeHiddenContainer(writer, facesContext, (UIDataTableBase)row);
if(rowHolder.isPartialUpdate()) {
facesContext.getPartialViewContext().getPartialResponseWriter().endUpdate();
}
@@ -221,8 +221,7 @@
encodeStyleClass(writer, context, component, HTML.STYLE_CLASS_ATTR, styleClass);
}
- protected void encodeScriptContainer(ResponseWriter writer, FacesContext context,
UIDataTableBase dataTableBase) throws IOException {
-
+ protected void encodeHiddenContainer(ResponseWriter writer, FacesContext context,
UIDataTableBase dataTableBase) throws IOException {
writer.startElement(HTML.TBODY_ELEMENT, dataTableBase);
writer.writeAttribute(HTML.ID_ATTRIBUTE, dataTableBase.getClientId(context)
+":sc",null);
writer.writeAttribute(HTML.STYLE_ATTRIBUTE, "display: none", null);
@@ -231,6 +230,7 @@
writer.startElement(HTML.TD_ELEM, dataTableBase);
encodeClientScript(writer, context, dataTableBase);
+ encodeHiddenInput(writer, context, dataTableBase);
writer.endElement(HTML.TD_ELEM);
writer.endElement(HTML.TR_ELEMENT);
@@ -243,6 +243,8 @@
}
public abstract void encodeClientScript(ResponseWriter writer, FacesContext context,
UIDataTableBase component) throws IOException;
+
+ public abstract void encodeHiddenInput(ResponseWriter writer, FacesContext context,
UIDataTableBase component) throws IOException;
public void encodeTableBodyStart(ResponseWriter writer, FacesContext context,
UIDataTableBase dataTable)
throws IOException {
Modified:
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
===================================================================
---
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-05-28
10:40:04 UTC (rev 17344)
+++
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-05-28
10:40:38 UTC (rev 17345)
@@ -268,6 +268,11 @@
writer.endElement(HTML.SCRIPT_ELEM);
}
+ @Override
+ public void encodeHiddenInput(ResponseWriter writer, FacesContext context,
UIDataTableBase component)
+ throws IOException {
+ }
+
public String getTableSkinClass() {
return "rf-dt";
}
Modified:
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
===================================================================
---
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2010-05-28
10:40:04 UTC (rev 17344)
+++
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2010-05-28
10:40:38 UTC (rev 17345)
@@ -49,14 +49,18 @@
private static final String STATE = ":state";
+ private static final String OPTIONS = ":options";
+
protected void doDecode(FacesContext facesContext, UIComponent component) {
UISubTable subTable = (UISubTable)component;
-
- String clientId = subTable.getClientId(facesContext) + STATE;
+
+ String clientId = subTable.getClientId(facesContext);
+
+ String stateId = clientId + STATE;
Map<String, String> requestMap =
facesContext.getExternalContext().getRequestParameterMap();
- String state = (String)requestMap.get(clientId);
+ String state = (String)requestMap.get(stateId);
boolean isExpand = true;
if(state != null) {
@@ -70,7 +74,6 @@
new ToggleEvent(subTable, isExpand).queue();
}
}
-
}
public void encodeTableFacets(ResponseWriter writer, FacesContext context,
UIDataTableBase dataTable) throws IOException {
@@ -136,7 +139,7 @@
UISubTable subTable = (UISubTable)row;
encodeFooterFacet(writer, facesContext, subTable, false);
encodeTableBodyEnd(writer);
- encodeScriptContainer(writer, facesContext, subTable);
+ encodeHiddenContainer(writer, facesContext, subTable);
if(rowHolder.isPartialUpdate()) {
facesContext.getPartialViewContext().getPartialResponseWriter().endUpdate();
}
@@ -147,16 +150,26 @@
return true;
}
- public void encodeStateInput(ResponseWriter writer, FacesContext facesContext,
UISubTable subTable) throws IOException {
- String clientId = subTable.getClientId(facesContext) + STATE;
+ public void encodeHiddenInput(ResponseWriter writer, FacesContext facesContext,
UIDataTableBase dataTableBase) throws IOException {
+ UISubTable subTable = (UISubTable)dataTableBase;
+
+ String stateId = subTable.getClientId(facesContext) + STATE;
writer.startElement(HTML.INPUT_ELEM, subTable);
- writer.writeAttribute(HTML.ID_ATTRIBUTE, clientId , null);
- writer.writeAttribute(HTML.NAME_ATTRIBUTE, clientId , null);
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, stateId , null);
+ writer.writeAttribute(HTML.NAME_ATTRIBUTE, stateId , null);
writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
int state = subTable.isExpanded() ? 1 : 0;
writer.writeAttribute(HTML.VALUE_ATTRIBUTE, state, null);
writer.endElement(HTML.INPUT_ELEM);
+
+ String optionsId = subTable.getClientId(facesContext) + OPTIONS;
+ writer.startElement(HTML.INPUT_ELEM, subTable);
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, optionsId , null);
+ writer.writeAttribute(HTML.NAME_ATTRIBUTE, optionsId , null);
+ writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
+ writer.endElement(HTML.INPUT_ELEM);
+
}
public boolean containsThead() {
@@ -177,7 +190,8 @@
String formId = nestingForm != null ? nestingForm.getClientId(facesContext) :
"";
Map<String, Object> options = new HashMap<String, Object>();
- options.put("stateInput", subTable.getClientId(facesContext)
+":state");
+ 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));
Added:
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java
===================================================================
---
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java
(rev 0)
+++
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java 2010-05-28
10:40:38 UTC (rev 17345)
@@ -0,0 +1,179 @@
+/*
+ * 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.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.component.UISubTable;
+import org.richfaces.component.UISubTableToggleControl;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+@ResourceDependencies( {@ResourceDependency(library = "javax.faces", name =
"jsf.js"),
+ @ResourceDependency(name = "richfaces.js"), @ResourceDependency(name =
"subtable-toggler.js")})
+
+public class SubTableToggleControlRendererBase extends RendererBase {
+
+ private static final String DISPLAY_NONE = "display: none;";
+
+ 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 {
+
+ UISubTableToggleControl toggleControl = (UISubTableToggleControl) component;
+
+ UISubTable subTable = findComponent(context, toggleControl);
+ if (subTable != null) {
+ ResponseWriter writer = context.getResponseWriter();
+
+ String toggleId = toggleControl.getClientId(context);
+ Map<String, Object> options = encodeOptions(context, toggleControl,
subTable);
+ String switchType = subTable.getExpandMode();
+
+ boolean expanded = subTable.isExpanded();
+
+ encodeControl(context, writer, toggleControl, switchType, expanded, false);
+ encodeControl(context, writer, toggleControl, switchType, !expanded, true);
+
+ JSFunction jsFunction = new JSFunction("new
RichFaces.ui.SubTableToggler");
+ jsFunction.addParameter(toggleId);
+ jsFunction.addParameter(options);
+
+ writer.startElement(HTML.SCRIPT_ELEM, subTable);
+ writer.writeText(jsFunction.toScript(), null);
+ writer.endElement(HTML.SCRIPT_ELEM);
+
+ subTable.addToggleListener(toggleControl);
+ }
+
+ }
+
+ protected void encodeControl(FacesContext context, ResponseWriter writer,
UISubTableToggleControl 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(HTML.SPAN_ELEM, control);
+
+ if (!visible) {
+ writer.writeAttribute(HTML.STYLE_ATTRIBUTE, DISPLAY_NONE, null);
+ }
+
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, control.getClientId() + ":" +
state, null);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, styleClass, null);
+ writer.writeAttribute(HTML.STYLE_ATTRIBUTE, style, null);
+
+ UIComponent controlFacet = control.getFacet(state);
+ if(controlFacet != null && controlFacet.isRendered()) {
+
+ if(!visible) {
+ String facetStyle =
(String)controlFacet.getAttributes().get("style");
+ facetStyle = facetStyle != null ? facetStyle + "; display:
none" : "; display: none";
+ controlFacet.getAttributes().put("style", facetStyle);
+ }
+
+ controlFacet.encodeAll(context);
+
+ } else {
+
+ String image = expanded ? control.getExpandIcon() :
control.getCollapseIcon();
+ if (image != null && image.trim().length() > 0) {
+ writer.startElement(HTML.IMG_ELEMENT, control);
+ writer.writeAttribute(HTML.SRC_ATTRIBUTE, image, null);
+ writer.writeAttribute(HTML.ALT_ATTRIBUTE, "", null);
+ writer.endElement(HTML.IMG_ELEMENT);
+ }
+
+ String label = expanded ? control.getExpandLabel() :
control.getCollapseLabel();
+ if(label != null && label.trim().length() > 0) {
+ writer.startElement(HTML.A_ELEMENT, control);
+ writer.writeAttribute(HTML.HREF_ATTR, "javascript:void(0);",
null);
+ writer.writeText(label, null);
+ writer.endElement(HTML.A_ELEMENT);
+ }
+ }
+ writer.endElement(HTML.SPAN_ELEM);
+ }
+
+ public HashMap<String, Object> encodeOptions(FacesContext context,
UISubTableToggleControl toggleControl, UISubTable 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, UISubTableToggleControl control) {
+ return null;
+ }
+
+ public String getStyle(FacesContext context, UISubTableToggleControl control) {
+ return null;
+ }
+
+ protected UISubTable findComponent(FacesContext context, UISubTableToggleControl
toggleControl) {
+ String forId = toggleControl.getFor();
+ if (forId != null && forId.length() > 0) {
+
+ UIComponent subTable = getUtils().findComponentFor(context, toggleControl,
forId);
+ if (subTable instanceof UISubTable) {
+ return (UISubTable) subTable;
+ }
+
+ }
+ return null;
+ }
+
+ protected String getState(boolean expand) {
+ return expand ? EXPAND_STATE : COLLAPSE_STATE;
+ }
+
+}
Deleted:
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java
===================================================================
---
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java 2010-05-28
10:40:04 UTC (rev 17344)
+++
root/ui-sandbox/tables/trunk/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java 2010-05-28
10:40:38 UTC (rev 17345)
@@ -1,164 +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.ajax4jsf.renderkit.RendererBase;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
-import org.richfaces.component.UISubTable;
-import org.richfaces.component.UIToggleControl;
-
-/**
- * @author Anton Belevich
- *
- */
-@ResourceDependencies( {@ResourceDependency(library = "javax.faces", name =
"jsf.js"),
- @ResourceDependency(name = "richfaces.js"), @ResourceDependency(name =
"toggler.js")})
-
-public abstract class ToggleControlRendererBase extends RendererBase {
-
- private static final String DISPLAY_NONE = "display: none;";
-
- private static final String EXPAND_STATE = "expand";
-
- private static final String COLLAPSE_STATE = "collapse";
-
-
- protected void encodeControl(FacesContext context, UIComponent component) throws
IOException {
- UIToggleControl toggleControl = (UIToggleControl) component;
-
- UISubTable subTable = findComponent(context, toggleControl);
- if (subTable != null) {
- ResponseWriter writer = context.getResponseWriter();
-
- String toggleId = toggleControl.getClientId(context);
- Map<String, Object> options = encodeOptions(context, toggleControl,
subTable);
- String switchType = subTable.getExpandMode();
-
- boolean expanded = subTable.isExpanded();
-
- encodeControl(context, writer, toggleControl, switchType, expanded, false);
- encodeControl(context, writer, toggleControl, switchType, !expanded, true);
-
- JSFunction jsFunction = new JSFunction("new
RichFaces.ui.DataTableToggler");
- jsFunction.addParameter(toggleId);
- jsFunction.addParameter(options);
-
- writer.startElement(HTML.SCRIPT_ELEM, subTable);
- writer.writeText(jsFunction.toScript(), null);
- writer.endElement(HTML.SCRIPT_ELEM);
- }
-
- }
-
- protected void encodeControl(FacesContext context, ResponseWriter writer,
UIToggleControl 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(HTML.SPAN_ELEM, control);
-
- if (!visible) {
- writer.writeAttribute(HTML.STYLE_ATTRIBUTE, DISPLAY_NONE, null);
- }
-
- writer.writeAttribute(HTML.ID_ATTRIBUTE, control.getClientId() + ":" +
state, null);
- writer.writeAttribute(HTML.CLASS_ATTRIBUTE, styleClass, null);
- writer.writeAttribute(HTML.STYLE_ATTRIBUTE, style, null);
-
- UIComponent controlFacet = control.getFacet(state);
- if(controlFacet != null && controlFacet.isRendered()) {
-
- if(!visible) {
- String facetStyle =
(String)controlFacet.getAttributes().get("style");
- facetStyle = facetStyle != null ? facetStyle + "; display:
none" : "; display: none";
- controlFacet.getAttributes().put("style", facetStyle);
- }
-
- controlFacet.encodeAll(context);
-
- } else {
-
- String image = expanded ? control.getExpandControl() :
control.getCollapseControl();
- if (image != null && image.trim().length() > 0) {
- writer.startElement(HTML.IMG_ELEMENT, control);
- writer.writeAttribute(HTML.SRC_ATTRIBUTE, image, null);
- writer.writeAttribute(HTML.ALT_ATTRIBUTE, "", null);
- writer.endElement(HTML.IMG_ELEMENT);
- }
-
- }
- writer.endElement(HTML.SPAN_ELEM);
- }
-
- public HashMap<String, Object> encodeOptions(FacesContext context,
UIToggleControl toggleControl, UISubTable 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, UIToggleControl control) {
- return null;
- }
-
- public String getStyle(FacesContext context, UIToggleControl control) {
- return null;
- }
-
- protected UISubTable findComponent(FacesContext context, UIToggleControl
toggleControl) {
- String forId = toggleControl.getFor();
- if (forId != null && forId.length() > 0) {
-
- UIComponent subTable = getUtils().findComponentFor(context, toggleControl,
forId);
- if (subTable instanceof UISubTable) {
- return (UISubTable) subTable;
- }
-
- }
- return null;
- }
-
- protected String getState(boolean expand) {
- return expand ? EXPAND_STATE : COLLAPSE_STATE;
- }
-}
Modified:
root/ui-sandbox/tables/trunk/ui/src/main/resources/META-INF/resources/datatable.ecss
===================================================================
---
root/ui-sandbox/tables/trunk/ui/src/main/resources/META-INF/resources/datatable.ecss 2010-05-28
10:40:04 UTC (rev 17344)
+++
root/ui-sandbox/tables/trunk/ui/src/main/resources/META-INF/resources/datatable.ecss 2010-05-28
10:40:38 UTC (rev 17345)
@@ -250,3 +250,13 @@
.rf-st-h{
}
+
+
+/*should be generated in M1*/
+.rf-stt-exp{
+ background-image: url("#{resource['up_icon.gif']}");
+}
+
+.rf-stt-col{
+ background-image: url("#{resource['down_icon.gif']}");
+}
Added:
root/ui-sandbox/tables/trunk/ui/src/main/resources/META-INF/resources/down_icon.gif
===================================================================
(Binary files differ)
Property changes on:
root/ui-sandbox/tables/trunk/ui/src/main/resources/META-INF/resources/down_icon.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified:
root/ui-sandbox/tables/trunk/ui/src/main/resources/META-INF/resources/subtable.js
===================================================================
---
root/ui-sandbox/tables/trunk/ui/src/main/resources/META-INF/resources/subtable.js 2010-05-28
10:40:04 UTC (rev 17344)
+++
root/ui-sandbox/tables/trunk/ui/src/main/resources/META-INF/resources/subtable.js 2010-05-28
10:40:38 UTC (rev 17345)
@@ -5,6 +5,7 @@
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;
@@ -35,21 +36,25 @@
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() {
+ var server = function(options) {
this.switchState();
$(document.getElementById(this.formId)).submit();
};
- var client = function() {
+ var client = function(options) {
if(this.isExpand()) {
- this.collapse();
+ this.collapse(options);
} else {
- this.expand();
+ this.expand(options);
}
};
@@ -58,22 +63,22 @@
name: "RichFaces.ui.SubTable",
- toggle: function(e) {
+ toggle: function(e, options) {
if(this.expandMode == richfaces.ui.SubTable.MODE_AJAX) {
- ajax.call(this, e, this.eventOptions);
+ ajax.call(this, e, this.eventOptions, options);
}else if(this.expandMode == richfaces.ui.SubTable.MODE_SRV) {
- server.call(this);
+ server.call(this, options);
}else if(this.expandMode == richfaces.ui.SubTable.MODE_CLNT) {
- client.call(this);
+ client.call(this, options);
}
},
- collapse: function() {
+ collapse: function(options) {
this.setState(richfaces.ui.SubTable.collapse);
element.call(this).hide();
},
- expand: function() {
+ expand: function(options) {
this.setState(richfaces.ui.SubTable.expand);
element.call(this).show();
},
@@ -82,7 +87,7 @@
return (this.getState() > richfaces.ui.SubTable.collapse);
},
- switchState: function() {
+ switchState: function(options) {
var state = this.isExpand() ? richfaces.ui.SubTable.collapse :
richfaces.ui.SubTable.expand;
this.setState(state);
},
@@ -93,6 +98,10 @@
setState: function(state) {
stateInputElem.call(this).val(state)
+ },
+
+ setOption: function(option) {
+ optionsInputElem.call(this).val(option);
}
};
Deleted: root/ui-sandbox/tables/trunk/ui/src/main/resources/META-INF/resources/toggler.js
===================================================================
---
root/ui-sandbox/tables/trunk/ui/src/main/resources/META-INF/resources/toggler.js 2010-05-28
10:40:04 UTC (rev 17344)
+++
root/ui-sandbox/tables/trunk/ui/src/main/resources/META-INF/resources/toggler.js 2010-05-28
10:40:38 UTC (rev 17345)
@@ -1,48 +0,0 @@
-(function ($, richfaces) {
-
- richfaces.ui = richfaces.ui || {};
-
- richfaces.ui.DataTableToggler = function(id, options) {
- this.id = id;
- this.eventName = options.eventName;
- this.expandControl = options.expandControl;
- this.collapseControl = options.collapseControl;
- this.forId = options.forId;
-
- richfaces.Event.bindById(this.id, this.eventName, this.toggle, this);
- };
-
- $.extend(richfaces.ui.DataTableToggler.prototype, (function () {
-
- var getElementById= function(id) {
- return $(document.getElementById(id))
- }
-
- return {
-
- toggle: function(e) {
- var subtable = richfaces.$(this.forId);
- if(subtable) {
- this.toggleControl(subtable.isExpand());
- 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: root/ui-sandbox/tables/trunk/ui/src/main/resources/META-INF/resources/up_icon.gif
===================================================================
(Binary files differ)
Property changes on:
root/ui-sandbox/tables/trunk/ui/src/main/resources/META-INF/resources/up_icon.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified:
root/ui-sandbox/tables/trunk/ui/src/main/resources/META-INF/tables.faces-config.xml
===================================================================
---
root/ui-sandbox/tables/trunk/ui/src/main/resources/META-INF/tables.faces-config.xml 2010-05-28
10:40:04 UTC (rev 17344)
+++
root/ui-sandbox/tables/trunk/ui/src/main/resources/META-INF/tables.faces-config.xml 2010-05-28
10:40:38 UTC (rev 17345)
@@ -63,8 +63,8 @@
</component-extension>
</component>
<component>
- <component-type>org.richfaces.ToggleControl</component-type>
- <component-class>org.richfaces.component.html.HtmlToggleControl</component-class>
+ <component-type>org.richfaces.SubTableToggleControl</component-type>
+ <component-class>org.richfaces.component.html.HtmlSubTableToggleControl</component-class>
<component-extension>
<cdk:generate
xmlns:cdk="http://richfaces.org/cdk/extensions">false</cd...
</component-extension>
@@ -92,5 +92,11 @@
<renderer-type>org.richfaces.ExtendedDataTableRenderer</renderer-type>
<renderer-class>org.richfaces.renderkit.ExtendedDataTableRenderer</renderer-class>
</renderer>
+ <renderer>
+ <component-family>org.richfaces.SubTableToggleControl</component-family>
+ <renderer-type>org.richfaces.SubTableToggleControl</renderer-type>
+ <renderer-class>org.richfaces.renderkit.html.SubTableToggleControlRenderer</renderer-class>
+ </renderer>
+
</render-kit>
</faces-config>
\ No newline at end of file
Modified: root/ui-sandbox/tables/trunk/ui/src/main/resources/META-INF/tables.taglib.xml
===================================================================
---
root/ui-sandbox/tables/trunk/ui/src/main/resources/META-INF/tables.taglib.xml 2010-05-28
10:40:04 UTC (rev 17344)
+++
root/ui-sandbox/tables/trunk/ui/src/main/resources/META-INF/tables.taglib.xml 2010-05-28
10:40:38 UTC (rev 17345)
@@ -40,10 +40,10 @@
</component>
</tag>
<tag>
- <tag-name>toggleControl</tag-name>
+ <tag-name>subTableToggleControl</tag-name>
<component>
- <component-type>org.richfaces.ToggleControl</component-type>
- <renderer-type>org.richfaces.ToggleControlRenderer</renderer-type>
+ <component-type>org.richfaces.SubTableToggleControl</component-type>
+ <renderer-type>org.richfaces.SubTableToggleControlRenderer</renderer-type>
</component>
</tag>
Modified:
root/ui-sandbox/tables/trunk/ui/src/main/templates/org/richfaces/renderkit/html/toggle-control.template.xml
===================================================================
---
root/ui-sandbox/tables/trunk/ui/src/main/templates/org/richfaces/renderkit/html/toggle-control.template.xml 2010-05-28
10:40:04 UTC (rev 17344)
+++
root/ui-sandbox/tables/trunk/ui/src/main/templates/org/richfaces/renderkit/html/toggle-control.template.xml 2010-05-28
10:40:38 UTC (rev 17345)
@@ -6,10 +6,10 @@
xmlns:javaee="http://java.sun.com/xml/ns/javaee">
<cc:interface>
- <cdk:class>org.richfaces.renderkit.html.ToggleControlRenderer</cdk:class>
- <cdk:superclass>org.richfaces.renderkit.ToggleControlRendererBase</cdk:superclass>
- <cdk:component-family>org.richfaces.ToggleControl</cdk:component-family>
- <cdk:renderer-type>org.richfaces.ToggleControlRenderer</cdk:renderer-type>
+ <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>
</cc:interface>
<cc:implementation>