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>