Author: abelevich
Date: 2010-06-23 13:11:45 -0400 (Wed, 23 Jun 2010)
New Revision: 17663
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTable.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTableToggleControl.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java
Log:
RF-8718, RF-8714
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java 2010-06-23
16:27:39 UTC (rev 17662)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java 2010-06-23
17:11:45 UTC (rev 17663)
@@ -325,5 +325,9 @@
}
super.queueEvent(event);
}
+
+ public static Set<String> getSupportedMetaComponents() {
+ return SUPPORTED_META_COMPONENTS;
+ }
}
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTable.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTable.java 2010-06-23
16:27:39 UTC (rev 17662)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTable.java 2010-06-23
17:11:45 UTC (rev 17663)
@@ -22,22 +22,13 @@
package org.richfaces.component;
-import java.util.HashSet;
-import java.util.Set;
-
import javax.el.ELContext;
import javax.el.ValueExpression;
import javax.faces.application.ResourceDependency;
-import javax.faces.component.UIComponent;
-import javax.faces.component.visit.VisitCallback;
-import javax.faces.component.visit.VisitContext;
-import javax.faces.component.visit.VisitResult;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
-import org.richfaces.context.ExtendedVisitContext;
-import org.richfaces.context.ExtendedVisitContextMode;
import org.richfaces.event.ToggleEvent;
import org.richfaces.event.ToggleListener;
@@ -50,18 +41,6 @@
public static final String MODE_SERVER = "server";
public static final String MODE_CLIENT = "client";
-
- public static final String PARENT_PARTIAL = "partial";
-
- public static final String TB_ID = ":c";
-
- public static final String SUBTABLE = "subtable";
-
- private static final Set<String> SUPPORTED_META_COMPONENTS = new
HashSet<String>();
-
- static {
- SUPPORTED_META_COMPONENTS.add(SUBTABLE);
- }
enum PropertyKeys {
expandMode, expanded, toggleExpression
@@ -82,7 +61,7 @@
valueExpression.setValue(elContext, newValue);
}
- String render = resolveClientId(facesContext, this, SUBTABLE);
+ String render = resolveClientId(facesContext, this, BODY);
getFacesContext().getPartialViewContext().getRenderIds().add(render);
}
@@ -134,32 +113,6 @@
getStateHelper().put(PropertyKeys.expandMode, expandMode);
}
- @Override
- public String resolveClientId(FacesContext facesContext, UIComponent
contextComponent, String metaComponentId) {
- String clientId = super.resolveClientId(facesContext, contextComponent,
metaComponentId);
- if(clientId == null &&
SUPPORTED_META_COMPONENTS.contains(metaComponentId)) {
- return getClientId(facesContext) +
MetaComponentResolver.META_COMPONENT_SEPARATOR_CHAR + metaComponentId;
- //TODO: LOG
- }
- return null;
- }
-
- @Override
- protected boolean visitDataChildren(VisitContext visitContext, VisitCallback
callback, boolean visitRows) {
- if(visitContext instanceof ExtendedVisitContext) {
- ExtendedVisitContext extendedVisitContext =
(ExtendedVisitContext)visitContext;
- if (extendedVisitContext.getVisitMode() == ExtendedVisitContextMode.RENDER)
{
- VisitResult result =
extendedVisitContext.invokeMetaComponentVisitCallback(this, callback, SUBTABLE);
- if(result == VisitResult.ACCEPT) {
- //TODO:
- } else {
- return result == VisitResult.COMPLETE;
- }
- }
- }
- return super.visitDataChildren(visitContext, callback, visitRows);
- }
-
public void setIterationState(Object stateObject) {
Object[] state = (Object[]) stateObject;
if (state != null) {
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTableToggleControl.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTableToggleControl.java 2010-06-23
16:27:39 UTC (rev 17662)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTableToggleControl.java 2010-06-23
17:11:45 UTC (rev 17663)
@@ -21,26 +21,20 @@
*/
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 class UISubTableToggleControl extends UIComponentBase {
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
+ expandIcon, collapseIcon, expandLabel, collapseLabel, forId, event
}
public String getFamily() {
@@ -95,14 +89,4 @@
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()));
- }
}
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2010-06-23
16:27:39 UTC (rev 17662)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2010-06-23
17:11:45 UTC (rev 17663)
@@ -167,7 +167,6 @@
boolean encodeParentTBody = encodeParentTBody(dataTableBase);
encodeBeforeRows(writer, facesContext, dataTableBase, encodeParentTBody,
encodePartialUpdate);
-
if (rowCount > 0) {
processRows(writer, facesContext, dataTableBase, new Object[]
{encodePartialUpdate, encodeParentTBody});
} else {
@@ -204,7 +203,7 @@
facesContext.getPartialViewContext().getPartialResponseWriter().startUpdate(id);
}
- encodeHiddens(writer, facesContext, dataTableBase);
+ encodeHiddens(writer, facesContext, dataTableBase, new
Object[]{encodeParentTBody});
if(encodePartialUpdate) {
facesContext.getPartialViewContext().getPartialResponseWriter().endUpdate();
@@ -244,14 +243,14 @@
encodeStyleClass(writer, context, component, HTML.STYLE_CLASS_ATTR, styleClass);
}
- protected void encodeHiddens(ResponseWriter writer, FacesContext facesContext,
UIDataTableBase dataTableBase) throws IOException {
+ protected void encodeHiddens(ResponseWriter writer, FacesContext facesContext,
UIDataTableBase dataTableBase, Object [] params) throws IOException {
EncodeStrategy encodeStrategy = getHiddenContainerStrategy();
- encodeStrategy.begin(writer, facesContext, dataTableBase, null);
+ encodeStrategy.begin(writer, facesContext, dataTableBase, params);
encodeClientScript(writer, facesContext, dataTableBase);
encodeHiddenInput(writer, facesContext, dataTableBase);
- encodeStrategy.end(writer, facesContext, dataTableBase, null);
+ encodeStrategy.end(writer, facesContext, dataTableBase, params);
}
public void encodeTableEnd(ResponseWriter writer) throws IOException {
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-06-23
16:27:39 UTC (rev 17662)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-06-23
17:11:45 UTC (rev 17663)
@@ -146,8 +146,6 @@
UIDataTable dataTable = (UIDataTable)row;
boolean partialUpdate = rowHolder.isUpdatePartial();
-
- //TODO: try to use rowHolder for storing current <tbody> open/close state
boolean parentTbodyStart = rowHolder.isEncodeParentTBody();
boolean tbodyStart = parentTbodyStart;
@@ -179,15 +177,11 @@
if(partialUpdate) {
partialStart(facesContext, id);
}
-
- writer.startElement(HTML.TBODY_ELEMENT, child);
- writer.writeAttribute(HTML.ID_ATTRIBUTE, id, null);
}
child.encodeAll(facesContext);
if (isSubtable) {
- writer.endElement(HTML.TBODY_ELEMENT);
if(partialUpdate) {
partialEnd(facesContext);
}
@@ -200,6 +194,7 @@
partialStart(facesContext,
dataTable.getRelativeClientId(facesContext) + ":tb");
}
encodeTableBodyStart(writer, facesContext, dataTable);
+ rowHolder.setRowStart(true);
tbodyStart = true;
}
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2010-06-23
16:27:39 UTC (rev 17662)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2010-06-23
17:11:45 UTC (rev 17663)
@@ -48,6 +48,8 @@
*
*/
public class SubTableRenderer extends AbstractTableRenderer {
+
+ public static final String TB_ROW = ":c";
private static final String STATE = ":state";
@@ -55,9 +57,7 @@
private static final String HIDDEN_STYLE = "display: none";
-
private class SubTableHiddenEncodeStrategy implements EncodeStrategy {
-
public void begin(ResponseWriter writer, FacesContext context, UIComponent
component, Object[] params) throws IOException {
UISubTable subTable = (UISubTable)component;
writer.startElement(HTML.TR_ELEMENT, subTable);
@@ -69,8 +69,14 @@
public void end(ResponseWriter writer, FacesContext context, UIComponent
component, Object[] params) throws IOException {
writer.endElement(HTML.TD_ELEM);
writer.endElement(HTML.TR_ELEMENT);
+
+ if(params != null && params.length ==1) {
+ boolean endTbody = (Boolean)params[0];
+ if(endTbody) {
+ encodeTableBodyEnd(writer);
+ }
+ }
}
-
};
protected void doDecode(FacesContext facesContext, UIComponent component) {
@@ -135,11 +141,11 @@
UIDataTableBase component = findParent(subTable);
if(component instanceof UIDataTable) {
-// writer.startElement(HTML.TBODY_ELEMENT, null);
-// writer.writeAttribute(HTML.ID_ATTRIBUTE,
dataTable.getRelativeClientId(facesContext) + ":" + subTable.getId() +
":c", null);
-
+ writer.startElement(HTML.TBODY_ELEMENT, null);
+ writer.writeAttribute(HTML.ID_ATTRIBUTE,
component.getRelativeClientId(facesContext) + ":" + subTable.getId() + TB_ROW,
null);
+
String predefinedStyles = !subTable.isExpanded() ? "display:
none;" : null;
-
+
writer.writeAttribute(HTML.CLASS_ATTRIBUTE, getTableSkinClass(), null);
encodeStyle(writer, facesContext, subTable, predefinedStyles);
}
@@ -148,13 +154,6 @@
@Override
public void encodeBeforeRows(ResponseWriter writer, FacesContext facesContext,
UIDataTableBase dataTableBase, boolean encodeParentTBody, boolean partialUpdate) throws
IOException {
UISubTable subTable = (UISubTable)dataTableBase;
-
- UIDataTableBase parent = findParent(subTable);
-
- if(parent instanceof UISubTable) {
- encodeTableBodyEnd(writer);
- }
-
encodeTableBodyStart(writer, facesContext, subTable);
encodeSubTableDomElement(writer, facesContext, subTable);
setupTableStartElement(facesContext, subTable);
@@ -182,7 +181,19 @@
}
while (components.hasNext()) {
- encodeColumn(context, writer, (UIColumn) components.next(), rowHolder);
+ UIComponent component = components.next();
+
+ if(component instanceof UIColumn) {
+ encodeColumn(context, writer, (UIColumn)component , rowHolder);
+
+ } else if (component instanceof UISubTable) {
+ if(component.isRendered()) {
+ encodeRowEnd(writer);
+ }
+
+ component.encodeAll(context);
+ rowHolder.setRowStart(true);
+ }
}
encodeRowEnd(writer);
@@ -197,12 +208,15 @@
boolean encodeParentTBody, boolean partialUpdate) throws IOException {
UISubTable subTable = (UISubTable)dataTableBase;
encodeFooterFacet(writer, facesContext, subTable, false);
-// encodeTableBodyEnd(writer);
}
@Override
public boolean encodeParentTBody(UIDataTableBase dataTableBase) {
- return true;
+ UIDataTableBase parent = findParent((UISubTable)dataTableBase);
+ if(parent instanceof UIDataTable) {
+ return true;
+ }
+ return false;
}
public void encodeHiddenInput(ResponseWriter writer, FacesContext facesContext,
UIDataTableBase dataTableBase) throws IOException {
@@ -347,18 +361,15 @@
UISubTable subTable = (UISubTable)component;
setupTableStartElement(facesContext, subTable);
- if(UISubTable.SUBTABLE.equals(metaComponentId)) {
+ if(UISubTable.BODY.equals(metaComponentId)) {
ResponseWriter writer = facesContext.getResponseWriter();
UIDataTableBase dataTableBase = findParent(subTable);
- String updateId = dataTableBase.getRelativeClientId(facesContext) +
":" + subTable.getId() +":c";
-
+ String updateId = dataTableBase.getRelativeClientId(facesContext) +
":" + subTable.getId() +TB_ROW;
+
facesContext.getPartialViewContext().getPartialResponseWriter().startUpdate(updateId);
encodeTableRows(writer, facesContext, subTable, false);
facesContext.getPartialViewContext().getPartialResponseWriter().endUpdate();
-
- }else {
- super.encodeMetaComponent(facesContext, component, metaComponentId);
}
}
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java 2010-06-23
16:27:39 UTC (rev 17662)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java 2010-06-23
17:11:45 UTC (rev 17663)
@@ -83,8 +83,6 @@
writer.startElement(HTML.SCRIPT_ELEM, subTable);
writer.writeText(jsFunction.toScript(), null);
writer.endElement(HTML.SCRIPT_ELEM);
-
- subTable.addToggleListener(toggleControl);
}
}