JBoss Rich Faces SVN: r15834 - root/framework/trunk/impl/src/main/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2009-11-05 05:50:08 -0500 (Thu, 05 Nov 2009)
New Revision: 15834
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/component/UIDataAdaptor.java
Log:
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/component/UIDataAdaptor.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/component/UIDataAdaptor.java 2009-11-05 10:49:00 UTC (rev 15833)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/component/UIDataAdaptor.java 2009-11-05 10:50:08 UTC (rev 15834)
@@ -783,7 +783,10 @@
* @param visitor
*/
public void walk(FacesContext faces, DataVisitor visitor, Object argument) {
- Range range = null;
+ Object key = getRowKey();
+ captureOrigValue(faces);
+
+ Range range = null;
DataComponentState componentState = getComponentState();
if (componentState != null) {
@@ -791,8 +794,11 @@
}
getExtendedDataModel().walk(faces, visitor, range, argument);
+
+ setRowKey(key);
+ restoreOrigValue(faces);
}
-
+
public void processDecodes(FacesContext faces) {
if (!this.isRendered()) {
return;
15 years, 2 months
JBoss Rich Faces SVN: r15833 - root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2009-11-05 05:49:00 -0500 (Thu, 05 Nov 2009)
New Revision: 15833
Modified:
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/component/Row.java
Log:
Modified: root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/component/Row.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/component/Row.java 2009-11-05 10:48:23 UTC (rev 15832)
+++ root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/component/Row.java 2009-11-05 10:49:00 UTC (rev 15833)
@@ -24,18 +24,31 @@
import java.util.Iterator;
import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import org.ajax4jsf.model.DataVisitor;
+
/**
* Marker interface for table columns, rendered as entire row.
* @author shura
*
*/
-public interface Row extends Column {
+public interface Row {
/**
* Get iterator for all columns contained in this row.
- * @return
+ *
*/
public Iterator<UIComponent> columns();
-
+
+ public void setRowKey(FacesContext context, Object rowKey);
+
+ public void walk(FacesContext context, DataVisitor visitor, Object argument);
+
+ public String getCellSkinClass();
+
+ public String getRowSkinClass();
+
+ public String getFirstRowSkinClass();
+
}
15 years, 2 months
JBoss Rich Faces SVN: r15832 - root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2009-11-05 05:48:23 -0500 (Thu, 05 Nov 2009)
New Revision: 15832
Removed:
root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/simpletable.template.xml
Log:
Deleted: root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/simpletable.template.xml
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/simpletable.template.xml 2009-11-05 10:42:57 UTC (rev 15831)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/simpletable.template.xml 2009-11-05 10:48:23 UTC (rev 15832)
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<cdk:root xmlns="http://richfaces.org/xhtml-el" xmlns:cdk="http://richfaces.org/cdk"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- class="org.richfaces.renderkit.html.SimpleDataTableRenderer"
- superclass="org.richfaces.renderkit.SimpleDataTableRendererBase"
- componentclass="org.richfaces.component.UISimpleDataTable">
- <table id="#{clientId}">
- <cdk:call expression="encodeTableStructure(context,component);" />
- <cdk:body>
- <cdk:call expression="encodeTableBody(context,component);" />
- </cdk:body>
- </table>
-</cdk:root>
\ No newline at end of file
15 years, 2 months
JBoss Rich Faces SVN: r15831 - in root/ui-sandbox/trunk/components/tables/ui/src/main: java/org/richfaces/component and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2009-11-05 05:42:57 -0500 (Thu, 05 Nov 2009)
New Revision: 15831
Added:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ProcessRowHolder.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowHolder.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleDataTableRenderer.java
Removed:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/CellEncodeEvent.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeEvent.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowEncodeEvent.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowEncoder.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleDataTableRendererBase.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/TableHolder.java
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/config/component/tables.xml
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumnGroup.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTable.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISimpleDataTable.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISubTable.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlColumnGroup.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeListener.java
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/faces-config.xml
Log:
new renderer vision
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/config/component/tables.xml
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/config/component/tables.xml 2009-11-05 01:25:23 UTC (rev 15830)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/config/component/tables.xml 2009-11-05 10:42:57 UTC (rev 15831)
@@ -55,9 +55,8 @@
<![CDATA[TODO: add description here]]>
</description>
- <renderer generate="true">
- <name>org.richfaces.renderkit.html.SimpleDataTableRenderer</name>
- <template>org/richfaces/renderkit/html/simpletable.template.xml</template>
+ <renderer generate="false" override="false">
+ <name>org.richfaces.renderkit.SimpleDataTableRenderer</name>
</renderer>
<tag>
<name>simpleDataTable</name>
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumnGroup.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumnGroup.java 2009-11-05 01:25:23 UTC (rev 15830)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumnGroup.java 2009-11-05 10:42:57 UTC (rev 15831)
@@ -25,12 +25,16 @@
import javax.faces.component.UIComponent;
import javax.faces.component.UIPanel;
+import javax.faces.context.FacesContext;
+import org.ajax4jsf.model.DataVisitor;
+import org.richfaces.renderkit.RowHolder;
+
/**
* JSF component class
*
*/
-public abstract class UIColumnGroup extends UIPanel implements Row {
+public abstract class UIColumnGroup extends UIPanel implements Row, Column {
public static final String COMPONENT_TYPE = "org.richfaces.Colgroup";
@@ -48,4 +52,27 @@
throw new IllegalStateException("Property 'breakBefore' for subtable is read-only");
}
+ public void setRowKey(FacesContext context, Object rowKey) {
+ // columnGroup doesn't have data model
+ }
+
+ public void walk(FacesContext context, DataVisitor visitor, Object argument) {
+ if(!(argument instanceof RowHolder)) {
+ return;
+ }
+
+ visitor.process(context, null, argument);
+ }
+
+ public String getCellSkinClass() {
+ return null;
+ }
+
+ public String getRowSkinClass() {
+ return null;
+ }
+
+ public String getFirstRowSkinClass() {
+ return null;
+ }
}
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTable.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTable.java 2009-11-05 01:25:23 UTC (rev 15830)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTable.java 2009-11-05 10:42:57 UTC (rev 15831)
@@ -4,7 +4,7 @@
import javax.faces.component.UIComponent;
-public class UIDataTable extends UISequence {
+public abstract class UIDataTable extends UISequence implements Row {
public Iterator<UIComponent> columns() {
return new ColumnsIterator(this);
@@ -37,4 +37,5 @@
public boolean getRendersChildren() {
return true;
}
+
}
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISimpleDataTable.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISimpleDataTable.java 2009-11-05 01:25:23 UTC (rev 15830)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISimpleDataTable.java 2009-11-05 10:42:57 UTC (rev 15831)
@@ -11,4 +11,15 @@
public abstract class UISimpleDataTable extends UIDataTable {
+ public String getCellSkinClass() {
+ return "rich-table-cell";
+ }
+
+ public String getRowSkinClass() {
+ return "rich-table-row";
+ }
+
+ public String getFirstRowSkinClass() {
+ return "rich-table-firstrow";
+ }
}
\ No newline at end of file
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISubTable.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISubTable.java 2009-11-05 01:25:23 UTC (rev 15830)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISubTable.java 2009-11-05 10:42:57 UTC (rev 15831)
@@ -26,12 +26,14 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import org.ajax4jsf.model.DataVisitor;
+
/**
* JSF component class
*
*/
-public abstract class UISubTable extends UIDataTable implements Row {
+public abstract class UISubTable extends UIDataTable implements Row, Column {
public static final String COMPONENT_TYPE = "org.richfaces.SubTable";
@@ -56,20 +58,33 @@
return null;
}
- @Override
- public void resetDataModel(FacesContext context) {
- super.resetDataModel(context);
- }
-
public void setSortExpression(String sortExpression) {
// Do nothing - subtable is not sortable element;
//TODO nick - throw exception
}
+ @Override
+ public void walk(FacesContext context, DataVisitor visitor, Object argument) {
+ resetDataModel(context);
+ super.walk(context, visitor, argument);
+ }
@Override
public boolean getRendersChildren() {
//TODO nick - why "false"?
return false;
}
+
+ public String getCellSkinClass() {
+ return "rich-subtable-cell";
+ }
+
+ public String getRowSkinClass() {
+ return "rich-subtable-row";
+ }
+
+ public String getFirstRowSkinClass() {
+ return "rich-subtable-firstrow";
+ }
+
}
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlColumnGroup.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlColumnGroup.java 2009-11-05 01:25:23 UTC (rev 15830)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlColumnGroup.java 2009-11-05 10:42:57 UTC (rev 15831)
@@ -1,6 +1,7 @@
package org.richfaces.component.html;
import javax.el.MethodExpression;
+import javax.faces.context.FacesContext;
import org.richfaces.component.UIColumnGroup;
import org.richfaces.model.Ordering;
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2009-11-05 01:25:23 UTC (rev 15830)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2009-11-05 10:42:57 UTC (rev 15831)
@@ -22,27 +22,21 @@
package org.richfaces.renderkit;
import java.io.IOException;
-import java.util.Map;
-import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
import org.ajax4jsf.model.DataVisitResult;
import org.ajax4jsf.model.DataVisitor;
import org.ajax4jsf.renderkit.RendererBase;
-import org.ajax4jsf.renderkit.RendererUtils;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
-import org.richfaces.component.UIDataAdaptor;
+import org.richfaces.component.Row;
import org.richfaces.component.UIDataTable;
-import org.richfaces.component.util.HtmlUtil;
/**
* @author shura
*
*/
-public abstract class AbstractRowsRenderer extends RendererBase implements DataVisitor, ElementEncodeListener {
-
+public abstract class AbstractRowsRenderer extends RendererBase implements DataVisitor {
+ /*
public static final String[][] TABLE_EVENT_ATTRS = {
//TODO nick - clarify new names for attributes
{"onclick","onRowClick"},
@@ -54,94 +48,39 @@
{"onmouseout","onRowMouseOut"}
};
- public static final String ROW_CLASS_KEY = AbstractRowsRenderer.class.getName() + ".rowClass";
-
- public static final String SKIN_ROW_CLASS_KEY = AbstractRowsRenderer.class.getName() + ".skinRowClass";
-
- public static final String CELL_CLASS_KEY = AbstractRowsRenderer.class.getName() + ".cellClass";
-
- public static final String SKIN_CELL_CLASS_KEY = AbstractRowsRenderer.class.getName() + ".skinCellClass";
-
- public static final String SKIN_FIRST_ROW_CLASS_KEY = AbstractRowsRenderer.class.getName() + ".firstRowSkinClass";
-
-
- protected abstract String getCellSkinClass();
+ */
- public abstract RowEncoder getRowEncoder(TableHolder holder);
+ public abstract void encodeRow(FacesContext context, RowHolder rowHolder) throws IOException;
- protected String getCellStyleClasses(FacesContext context, UIComponent component) {
- StringBuffer styleClass = new StringBuffer();
-
- // Construct predefined classes
- //TODO nick - use FacesContext#attributes
- Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
- Object parentPredefined = requestMap.get(AbstractRowsRenderer.SKIN_CELL_CLASS_KEY);
- if (null != parentPredefined) {
- //TODO nick - use HtmlUtil.concatClasses(String ...);
- styleClass.append(parentPredefined).append(" ");
- } else {
- styleClass.append(getCellSkinClass());
- }
- // Append class from parent component.
- Object parent = requestMap.get(AbstractRowsRenderer.CELL_CLASS_KEY);
- if (null != parent) {
- styleClass.append(parent).append(" ");
- }
-
- Object custom = component.getAttributes().get("styleClass");
- if (null != custom) {
- styleClass.append(custom);
- }
- return styleClass.toString();
-
- }
-
public DataVisitResult process(FacesContext context, Object rowKey, Object argument) {
- TableHolder holder = (TableHolder) argument;
- UIDataAdaptor table = holder.getTable();
- table.setRowKey(context, rowKey);
+ RowHolder holder = (RowHolder) argument;
+ Row row = holder.getRow();
+ row.setRowKey(context, rowKey);
try {
- RowEncoder encoder = getRowEncoder(holder);
- encoder.setHeader(false);
- encoder.encodeRows(context, table);
+ encodeRow(context, holder);
} catch (IOException e) {
//TODO: seems we need add throws IOException ???
- }
+ }
+
holder.nextRow();
return DataVisitResult.CONTINUE;
}
+ //TODO remove
public void encodeRows(FacesContext facesContext, UIDataTable table) throws IOException {
- TableHolder tableHolder = new TableHolder(table);
- encodeRows(facesContext, table, tableHolder);
+ RowHolder rowHolder = new RowHolder(table);
+ encodeRows(facesContext, table, rowHolder);
}
- protected void encodeRows(FacesContext context, UIDataTable table, TableHolder tableHolder) throws IOException {
- Object key = table.getRowKey();
- table.captureOrigValue(context);
-
- table.walk(context, this, tableHolder);
-
- doCleanup(context, tableHolder);
- table.setRowKey(key);
- table.restoreOrigValue(context);
+ protected void encodeRows(FacesContext context, Row table, RowHolder rowHolder) throws IOException {
+ table.walk(context, this, rowHolder);
}
- protected void doCleanup(FacesContext context, TableHolder tableHolder) throws IOException {
- // Hoock method for perform encoding after all rows is rendered
- }
-
public boolean getRendersChildren() {
return true;
}
- public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
- //TODO nick - move this down by classes hierarchy
- if(component instanceof UIDataTable) {
- encodeRows(context, (UIDataTable)component);
- }
- }
-
+ /*
protected void encodeRowEvents(FacesContext context, UIDataAdaptor table) throws IOException {
RendererUtils utils2 = getUtils();
@@ -150,133 +89,5 @@
utils2.encodeAttribute(context, table, attrs[1], attrs[0]);
}
- }
-
- /**
- * Encode HTML "class" attribute, if is not empty. Classes combined from
- * pre-defined skin classes, class from parent component, and custom
- * attribute.
- *
- * @param writer
- * @param parentPredefined TODO
- * @param predefined
- * predefined skin classes
- * @param parent
- * class from parent component
- * @param custom
- * custom classes.
- * @throws IOException
- */
-
- protected void encodeStyleClass(ResponseWriter writer, Object parentPredefined, Object predefined,
- Object parent, Object custom) throws IOException {
-
- StringBuffer styleClass = new StringBuffer();
-
- // Construct predefined classes
- //TODO nick - use HtmlUtil.concatClasses(String ...);
- if (null != parentPredefined) {
- styleClass.append(parentPredefined).append(" ");
- } else if (null != predefined) {
- styleClass.append(predefined).append(" ");
- }
-
- // Append class from parent component.
- if (null != parent) {
- styleClass.append(parent).append(" ");
- }
- if (null != custom) {
- styleClass.append(custom);
- }
- if (styleClass.length() > 0) {
- writer.writeAttribute(HTML.CLASS_ATTRIBUTE, styleClass, "styleClass");
- }
- }
-
- protected void encodeStyle(ResponseWriter writer, Object parentPredefined,
- Object predefined, Object parent, Object custom) throws IOException {
-
- StringBuffer style = new StringBuffer();
- // Construct predefined styles
- //TODO nick - use HtmlUtil.concatStyles(String ...);
- if (null != parentPredefined) {
- style.append(parentPredefined).append(" ");
- } else if (null != predefined) {
- style.append(predefined).append(" ");
- }
- // Append style from parent component.
- if (null != parent) {
- style.append(parent).append(" ");
- }
- if (null != custom) {
- style.append(custom);
- }
- if (style.length() > 0) {
- writer.writeAttribute("style", style, "style");
- }
-
- }
-
-
- /**
- * Render component and all its children with current row/cell style
- * classes.
- *
- * @param context
- * @param cell
- * @param skinFirstRowClass TODO
- * @param skinRowClass
- * TODO
- * @param rowClass
- * @param skinCellClass
- * TODO
- * @param cellClass
- * @throws IOException
- */
-
-/*
- protected void encodeCellChildren(FacesContext context, UIComponent cell,
- String skinFirstRowClass, String skinRowClass, String rowClass,
- String skinCellClass, String cellClass) throws IOException {
-
- Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
- // Save top level class parameters ( if any ), and put new for this
- // component
- Object savedRowClass = requestMap.get(ROW_CLASS_KEY);
- if (null != rowClass) {
- requestMap.put(ROW_CLASS_KEY, rowClass);
-
- }
- Object savedSkinFirstRowClass = requestMap.get(SKIN_FIRST_ROW_CLASS_KEY);
- if (null != skinRowClass) {
- requestMap.put(SKIN_FIRST_ROW_CLASS_KEY, skinFirstRowClass);
-
- }
- Object savedSkinRowClass = requestMap.get(SKIN_ROW_CLASS_KEY);
- if (null != skinRowClass) {
- requestMap.put(SKIN_ROW_CLASS_KEY, skinRowClass);
-
- }
- Object savedCellClass = requestMap.get(CELL_CLASS_KEY);
- if (null != cellClass) {
- requestMap.put(CELL_CLASS_KEY, cellClass);
- }
- Object savedSkinCellClass = requestMap.get(SKIN_CELL_CLASS_KEY);
- if (null != skinCellClass) {
- requestMap.put(SKIN_CELL_CLASS_KEY, skinCellClass);
-
- }
-
- encodeCell(context, cell);
-
- // Restore original values.
- requestMap.put(ROW_CLASS_KEY, savedRowClass);
- requestMap.put(CELL_CLASS_KEY, savedCellClass);
- requestMap.put(SKIN_FIRST_ROW_CLASS_KEY, savedSkinFirstRowClass);
- requestMap.put(SKIN_ROW_CLASS_KEY, savedSkinRowClass);
- requestMap.put(SKIN_CELL_CLASS_KEY, savedSkinCellClass);
-
- }
-*/
-
+ } */
}
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2009-11-05 01:25:23 UTC (rev 15830)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2009-11-05 10:42:57 UTC (rev 15831)
@@ -1,13 +1,11 @@
package org.richfaces.renderkit;
-import java.io.IOException;
import java.util.Iterator;
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 org.richfaces.component.Column;
import org.richfaces.component.Row;
@@ -21,17 +19,6 @@
})
public abstract class AbstractTableRenderer extends AbstractRowsRenderer {
- public void encodeTableBody (FacesContext context, UIDataTable table) throws IOException {
- encodeBodyBegin(context, table);
- encodeRows(context, table);
- encodeBodyEnd(context, table);
- }
-
- public abstract void encodeBodyBegin(FacesContext context, UIDataTable table) throws IOException;
-
- public abstract void encodeBodyEnd(FacesContext context, UIDataTable table) throws IOException;
-
-
public boolean isColumnFacetPresent(UIDataTable table, String facetName) {
Iterator<UIComponent> columns = table.columns();
boolean result = false;
@@ -70,8 +57,7 @@
protected int getColumnsCount(UIDataTable table) {
// check for exact value in component
Integer span = (Integer) table.getAttributes().get("columns");
- int count = (null != span && span.intValue() != Integer.MIN_VALUE) ?
- span.intValue() : calculateRowColumns(table.columns());
+ int count = (null != span && span.intValue() != Integer.MIN_VALUE) ? span.intValue() : calculateRowColumns(table.columns());
return count;
}
@@ -122,10 +108,4 @@
}
return count;
}
-
- @Override
- public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
- encodeTableBody(context, (UIDataTable) component);
- }
-
}
Deleted: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/CellEncodeEvent.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/CellEncodeEvent.java 2009-11-05 01:25:23 UTC (rev 15830)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/CellEncodeEvent.java 2009-11-05 10:42:57 UTC (rev 15831)
@@ -1,36 +0,0 @@
-package org.richfaces.renderkit;
-
-import java.util.Map;
-
-import javax.faces.component.UIColumn;
-import javax.faces.context.FacesContext;
-
-//TODO nick - can this be UIComponent instead of UIColumn?
-public class CellEncodeEvent implements ElementEncodeEvent <UIColumn> {
-
- private FacesContext context;
-
- private UIColumn source;
-
- private Map<String, String> styleClasses;
-
-
- public CellEncodeEvent(FacesContext context, UIColumn source) {
- this.context = context;
- this.source = source;
- }
-
- public FacesContext getContext() {
- return this.context;
- }
-
- public UIColumn getSource() {
- return this.source;
- }
-
- public Map<String, String> getStyleClasses() {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
Deleted: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeEvent.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeEvent.java 2009-11-05 01:25:23 UTC (rev 15830)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeEvent.java 2009-11-05 10:42:57 UTC (rev 15831)
@@ -1,16 +0,0 @@
-package org.richfaces.renderkit;
-
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-public interface ElementEncodeEvent <T extends UIComponent> {
-
- public Map <String, String> getStyleClasses();
-
- public T getSource();
-
- public FacesContext getContext();
-
-}
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeListener.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeListener.java 2009-11-05 01:25:23 UTC (rev 15830)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeListener.java 2009-11-05 10:42:57 UTC (rev 15831)
@@ -2,27 +2,42 @@
import java.io.IOException;
+import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
-import org.richfaces.component.UISubTable;
+import org.richfaces.component.UIDataTable;
public interface ElementEncodeListener {
+
+ public void encodeRowStart(ResponseWriter writer, FacesContext context, UIComponent component, RowHolder holder) throws IOException;
-// public void encodeFirstCell(CellEncodeEvent event)throws IOException;
+ public void encodeRowEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException;
- //TODO nick - also encodeFooterCell?
- public void encodeHeaderCell(CellEncodeEvent event) throws IOException;
+ public void encodeCellStart(ResponseWriter writer, FacesContext context, UIComponent component, RowHolder holder) throws IOException;
- public void encodeCell(CellEncodeEvent event) throws IOException;
-
- //TODO nick - encodeFirstRow and encodeRowStart are not on the same abstraction level
- public void encodeFirstRow(RowEncodeEvent event) throws IOException;
+ public void encodeCellEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException;
- public void encodeRowStart(RowEncodeEvent event) throws IOException;
+// public void encodeHeaderCellStart(ResponseWriter writer, FacesContext context, UIComponent component, String styleClass) throws IOException;
+//
+// public void encodeHeaderCellEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException;
- public void encodeRowEnd(RowEncodeEvent event) throws IOException;
+ public void encodeFirstRowStart(ResponseWriter writer, FacesContext context, UIComponent component, RowHolder holder) throws IOException;
+
+ public void encodeFirstRowEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException;
+
+ public void encodeTableStart(ResponseWriter writer, FacesContext context, UIDataTable dataTable) throws IOException;
+
+ public void encodeTableEnd(ResponseWriter writer, FacesContext context, UIDataTable dataTable) throws IOException;
+
+ public void encodeTableBodyStart(ResponseWriter writer, FacesContext context, UIDataTable dataTable) throws IOException;
+
+ public void encodeTableBodyEnd(ResponseWriter writer, FacesContext context, UIDataTable dataTable) throws IOException;
+
+ public void encodeCaption(ResponseWriter writer, FacesContext context, UIDataTable dataTable) throws IOException;
+
+ public void encodeHeader(ResponseWriter writer, FacesContext context, UIDataTable dataTable, int columns) throws IOException;
+
+ public void encodeFooter(ResponseWriter writer, FacesContext context, UIDataTable dataTable, int columns) throws IOException;
- //TODO nick - should be removed?
- public void encodeSubTable(FacesContext context, UISubTable subTable) throws IOException;
-
}
Added: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ProcessRowHolder.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ProcessRowHolder.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ProcessRowHolder.java 2009-11-05 10:42:57 UTC (rev 15831)
@@ -0,0 +1,28 @@
+package org.richfaces.renderkit;
+
+import javax.faces.component.UIComponent;
+
+public class ProcessRowHolder {
+
+ private UIComponent component;
+
+ private int processRow;
+
+
+ public int getProcessRow() {
+ return processRow;
+ }
+
+ public void setProcessRow(int processRow) {
+ this.processRow = processRow;
+ }
+
+ public ProcessRowHolder(UIComponent component) {
+ this.component = component;
+ }
+
+ public int nextRow(){
+ return ++processRow;
+ }
+
+}
Deleted: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowEncodeEvent.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowEncodeEvent.java 2009-11-05 01:25:23 UTC (rev 15830)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowEncodeEvent.java 2009-11-05 10:42:57 UTC (rev 15831)
@@ -1,34 +0,0 @@
-package org.richfaces.renderkit;
-
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-public class RowEncodeEvent implements ElementEncodeEvent<UIComponent> {
-
- private FacesContext context;
-
- private UIComponent source;
-
- private Map<String, String> styleClasses;
-
- public RowEncodeEvent(FacesContext context, UIComponent source) {
- this.context = context;
- this.source = source;
- }
-
- public FacesContext getContext() {
- return this.context;
- }
-
- public UIComponent getSource() {
- return this.source;
- }
-
- public Map<String, String> getStyleClasses() {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
Deleted: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowEncoder.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowEncoder.java 2009-11-05 01:25:23 UTC (rev 15830)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowEncoder.java 2009-11-05 10:42:57 UTC (rev 15831)
@@ -1,126 +0,0 @@
-package org.richfaces.renderkit;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.faces.component.UIColumn;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.renderkit.RendererUtils;
-import org.richfaces.component.Column;
-import org.richfaces.component.Row;
-import org.richfaces.component.UISubTable;
-
-
-public class RowEncoder {
-
-
- private ElementEncodeListener listener;
-
- private Map <String, String> styleClasses = new HashMap<String, String>();
-
- private boolean header = false;
-
- public void encodeCell(FacesContext context, UIColumn column, int currentColumn) throws IOException {
- CellEncodeEvent event = new CellEncodeEvent(context, column);
- listener.encodeCell(event);
- }
-
- public void encodeHeaderCell(FacesContext context, UIColumn column, int currentColumn) throws IOException {
- CellEncodeEvent event = new CellEncodeEvent(context, column);
- listener.encodeHeaderCell(event);
- }
-
- public void encodeRowEnd(FacesContext context, UIComponent component) throws IOException {
- RowEncodeEvent event = new RowEncodeEvent(context, component);
- listener.encodeRowEnd(event);
- }
-
- public void encodeRowStart(FacesContext context, UIComponent component) throws IOException {
- RowEncodeEvent event = new RowEncodeEvent(context, component);
- listener.encodeRowStart(event);
- }
-
- public void encodeFirstRow(FacesContext context, UIComponent row) throws IOException {
- RowEncodeEvent event = new RowEncodeEvent(context, row);
- listener.encodeFirstRow(event);
- }
-
- public ElementEncodeListener getListener() {
- return listener;
- }
-
- public void setListener(ElementEncodeListener listener) {
- this.listener = listener;
- }
-
- public void encodeSubTable(FacesContext context, UISubTable subTable) throws IOException {
- subTable.resetDataModel(context);
- listener.encodeSubTable(context, subTable);
- }
-
- public void encodeRows(FacesContext context, UIComponent component) throws IOException {
- boolean firstRow = true;
- int currentColumn = 0;
- Iterator<UIComponent> iterator = component.getChildren().iterator();
- while(iterator.hasNext()) {
-
- UIComponent child = iterator.next();
- if(!(child instanceof UISubTable)) {
-
- if(firstRow) {
- encodeRowStart(context, child);
- firstRow = false;
- }
-
- if(child instanceof Row) {
- if(!firstRow) {
- encodeRowEnd(context, null);
- }
- encodeRows(context, child);
- }
-
- if(child instanceof UIColumn) {
-
- UIColumn column = (UIColumn)child;
- //TODO: check
- if(column instanceof Column && ((Column)column).isBreakBefore()) {
- encodeRows(context, column);
- }
-
- if(header) {
- encodeHeaderCell(context, column, currentColumn);
- } else {
- encodeCell(context, column, currentColumn);
- }
-
- }
-
- } else {
- UISubTable subTable = (UISubTable)child;
- encodeSubTable(context,subTable);
- }
- }
- encodeRowEnd(context, null);
- }
-
- public RendererUtils getRenderUtils() {
- return RendererUtils.getInstance();
- }
-
- public void setStyleClass(String key, String value) {
- styleClasses.put(key, value);
- }
-
- public boolean isHeader() {
- return header;
- }
-
- public void setHeader(boolean header) {
- this.header = header;
- }
-
-}
Added: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowHolder.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowHolder.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowHolder.java 2009-11-05 10:42:57 UTC (rev 15831)
@@ -0,0 +1,90 @@
+package org.richfaces.renderkit;
+
+import org.richfaces.component.Row;
+
+public class RowHolder {
+
+ private int currentRow = 0;
+
+ private String cellElement;
+
+ private String cellClass;
+
+ private String rowClass;
+
+ private String firstRowClass;
+
+ private boolean headerRow;
+
+ public boolean isHeaderRow() {
+ return headerRow;
+ }
+
+ public void setHeaderRow(boolean headerRow) {
+ this.headerRow = headerRow;
+ }
+
+ private Row row;
+
+ public RowHolder(Row row) {
+ this.row = row;
+ }
+
+ public int getCurrentRow() {
+ return currentRow;
+ }
+
+ public int nextRow() {
+ return ++currentRow;
+ }
+
+ public void setCurrentRow(int currentRow) {
+ this.currentRow = currentRow;
+ }
+
+ public void resetCurrentRow() {
+ this.currentRow = 0;
+ }
+
+ public String getCellClass() {
+ return this.cellClass;
+ }
+
+ public void setCellClass(String cellClass) {
+ this.cellClass = cellClass;
+ }
+
+ public String getRowClass() {
+ return this.rowClass;
+ }
+
+ public void setRowClass(String rowClass) {
+ this.rowClass = rowClass;
+ }
+
+ public String getFirstRowClass() {
+ return this.firstRowClass;
+ }
+
+ public void setFirstRowClass(String firstRowClass) {
+ this.firstRowClass = firstRowClass;
+ }
+
+ public String getCellElement() {
+ return cellElement;
+ }
+
+ public void setCellElement(String cellElement) {
+ this.cellElement = cellElement;
+ }
+
+ public Row getRow() {
+ return this.row;
+ }
+
+ public void setRow(Row row) {
+ this.row = row;
+ }
+
+}
+
Added: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleDataTableRenderer.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleDataTableRenderer.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleDataTableRenderer.java 2009-11-05 10:42:57 UTC (rev 15831)
@@ -0,0 +1,463 @@
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+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 org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.component.Row;
+import org.richfaces.component.UIDataTable;
+import org.richfaces.component.UISimpleDataTable;
+
+@ResourceDependencies({
+ @ResourceDependency(name = "simple-datatable.js"),
+ @ResourceDependency(name = "simple-table.css")
+})
+public class SimpleDataTableRenderer extends AbstractTableRenderer implements ElementEncodeListener{
+
+
+ protected void encodeTableStructure(ResponseWriter writer, FacesContext context, UIDataTable dataTable) throws IOException {
+
+ Object key = dataTable.getRowKey();
+ dataTable.captureOrigValue(context);
+ dataTable.setRowKey(context, null);
+
+ encodeCaption(writer, context, dataTable);
+
+ //TODO nick - do we need this element if "columnsWidth" is absent?
+ //TODO nick - use constants from HTML class for attribute/element names
+ writer.startElement("colgroup", dataTable);
+ int columns = getColumnsCount(dataTable);
+
+ writer.writeAttribute(HTML.SPAN_ELEM, String.valueOf(columns), null);
+ String columnsWidth = (String) dataTable.getAttributes().get("columnsWidth");
+
+ if (null != columnsWidth) {
+ String[] widths = columnsWidth.split(",");
+ for (int i = 0; i < widths.length; i++) {
+ writer.startElement("col", dataTable);
+ writer.writeAttribute("width", widths[i], null);
+ writer.endElement("col");
+ }
+ }
+ writer.endElement("colgroup");
+
+ encodeHeader(writer, context, dataTable, columns);
+ encodeFooter(writer, context, dataTable, columns);
+
+ dataTable.setRowKey(context, key);
+ dataTable.restoreOrigValue(context);
+
+ }
+
+ public void encodeRows(FacesContext context, UIDataTable dataTable) throws IOException {
+
+ RowHolder holder = new RowHolder(dataTable);
+ holder.setCellClass(dataTable.getCellSkinClass());
+ holder.setRowClass(dataTable.getRowSkinClass());
+ holder.setFirstRowClass(dataTable.getFirstRowSkinClass());
+ holder.setHeaderRow(false);
+
+ encodeRows(context, dataTable, holder);
+ }
+
+ public void encodeRow(FacesContext context, RowHolder rowHolder) throws IOException {
+
+ boolean rowStart = true;
+ int processCell = 0;
+
+ Row row = rowHolder.getRow();
+ int processRow = rowHolder.getCurrentRow();
+
+ ResponseWriter writer = context.getResponseWriter();
+
+ Iterator<UIComponent> iterator = row.columns();
+ while(iterator.hasNext()) {
+
+ UIComponent child = iterator.next();
+ if(child instanceof Row) {
+
+ Row childRow = (Row)child;
+ RowHolder childRowHolder = new RowHolder(childRow);
+ childRowHolder.setCurrentRow(processRow);
+ childRowHolder.setCellElement(rowHolder.getCellElement());
+
+ if(rowHolder.isHeaderRow()) {
+ childRowHolder.setRowClass(rowHolder.getRowClass());
+ childRowHolder.setFirstRowClass(rowHolder.getFirstRowClass());
+ childRowHolder.setCellClass(rowHolder.getCellClass());
+ } else {
+ childRowHolder.setRowClass(childRow.getRowSkinClass());
+ childRowHolder.setFirstRowClass(childRow.getFirstRowSkinClass());
+ childRowHolder.setCellClass(childRow.getCellSkinClass());
+ }
+ childRowHolder.setHeaderRow(rowHolder.isHeaderRow());
+ encodeRows(context, childRow, childRowHolder);
+
+ } else if(child instanceof UIColumn) {
+
+ if(rowStart) {
+
+ if(processRow == 0) {
+ encodeFirstRowStart(writer, context, child, rowHolder);
+ } else {
+ encodeRowStart(writer, context, child, rowHolder);
+ }
+
+ rowStart = false;
+ }
+
+ encodeCellStart(writer, context, child, rowHolder);
+ encodeCellEnd(writer, context, child);
+
+ if(!iterator.hasNext()) {
+ if(processRow == 0) {
+ encodeFirstRowEnd(writer, context, child);
+ } else {
+ encodeRowEnd(writer, context, child);
+ }
+ }
+ processCell++;
+ }
+ }
+ }
+
+ @Override
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ if(!shouldProceed(component)) {
+ return;
+ }
+ UIDataTable dataTable = (UIDataTable)component;
+ encodeTableStart(writer,context, dataTable);
+ encodeTableStructure(writer, context, dataTable);
+ }
+
+ @Override
+ protected void doEncodeChildren(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+
+ if(!shouldProceed(component)) {
+ return;
+ }
+
+ UIDataTable dataTable = (UIDataTable)component;
+ encodeTableBodyStart(writer, context, dataTable);
+ encodeRows(context, dataTable);
+ encodeTableBodyEnd(writer, context, dataTable);
+
+ }
+
+ @Override
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+
+ if(!shouldProceed(component)) {
+ return;
+ }
+
+ UIDataTable dataTable = (UIDataTable)component;
+ encodeTableEnd(writer, context, dataTable);
+ }
+
+ protected boolean shouldProceed(UIComponent component) {
+ return (component instanceof UIDataTable);
+ }
+
+ @Override
+ protected Class<? extends UIComponent> getComponentClass() {
+ return UISimpleDataTable.class;
+ }
+
+ public void encodeCellEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ writer.endElement(HTML.TD_ELEM);
+ }
+
+ public void encodeCellStart(ResponseWriter writer, FacesContext context, UIComponent component, RowHolder holder) throws IOException {
+ writer.startElement(HTML.TD_ELEM, component);
+ String cellClass = holder.getCellClass();
+ encodeStyleClass(writer, context, component, HTML.STYLE_CLASS_ATTR, cellClass);
+ renderChildren(context, component);
+ }
+
+ public void encodeFirstRowEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ writer.endElement(HTML.TR_ELEMENT);
+ }
+
+ public void encodeFirstRowStart(ResponseWriter writer, FacesContext context, UIComponent component, RowHolder holder) throws IOException {
+ writer.startElement(HTML.TR_ELEMENT, component);
+ String styleClass = holder.getFirstRowClass() + " " + holder.getRowClass();
+ encodeStyleClass(writer, context, component, HTML.STYLE_CLASS_ATTR, styleClass);
+ }
+
+ public void encodeRowEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ writer.endElement(HTML.TR_ELEMENT);
+ }
+
+ public void encodeRowStart(ResponseWriter writer, FacesContext context, UIComponent component, RowHolder holder) throws IOException {
+ writer.startElement(HTML.TR_ELEMENT, component);
+ String styleClass = holder.getRowClass();
+ encodeStyleClass(writer, context, component, HTML.STYLE_CLASS_ATTR, styleClass);
+ }
+
+ public void encodeTableBodyEnd(ResponseWriter writer, FacesContext context, UIDataTable component) throws IOException {
+ writer.endElement(HTML.TABLE_ELEMENT);
+ }
+
+ public void encodeTableBodyStart(ResponseWriter writer, FacesContext context, UIDataTable component) throws IOException {
+ writer.startElement(HTML.BODY_ELEMENT, component);
+ }
+
+ public void encodeTableEnd(ResponseWriter writer, FacesContext context, UIDataTable component) throws IOException {
+ writer.endElement(HTML.BODY_ELEMENT);
+ }
+
+ public void encodeTableStart(ResponseWriter writer, FacesContext context, UIDataTable component) throws IOException {
+ writer.startElement(HTML.TABLE_ELEMENT, component);
+ String styleClass = getTableSkinClass();
+ encodeStyleClass(writer, context, component, HTML.STYLE_CLASS_ATTR, styleClass);
+ }
+
+ public void encodeCaption(ResponseWriter writer, FacesContext context, UIDataTable dataTable) throws IOException {
+
+ UIComponent caption = dataTable.getCaption();
+
+ if (caption == null) {
+ return;
+ }
+
+ if(!caption.isRendered()) {
+ return;
+ }
+
+ writer.startElement(HTML.CAPTION_ELEMENT, dataTable);
+
+ String captionClass = (String) dataTable.getAttributes().get("captionClass");
+ String captionSkinClass = getCaptionSkinClass();
+ captionClass = captionClass != null ? captionClass + " " + captionClass : captionSkinClass;
+
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, captionClass, "captionClass");
+
+ String captionStyle = (String) dataTable.getAttributes().get("captionStyle");
+
+ if (captionStyle != null && captionStyle.trim().length()!=0) {
+ writer.writeAttribute(HTML.STYLE_ATTRIBUTE, captionStyle, "captionStyle");
+ }
+
+ renderChild(context, caption);
+
+ writer.endElement(HTML.CAPTION_ELEMENT);
+ }
+
+ public void encodeFooter(ResponseWriter writer, FacesContext context, UIDataTable dataTable, int columns) throws IOException {
+
+ Iterator<UIComponent> tableColumns = dataTable.columns();
+
+ UIComponent footer = dataTable.getFooter();
+
+ boolean columnFacetPresent = isColumnFacetPresent(dataTable, "footer");
+
+ if ((footer != null && footer.isRendered()) || columnFacetPresent) {
+
+ writer.startElement(HTML.TFOOT_ELEMENT, dataTable);
+ String footerClass = (String) dataTable.getAttributes().get("footerClass");
+
+ if (columnFacetPresent) {
+ writer.startElement(HTML.TR_ELEMENT, dataTable);
+
+ encodeStyleClass(writer, context, dataTable, "footerClass", "rich-table-subfooter");
+ //TODO nick - use "th" instead of "td"?
+ //TODO nick - rename method "encodeHeaderFacets"
+ encodeHeaderFacets(context, writer, tableColumns, "rich-table-subfootercell",
+ footerClass, "footer", HTML.TD_ELEM, columns);
+ writer.endElement("tr");
+ }
+
+
+ if (footer != null && footer.isRendered()) {
+ //TODO nick - use "th" instead of "td"?
+ //TODO nick - rename method "encodeTableHeaderFacet"
+ encodeTableHeaderFacet(context, columns, writer, footer,
+ "rich-table-footer",
+ "rich-table-footer-continue",
+ "rich-table-footercell",
+ footerClass, HTML.TH_ELEM);
+ }
+
+ writer.endElement(HTML.TFOOT_ELEMENT);
+ }
+ }
+
+ public void encodeHeader(ResponseWriter writer, FacesContext context, UIDataTable dataTable, int columns) throws IOException {
+
+ UIComponent header = dataTable.getHeader();
+ boolean isEncodeHeaders = isEncodeHeaders(dataTable);
+
+ if ((header != null && header.isRendered()) || isEncodeHeaders) {
+
+ writer.startElement(HTML.THEAD_ELEMENT, dataTable);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-table-thead", null);
+
+ String headerClass = (String) dataTable.getAttributes().get("headerClass");
+
+ if (header != null && header.isRendered()) {
+ encodeTableHeaderFacet(context, columns, writer, header,
+ "rich-table-header",
+ //TODO nick - rename classes!!!
+ "rich-table-header-continue",
+ "rich-table-headercell",
+ headerClass, HTML.TH_ELEM);
+ }
+
+ if (isEncodeHeaders) {
+ writer.startElement(HTML.TR_ELEMENT, dataTable);
+ encodeStyleClass(writer, context, dataTable, "headerClass", "rich-table-subheader");
+ encodeHeaderFacets(context, writer, dataTable.columns(), "rich-table-subheadercell", headerClass, "header", HTML.TH_ELEM, columns);
+ writer.endElement(HTML.TR_ELEMENT);
+ }
+
+ writer.endElement("thead");
+ }
+ }
+
+ protected void encodeTableHeaderFacet(FacesContext context, int columns, ResponseWriter writer, UIComponent footer,
+ String skinFirstRowClass, String skinRowClass, String skinCellClass, String footerClass, String element)
+ throws IOException {
+
+ if(footer instanceof Row) {
+ Row row = (Row)footer;
+
+ RowHolder holder = new RowHolder(row);
+ holder.setCellElement(element);
+ holder.setFirstRowClass(skinFirstRowClass);
+ holder.setRowClass(skinRowClass);
+ holder.setCellClass(skinCellClass);
+ holder.resetCurrentRow();
+ holder.setHeaderRow(true);
+
+ encodeRows(context, row, holder);
+ } else {
+ writer.startElement(HTML.TR_ELEMENT, footer);
+
+ String rowClass = skinFirstRowClass;
+ String cellClass = skinCellClass;
+ if(footerClass != null && footerClass.trim().length()!=0) {
+ rowClass = rowClass + " " + footerClass;
+ cellClass = cellClass + " " + footerClass;
+ }
+
+ encodeStyleClass(writer, context, footer, null, rowClass);
+
+ writer.startElement(element, footer);
+
+ encodeStyleClass(writer, context, footer, null, cellClass);
+
+ if(columns > 0) {
+ writer.writeAttribute("colspan", String.valueOf(columns), null);
+ }
+ writer.writeAttribute("scope", "colgroup", null);
+
+ renderChild(context, footer);
+
+ writer.endElement(element);
+ writer.endElement("tr");
+ }
+ }
+
+ protected void encodeHeaderFacets(FacesContext context, ResponseWriter writer, Iterator<UIComponent> headers,
+ String skinCellClass, String headerClass, String facetName, String element, int colCount) throws IOException {
+
+ int tColCount = 0;
+
+ while (headers.hasNext()) {
+ UIComponent column = headers.next();
+ if (!column.isRendered()) {
+ continue;
+ }
+
+ Integer colspan = (Integer) column.getAttributes().get("colspan");
+ if (colspan != null && colspan.intValue() > 0) {
+ tColCount += colspan.intValue();
+ } else {
+ tColCount++;
+ }
+
+ if (tColCount > colCount) {
+ break;
+ }
+
+ String classAttribute = facetName + "Class";
+ String columnHeaderClass = (String) column.getAttributes().get(classAttribute);
+
+ String styleClass = skinCellClass;
+ if(headerClass != null && headerClass.trim().length() != 0) {
+ styleClass = styleClass + " " + headerClass;
+ }
+
+ if(columnHeaderClass != null && columnHeaderClass.trim().length() != 0) {
+ styleClass = styleClass + " " + columnHeaderClass;
+ }
+
+
+ writer.startElement(element, column);
+
+ encodeStyleClass(writer, context, column, null, styleClass);
+
+ writer.writeAttribute("scope", "col", null);
+ getUtils().encodeAttribute(context, column, "colspan");
+
+ UIComponent facet = column.getFacet(facetName);
+ if (facet != null && facet.isRendered()) {
+ renderChild(context, facet);
+ }
+
+ writer.endElement(element);
+ }
+ }
+
+
+ protected void encodeStyleClass(ResponseWriter writer, FacesContext context, UIComponent component , String styleClassAttribute, String styleClass) throws IOException {
+ boolean isEmpty = isEmpty(component, styleClassAttribute);
+ if( isEmpty && !(styleClass != null && styleClass.trim().length() != 0)) {
+ return;
+ }
+
+ String componentStyleClass = isEmpty ? styleClass : styleClass + " " + component.getAttributes().get(styleClassAttribute);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, componentStyleClass, null);
+ }
+
+ protected boolean isEmpty(UIComponent component, String attribute) {
+ if(attribute == null) {
+ return true;
+ }
+ String value = (String) component.getAttributes().get(attribute);
+ return !(value != null && value.trim().length()!=0);
+ }
+
+ protected void encodeStyle(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ String style = (String)component.getAttributes().get(HTML.STYLE_ATTRIBUTE);
+ if(!isEmptyStyle(style)) {
+ writer.writeAttribute(HTML.STYLE_ATTRIBUTE, style, null);
+ }
+ }
+
+ protected boolean isEmptyStyle(String style) {
+ return !((style != null) && (style.trim().length()!=0));
+ }
+
+ protected String getTableSkinClass() {
+ return "rich-table";
+ }
+
+ protected String getTableHeadSkinClass() {
+ return "rich-table-head";
+ }
+
+ protected String getCaptionSkinClass() {
+ return "rich-table-caption";
+ }
+
+}
Deleted: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleDataTableRendererBase.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleDataTableRendererBase.java 2009-11-05 01:25:23 UTC (rev 15830)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleDataTableRendererBase.java 2009-11-05 10:42:57 UTC (rev 15831)
@@ -1,347 +0,0 @@
-package org.richfaces.renderkit;
-
-import java.io.IOException;
-import java.util.Iterator;
-
-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 org.ajax4jsf.renderkit.RendererUtils.HTML;
-import org.richfaces.component.Row;
-import org.richfaces.component.UIDataTable;
-import org.richfaces.component.UISubTable;
-
-@ResourceDependencies({
- @ResourceDependency(name = "simple-datatable.js"),
- @ResourceDependency(name = "simple-table.css")
-})
-public abstract class SimpleDataTableRendererBase extends AbstractTableRenderer {
-
- public void encodeRowStart(RowEncodeEvent event) throws IOException {
- ResponseWriter writer = event.getContext().getResponseWriter();
- writer.startElement(HTML.TR_ELEMENT, event.getSource());
- }
-
- public void encodeRowEnd(RowEncodeEvent event) throws IOException {
- ResponseWriter writer = event.getContext().getResponseWriter();
- writer.endElement(HTML.TR_ELEMENT);
- }
-
- public void encodeFirstRow(RowEncodeEvent event) throws IOException {
- ResponseWriter writer = event.getContext().getResponseWriter();
- writer.startElement(HTML.TR_ELEMENT, event.getSource());
- }
-
- public void encodeCell(CellEncodeEvent event) throws IOException {
- ResponseWriter writer = event.getContext().getResponseWriter();
- FacesContext context = event.getContext();
- UIColumn column = event.getSource();
-
- writer.startElement(HTML.TD_ELEM, column);
- getUtils().encodeId(context, column);
- getCellStyleClasses(context, column);
- renderChildren(context, column);
-
- writer.endElement(HTML.TD_ELEM);
- }
-
- public void encodeHeaderCell(CellEncodeEvent event) throws IOException {
- ResponseWriter writer = event.getContext().getResponseWriter();
- FacesContext context = event.getContext();
- UIColumn column = event.getSource();
-
- writer.startElement(HTML.TH_ELEM, column);
- //TODO --- move to the separate method
- getUtils().encodeId(context, column);
- getCellStyleClasses(context, column);
- renderChildren(context, column);
- //------
- writer.endElement(HTML.TH_ELEM);
- }
-
- @Override
- public RowEncoder getRowEncoder(TableHolder holder) {
- RowEncoder encoder = new RowEncoder();
- encoder.setListener(this);
- return encoder;
- }
-
- public void encodeSubTable(FacesContext context, UISubTable subTable) throws IOException {
- encodeRows(context, subTable);
- }
-
- // ---------------------------------------------------------------------------------------
-
- public void encodeTableStructure(FacesContext context, UIDataTable table) throws IOException {
-
- Object key = table.getRowKey();
- table.captureOrigValue(context);
- table.setRowKey(context, null);
-
- encodeCaption(context, table);
-
- // Encode colgroup definition.
- ResponseWriter writer = context.getResponseWriter();
-
- //TODO nick - do we need this element if "columnsWidth" is absent?
- //TODO nick - use constants from HTML class for attribute/element names
- writer.startElement("colgroup", table);
-
- int columns = getColumnsCount(table);
-
- writer.writeAttribute("span", String.valueOf(columns), null);
- String columnsWidth = (String) table.getAttributes().get("columnsWidth");
-
- if (null != columnsWidth) {
- String[] widths = columnsWidth.split(",");
- for (int i = 0; i < widths.length; i++) {
- writer.startElement("col", table);
- writer.writeAttribute("width", widths[i], null);
- writer.endElement("col");
- }
- }
- writer.endElement("colgroup");
-
- encodeHeader(context, table, columns);
- encodeFooter(context, table, columns);
-
- table.setRowKey(context, key);
- table.restoreOrigValue(context);
- }
-
- public void encodeCaption(FacesContext context, UIDataTable table) throws IOException {
-
- UIComponent caption = table.getCaption();
- //TODO nick - check for "rendered" attribute
- if (caption == null) {
- return;
- }
-
- ResponseWriter writer = context.getResponseWriter();
- writer.startElement("caption", table);
-
- String captionClass = (String) table.getAttributes().get("captionClass");
- captionClass = captionClass != null ? "rich-table-caption " + captionClass : "rich-table-caption";
- writer.writeAttribute("class", captionClass, "captionClass");
-
- String captionStyle = (String) table.getAttributes().get("captionStyle");
- //TODO nick - check for empty string
- if (captionStyle != null) {
- writer.writeAttribute("style", captionStyle, "captionStyle");
- }
-
- renderChild(context, caption);
-
- writer.endElement("caption");
-
- }
-/*
- @Override
- public void encodeCell(FacesContext context, UIComponent component) throws IOException {
- CellEncoder cellEncode = new SimpleCellEncoder(getUtils(), getCellStyleClasses(context, component));
- cellEncode.encodeBegin(context, component);
- renderChildren(context, component);
- cellEncode.encodeEnd(context, component);
-
- }
-
- */
-
- public void encodeHeader(FacesContext context, UIDataTable table, int columns) throws IOException {
- UIComponent header = table.getHeader();
- boolean isEncodeHeaders = isEncodeHeaders(table);
-
- //TODO nick - check for "rendered" attribute
- if (header != null || isEncodeHeaders) {
-
- ResponseWriter writer = context.getResponseWriter();
- writer.startElement("thead", table);
- writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-table-thead", null);
- String headerClass = (String) table.getAttributes().get("headerClass");
-
- if (header != null) {
- encodeTableHeaderFacet(context, columns, writer, header,
- "rich-table-header",
- //TODO nick - rename classes!!!
- "rich-table-header-continue",
- "rich-table-headercell",
- headerClass, "th");
- }
-
- if (isEncodeHeaders) {
- writer.startElement("tr", table);
- encodeStyleClass(writer, null, "rich-table-subheader", null, headerClass);
- encodeHeaderFacets(context, writer, table.columns(), "rich-table-subheadercell", headerClass, "header",
- "th", columns);
- writer.endElement("tr");
- }
-
- writer.endElement("thead");
- }
- }
-
- public void encodeFooter(FacesContext context, UIDataTable table, int columns) throws IOException {
- ResponseWriter writer = context.getResponseWriter();
- Iterator<UIComponent> tableColumns = table.columns();
-
- UIComponent footer = table.getFooter();
- boolean columnFacetPresent = isColumnFacetPresent(table, "footer");
-
- if (footer != null || columnFacetPresent) {
- writer.startElement("tfoot", table);
- String footerClass = (String) table.getAttributes().get("footerClass");
-
- if (columnFacetPresent) {
- writer.startElement("tr", table);
- encodeStyleClass(writer, null, "rich-table-subfooter", null, footerClass);
- //TODO nick - use "th" instead of "td"?
- //TODO nick - rename method "encodeHeaderFacets"
- encodeHeaderFacets(context, writer, tableColumns, "rich-table-subfootercell", footerClass, "footer",
- "td", columns);
- writer.endElement("tr");
- }
-
- if (footer != null) {
- //TODO nick - use "th" instead of "td"?
- //TODO nick - rename method "encodeTableHeaderFacet"
- encodeTableHeaderFacet(context, columns, writer, footer,
- "rich-table-footer",
- "rich-table-footer-continue",
- "rich-table-footercell",
- footerClass, "td");
- }
- writer.endElement("tfoot");
- }
- }
-
- protected void encodeTableHeaderFacet(FacesContext context, int columns, ResponseWriter writer, UIComponent footer,
- String skinFirstRowClass, String skinRowClass, String skinCellClass, String footerClass, String element)
- throws IOException {
-
- boolean isColgroup = footer instanceof Row;
-
- if (!isColgroup) {
- writer.startElement("tr", footer);
- encodeStyleClass(writer, null, skinFirstRowClass, footerClass, null);
- writer.startElement(element, footer);
- encodeStyleClass(writer, null, skinCellClass, footerClass, null);
-
- if (columns > 0) {
- writer.writeAttribute("colspan", String.valueOf(columns), null);
- }
-
- writer.writeAttribute("scope", "colgroup", null);
- }
-
- if (isColgroup) {
- //TODO nick - tableHolder is null
- RowEncoder encoder = getRowEncoder(null);
- encoder.setHeader(true);
- encoder.encodeRows(context, footer);
- } else {
- renderChild(context, footer);
- }
-
- if (!isColgroup) {
- writer.endElement(element);
- writer.endElement("tr");
- }
- }
-
- protected void encodeHeaderFacets(FacesContext context, ResponseWriter writer, Iterator<UIComponent> headers,
- String skinCellClass, String headerClass, String facetName, String element, int colCount) throws IOException {
-
- int tColCount = 0;
-
- // HeaderEncodeStrategy richEncodeStrategy = new
- // RichHeaderEncodeStrategy();
- // HeaderEncodeStrategy simpleEncodeStrategy = new
- // SimpleHeaderEncodeStrategy();
-
- while (headers.hasNext()) {
- UIComponent column = headers.next();
- if (!column.isRendered()) {
- continue;
- }
-
- Integer colspan = (Integer) column.getAttributes().get("colspan");
- if (colspan != null && colspan.intValue() > 0) {
- tColCount += colspan.intValue();
- } else {
- tColCount++;
- }
-
- if (tColCount > colCount) {
- break;
- }
-
- String classAttribute = facetName + "Class";
- String columnHeaderClass = (String) column.getAttributes().get(classAttribute);
-
- writer.startElement(element, column);
- encodeStyleClass(writer, null, skinCellClass, headerClass, columnHeaderClass);
- writer.writeAttribute("scope", "col", null);
- getUtils().encodeAttribute(context, column, "colspan");
-
- UIComponent facet = column.getFacet(facetName);
- if (facet != null && facet.isRendered()) {
- renderChild(context, facet);
- }
-
- writer.endElement(element);
- }
- }
-
- @Override
- public void encodeBodyBegin(FacesContext context, UIDataTable table) throws IOException {
- String clientId = table.getClientId(context);
- ResponseWriter writer = context.getResponseWriter();
- writer.startElement("tbody", table);
- writer.writeAttribute("id", clientId + ":tb", null);
- }
-
- @Override
- public void encodeBodyEnd(FacesContext context, UIDataTable table) throws IOException {
- ResponseWriter writer = context.getResponseWriter();
- writer.endElement("tbody");
- }
-
- protected String getRowSkinClasses(boolean firstColumn) {
- String rowSkinClass = getRowSkinClass();
- if (firstColumn) {
- String firstRowSkinClass = getFirstRowSkinClass();
- if (firstRowSkinClass != null && firstRowSkinClass.length() != 0) {
- rowSkinClass = (rowSkinClass != null && rowSkinClass.trim().length() != 0)
- ? rowSkinClass + " " + firstRowSkinClass : firstRowSkinClass;
- }
- }
-
- return rowSkinClass;
- }
-
- /**
- * @return
- */
- protected String getRowSkinClass() {
- return "rich-table-row";
- }
-
- /**
- * @return
- */
- protected String getFirstRowSkinClass() {
- return "rich-table-firstrow";
- }
-
- /**
- * @return
- */
- protected String getCellSkinClass() {
- return "rich-table-cell";
- }
-
-}
Deleted: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/TableHolder.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/TableHolder.java 2009-11-05 01:25:23 UTC (rev 15830)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/TableHolder.java 2009-11-05 10:42:57 UTC (rev 15831)
@@ -1,118 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit;
-
-import java.util.Map;
-
-import org.richfaces.component.UIDataAdaptor;
-
-/**
- * Private class for keep reference to table and intermediate iteration values ( current row styles, events etc )
- * @author shura
- *
- */
-public class TableHolder {
- private UIDataAdaptor component;
- private int rowCounter;
-
- //TODO nick - not used anyhow
- private int gridRowCounter;
-
- private String[] rowClasses;
- private String[] columnsClasses;
-
- /**
- * @param table
- */
- public TableHolder(UIDataAdaptor component) {
- this.component = component;
- this.rowCounter = 0;
- this.gridRowCounter = 0;
- Map<String, Object> attributes = component.getAttributes();
- String classes = (String) attributes.get("rowClasses");
- if(null != classes){
- rowClasses=classes.split(",");
- }
- classes = (String) attributes.get("columnClasses");
- if(null != classes){
- columnsClasses=classes.split(",");
- }
- }
-
- /**
- * @return the table
- */
- public UIDataAdaptor getTable() {
- return this.component;
- }
-
- /**
- * @return the rowCounter
- */
- public int getRowCounter() {
- return this.rowCounter;
- }
-
- /**
- * Get current rendered row number, and increment to next value.
- * @return the rowCounter
- */
- public int nextRow() {
- return ++rowCounter;
- }
-
- public String getRowClass() {
- int row = rowCounter;
- return getRowClass(row);
- }
-
- //TODO nick - this seems to be removed
- public String getRowClass(int row) {
- String rowClass = null;
- if(null != rowClasses){
- rowClass = rowClasses[row%rowClasses.length];
- }
- return rowClass;
- }
-
- public String getColumnClass(int columnNumber) {
- String columnClass = null;
- if(null != columnsClasses){
- columnClass = columnsClasses[columnNumber%columnsClasses.length];
- }
- return columnClass;
- }
-
- /**
- * @return the gridRowCounter
- */
- public int getGridRowCounter() {
- return this.gridRowCounter;
- }
-
- /**
- * @param gridRowCounter the gridRowCounter to set
- */
- public void setGridRowCounter(int gridRowCounter) {
- this.gridRowCounter = gridRowCounter;
- }
-}
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/faces-config.xml
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/faces-config.xml 2009-11-05 01:25:23 UTC (rev 15830)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/faces-config.xml 2009-11-05 10:42:57 UTC (rev 15831)
@@ -30,23 +30,12 @@
<renderer>
<component-family>org.richfaces.SimpleDataTable</component-family>
<renderer-type>org.richfaces.SimpleDataTableRenderer</renderer-type>
- <renderer-class>org.richfaces.renderkit.html.SimpleDataTableRenderer</renderer-class>
+ <renderer-class>org.richfaces.renderkit.SimpleDataTableRenderer</renderer-class>
</renderer>
<renderer>
<component-family>org.richfaces.ExtendedDataTable</component-family>
<renderer-type>org.richfaces.ExtendedDataTableRenderer</renderer-type>
<renderer-class>org.richfaces.renderkit.html.ExtendedDataTableRenderer</renderer-class>
</renderer>
- <!-- renderer>
- <component-family>org.richfaces.Colgroup</component-family>
- <renderer-type>org.richfaces.ColumnGroupRenderer</renderer-type>
- <renderer-class>org.richfaces.renderkit.html.ColgroupRenderer</renderer-class>
- </renderer>
- <renderer>
- <component-family>org.richfaces.SubTable</component-family>
- <renderer-type>org.richfaces.renderkit.SubTableRenderer</renderer-type>
- <renderer-class>org.richfaces.renderkit.SubTableRenderer</renderer-class>
- </renderer -->
-
</render-kit>
</faces-config>
\ No newline at end of file
15 years, 2 months
JBoss Rich Faces SVN: r15830 - in root/cdk/trunk/plugins/generator/src: main/java/org/richfaces/cdk/templatecompiler/model and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2009-11-04 20:25:23 -0500 (Wed, 04 Nov 2009)
New Revision: 15830
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/AnyElement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Attribute.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkBodyElement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkCallElement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeImplementation.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ElementsHandler.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/LeafModelElement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelElement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelFragment.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/package-info.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java
Log:
JAXB-based template parser.
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java 2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,91 @@
+/*
+ * $Id: RendererTemplateParser.java 15789 2009-11-01 16:17:29Z Alex.Kolonitsky $
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+
+package org.richfaces.cdk.templatecompiler;
+
+import org.richfaces.cdk.CdkContext;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.ModelBuilder;
+import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.model.*;
+import org.richfaces.cdk.templatecompiler.model.Template;
+import org.richfaces.cdk.xmlconfig.JAXBBinding;
+
+import javax.xml.stream.XMLStreamException;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class RendererTemplateParser implements ModelBuilder {
+ private CdkContext context;
+ private JAXBBinding jaxbBinding;
+
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.ModelBuilder#build()
+ */
+ @Override
+ public ComponentLibrary build() throws CdkException {
+ ComponentLibrary library = new ComponentLibrary();
+
+ for (File file : getContext().getSources(StandardSources.RENDERER_TEMPLATES)) {
+ try {
+ Template template = parseTemplate(file);
+// } catch (FileNotFoundException e) {
+// throw new CdkException(e);
+// } catch (XMLStreamException e) {
+// throw new CdkException(e);
+ } finally {
+
+ }
+ }
+
+ return library;
+ }
+
+ protected Template parseTemplate(File file) throws CdkException {
+ return jaxbBinding.unmarshal(file, null, Template.class);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.ModelBuilder#init(org.richfaces.cdk.CdkContext)
+ */
+ @Override
+ public void init(CdkContext context) throws CdkException {
+ this.context = context;
+ jaxbBinding = context.getWorkerInstance(JAXBBinding.class);
+ }
+
+ public CdkContext getContext() {
+ return context;
+ }
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/AnyElement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/AnyElement.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/AnyElement.java 2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,83 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.templatecompiler.model;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.bind.annotation.XmlAnyAttribute;
+import javax.xml.namespace.QName;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class AnyElement extends ModelFragment {
+
+ private QName name;
+
+ private Map<QName,Object> attributes;
+
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the name
+ */
+ public QName getName() {
+ return this.name;
+ }
+
+
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name the name to set
+ */
+ public void setName(QName name) {
+ this.name = name;
+ }
+
+
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the attributes
+ */
+ @XmlAnyAttribute
+ public Map<QName, Object> getAttributes() {
+ return this.attributes;
+ }
+
+
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param attributes the attributes to set
+ */
+ public void setAttributes(Map<QName, Object> attributes) {
+ this.attributes = attributes;
+ }
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/AnyElement.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Attribute.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Attribute.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Attribute.java 2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,208 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.templatecompiler.model;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+@XmlType(name="uicomponent-attributeType",namespace=Template.COMPOSITE_NAMESPACE)
+public class Attribute {
+
+ @XmlAttribute(required=true)
+ private String name;
+
+ @XmlAttribute
+ private String displayName;
+
+ @XmlAttribute
+ private String shortDescription;
+
+ @XmlAttribute(name="default")
+ private String defaultValue;
+
+ @XmlAttribute(name="method-signature")
+ private String methodSignature;
+
+ @XmlAttribute
+ private String applyTo;
+
+ @XmlAttribute
+ private boolean required;
+
+ @XmlAttribute
+ private boolean preffered;
+
+ @XmlAttribute
+ private boolean expert;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the name
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the displayName
+ */
+ public String getDisplayName() {
+ return this.displayName;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param displayName the displayName to set
+ */
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the shortDescription
+ */
+ public String getShortDescription() {
+ return this.shortDescription;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param shortDescription the shortDescription to set
+ */
+ public void setShortDescription(String shortDescription) {
+ this.shortDescription = shortDescription;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the defaultValue
+ */
+ public String getDefaultValue() {
+ return this.defaultValue;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param defaultValue the defaultValue to set
+ */
+ public void setDefaultValue(String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the methodSignature
+ */
+ public String getMethodSignature() {
+ return this.methodSignature;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param methodSignature the methodSignature to set
+ */
+ public void setMethodSignature(String methodSignature) {
+ this.methodSignature = methodSignature;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the applyTo
+ */
+ public String getApplyTo() {
+ return this.applyTo;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param applyTo the applyTo to set
+ */
+ public void setApplyTo(String applyTo) {
+ this.applyTo = applyTo;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the required
+ */
+ public boolean isRequired() {
+ return this.required;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param required the required to set
+ */
+ public void setRequired(boolean required) {
+ this.required = required;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the preffered
+ */
+ public boolean isPreffered() {
+ return this.preffered;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param preffered the preffered to set
+ */
+ public void setPreffered(boolean preffered) {
+ this.preffered = preffered;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the expert
+ */
+ public boolean isExpert() {
+ return this.expert;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param expert the expert to set
+ */
+ public void setExpert(boolean expert) {
+ this.expert = expert;
+ }
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Attribute.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkBodyElement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkBodyElement.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkBodyElement.java 2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,33 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.templatecompiler.model;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class CdkBodyElement extends ModelFragment {
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkBodyElement.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkCallElement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkCallElement.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkCallElement.java 2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,60 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.templatecompiler.model;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+@XmlRootElement(name="call",namespace=Template.CDK_NAMESPACE)
+public class CdkCallElement {
+
+ private String expression;
+
+ public CdkCallElement() {
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the expression
+ */
+ @XmlAttribute
+ public String getExpression() {
+ return this.expression;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param expression the expression to set
+ */
+ public void setExpression(String expression) {
+ this.expression = expression;
+ }
+
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkCallElement.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeImplementation.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeImplementation.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeImplementation.java 2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,38 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.templatecompiler.model;
+
+
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+@XmlType(name="ImplementationType",namespace=Template.COMPOSITE_NAMESPACE)
+public class CompositeImplementation extends ModelFragment {
+
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeImplementation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java 2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,172 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.templatecompiler.model;
+
+import java.util.List;
+
+import javax.faces.render.RenderKitFactory;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+@XmlType(name="InterfaceType",namespace=Template.COMPOSITE_NAMESPACE)
+public class CompositeInterface {
+
+ private String componentType;
+
+ private String family;
+
+ private List<Attribute> attributes;
+
+ private String renderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
+
+ private String javaClass;
+
+ private String baseClass;
+
+ private String rendererType;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the componentType
+ */
+ @XmlElement(name="component-type",namespace=Template.CDK_NAMESPACE)
+ public String getComponentType() {
+ return this.componentType;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param componentType the componentType to set
+ */
+ public void setComponentType(String componentType) {
+ this.componentType = componentType;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the family
+ */
+ @XmlElement(name="family",namespace=Template.CDK_NAMESPACE)
+ public String getFamily() {
+ return this.family;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param family the family to set
+ */
+ public void setFamily(String family) {
+ this.family = family;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the attributes
+ */
+ @XmlElement(name="attribute",namespace=Template.COMPOSITE_NAMESPACE)
+ public List<Attribute> getAttributes() {
+ return this.attributes;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param attributes the attributes to set
+ */
+ public void setAttributes(List<Attribute> attributes) {
+ this.attributes = attributes;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the renderKitId
+ */
+ @XmlElement(name="render-kit",namespace=Template.CDK_NAMESPACE)
+ public String getRenderKitId() {
+ return this.renderKitId;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param renderKitId the renderKitId to set
+ */
+ public void setRenderKitId(String renderKitId) {
+ this.renderKitId = renderKitId;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the javaClass
+ */
+ @XmlElement(name="class",namespace=Template.CDK_NAMESPACE)
+ public String getJavaClass() {
+ return this.javaClass;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param javaClass the javaClass to set
+ */
+ public void setJavaClass(String javaClass) {
+ this.javaClass = javaClass;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the rendererType
+ */
+ @XmlElement(name="renderer-type",namespace=Template.CDK_NAMESPACE)
+ public String getRendererType() {
+ return this.rendererType;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param rendererType the rendererType to set
+ */
+ public void setRendererType(String rendererType) {
+ this.rendererType = rendererType;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the baseClass
+ */
+ @XmlElement(name="superclass",namespace=Template.CDK_NAMESPACE)
+ public String getBaseClass() {
+ return this.baseClass;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param baseClass the baseClass to set
+ */
+ public void setBaseClass(String baseClass) {
+ this.baseClass = baseClass;
+ }
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ElementsHandler.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ElementsHandler.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ElementsHandler.java 2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,134 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.templatecompiler.model;
+
+import javax.xml.bind.JAXB;
+import javax.xml.bind.ValidationEventHandler;
+import javax.xml.bind.annotation.DomHandler;
+import javax.xml.bind.annotation.W3CDomHandler;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class ElementsHandler implements DomHandler<ModelElement, DOMResult> {
+
+ private DocumentBuilder builder;
+
+ /**
+ * Default constructor.
+ *
+ * It is up to a JAXB provider to decide which DOM implementation
+ * to use or how that is configured.
+ */
+ public ElementsHandler() {
+ DocumentBuilderFactory docFactory = DocumentBuilderFactory
+ .newInstance();
+// Create Document Builder
+ try {
+ this.builder = docFactory.newDocumentBuilder();
+ } catch (ParserConfigurationException e) {
+ throw new IllegalArgumentException("No documentBuilderFactory");
+ };
+ }
+
+ /**
+ * Constructor that allows applications to specify which DOM implementation
+ * to be used.
+ *
+ * @param builder
+ * must not be null. JAXB uses this {@link DocumentBuilder} to create
+ * a new element.
+ */
+ public ElementsHandler(DocumentBuilder builder) {
+ if(builder==null)
+ throw new IllegalArgumentException();
+ this.builder = builder;
+ }
+
+ public DocumentBuilder getBuilder() {
+ return builder;
+ }
+
+ public void setBuilder(DocumentBuilder builder) {
+ if(builder==null)
+ throw new IllegalArgumentException();
+ this.builder = builder;
+ }
+
+ public DOMResult createUnmarshaller(ValidationEventHandler errorHandler) {
+ if(builder==null)
+ return new DOMResult();
+ else
+ return new DOMResult(builder.newDocument());
+ }
+
+ @Override
+ public ModelElement getElement(DOMResult rt) {
+ Element domElement = getDomElement(rt);
+ AnyElement element = JAXB.unmarshal(new DOMSource(domElement), AnyElement.class);
+
+ QName name = new QName(domElement.getNamespaceURI(),domElement.getLocalName());
+ element.setName(name);
+ return element;
+ }
+
+ public Element getDomElement(DOMResult r) {
+ // JAXP spec is ambiguous about what really happens in this case,
+ // so work defensively
+ Node n = r.getNode();
+ if( n instanceof Document ) {
+ return ((Document)n).getDocumentElement();
+ }
+ if( n instanceof Element )
+ return (Element)n;
+ if( n instanceof DocumentFragment )
+ return (Element)n.getChildNodes().item(0);
+
+ // if the result object contains something strange,
+ // it is not a user problem, but it is a JAXB provider's problem.
+ // That's why we throw a runtime exception.
+ throw new IllegalStateException(n.toString());
+ }
+
+ @Override
+ public Source marshal(ModelElement n, ValidationEventHandler errorHandler) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ElementsHandler.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/LeafModelElement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/LeafModelElement.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/LeafModelElement.java 2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,17 @@
+package org.richfaces.cdk.templatecompiler.model;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlMixed;
+
+public interface LeafModelElement extends ModelElement {
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.templatecompiler.model.ModelElement#getChildren()
+ */
+ @XmlAnyElement(lax=true,value=ElementsHandler.class)
+ @XmlMixed
+ public List<Object> getChildren();
+
+}
\ No newline at end of file
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/LeafModelElement.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelBase.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelBase.java 2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,54 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.templatecompiler.model;
+
+import java.util.List;
+
+import com.google.common.collect.Lists;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class ModelBase {
+
+ private List<ModelBase> children = Lists.newArrayList();
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the children
+ */
+ public List<ModelBase> getChildren() {
+ return this.children;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param children the children to set
+ */
+ public void setChildren(List<ModelBase> children) {
+ this.children = children;
+ }
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelBase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelElement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelElement.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelElement.java 2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,14 @@
+package org.richfaces.cdk.templatecompiler.model;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlMixed;
+
+import org.w3c.dom.Element;
+
+public interface ModelElement {
+
+
+
+}
\ No newline at end of file
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelElement.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelFragment.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelFragment.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelFragment.java 2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,35 @@
+package org.richfaces.cdk.templatecompiler.model;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlMixed;
+import javax.xml.bind.annotation.XmlSeeAlso;
+
+/**
+ * <p class="changed_added_4_0">All classes that are used in template bodey should be presented
+ * in the {@link XmlSeeAlso} annotation </p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+(a)XmlSeeAlso({CdkCallElement.class,CdkBodyElement.class})
+public class ModelFragment implements LeafModelElement {
+
+ private List<Object> children;
+
+
+ @XmlAnyElement(lax=true,value=ElementsHandler.class)
+ @XmlMixed
+ public List<Object> getChildren() {
+ return this.children;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param body the body to set
+ */
+ public void setChildren(List<Object> body) {
+ this.children = body;
+ }
+
+}
\ No newline at end of file
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelFragment.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java 2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,80 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.templatecompiler.model;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlSeeAlso;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+@XmlRootElement(name="root",namespace=Template.CDK_NAMESPACE)
+public class Template {
+
+
+ public static final String CDK_NAMESPACE="http://richfaces.org/cdk";
+
+ public static final String COMPOSITE_NAMESPACE="http://java.sun.com/jsf/composite";
+
+ private CompositeInterface _interface;
+
+ private CompositeImplementation _implementation;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the interface
+ */
+ @XmlElement(name="interface",namespace=COMPOSITE_NAMESPACE)
+ public CompositeInterface getInterface() {
+ return this._interface;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param interface1 the interface to set
+ */
+ public void setInterface(CompositeInterface interface1) {
+ this._interface = interface1;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the implementation
+ */
+ @XmlElement(name="implementation",namespace=COMPOSITE_NAMESPACE)
+ public CompositeImplementation getImplementation() {
+ return this._implementation;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param implementation the implementation to set
+ */
+ public void setImplementation(CompositeImplementation implementation) {
+ this._implementation = implementation;
+ }
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/package-info.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/package-info.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/package-info.java 2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,22 @@
+/**
+ * <h2>JAXB classes that wraps real model classes.</h2>
+ * <p>Some model requirements do not match JAXB plain bean model. The most important case is requirements for unique
+ * Id's like component and renderer type. the other important difference is model properties which do not map to
+ * faces-config schema but moved into <<....-extension> elements.</p>
+ *
+ */
+(a)XmlAccessorType(XmlAccessType.NONE)
+(a)javax.xml.bind.annotation.XmlSchema(namespace = Template.CDK_NAMESPACE,
+ xmlns = {(a)javax.xml.bind.annotation.XmlNs(prefix = "cdk",
+ namespaceURI = Template.CDK_NAMESPACE),
+ @javax.xml.bind.annotation.XmlNs(prefix = "cc",
+ namespaceURI = Template.COMPOSITE_NAMESPACE)})
+
+package org.richfaces.cdk.templatecompiler.model;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlSchemaTypes;
+import javax.xml.bind.annotation.XmlSchemaType;
+
+
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/package-info.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java 2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,67 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.templatecompiler.model;
+
+import static org.junit.Assert.*;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.richfaces.cdk.xmlconfig.JaxbTestBase;
+
+/**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class TemplateTest extends JaxbTestBase {
+
+ private static final String TEMPLATE_EPILOG = "</cc:implementation></cdk:root>";
+ private static final String TEMPLATE_MIDDLE = "</cc:interface><cc:implementation>";
+ public static final String TEMPLATE_PROLOG = "<cdk:root xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:cdk=\"http://richfaces.org/cdk\" xmlns:cc=\"http://java.sun.com/jsf/composite\"><cc:interface>";
+
+ @Test
+ public void testTemplate() throws Exception {
+ Template template = unmarshal(Template.class, TEMPLATE_PROLOG
+ + TEMPLATE_MIDDLE + TEMPLATE_EPILOG);
+ assertNotNull(template.getInterface());
+ assertNotNull(template.getImplementation());
+ }
+ @Test
+ public void testImpl() throws Exception {
+ Template template = unmarshal(Template.class, TEMPLATE_PROLOG
+ + TEMPLATE_MIDDLE +"<cdk:call expression=\"#{cc.clientId}\"/><table width=\"200\"><tbody><cdk:call expression=\"#{cc.fooMethod(clientId)}\"/></tbody></table>Header<div class='bar'>foo</div>"+ TEMPLATE_EPILOG);
+
+ CompositeImplementation implementation = template.getImplementation();
+ assertNotNull(implementation);
+ List<Object> children = implementation.getChildren();
+ assertNotNull(children);
+ assertEquals(4, children.size());
+ assertEquals(CdkCallElement.class, children.get(0).getClass());
+ assertEquals(AnyElement.class, children.get(1).getClass());
+ assertEquals(String.class, children.get(2).getClass());
+ }
+}
Property changes on: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 2 months
JBoss Rich Faces SVN: r15829 - in root/cdk/trunk/plugins/maven-cdk-plugin/src: main/java/org/richfaces/builder/mojo and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2009-11-04 20:07:38 -0500 (Wed, 04 Nov 2009)
New Revision: 15829
Added:
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/verify.bsh
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
Log:
JAXB-based template parser.
Added: root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/verify.bsh
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/verify.bsh (rev 0)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/verify.bsh 2009-11-05 01:07:38 UTC (rev 15829)
@@ -0,0 +1,42 @@
+import java.io.*;
+import java.util.*;
+import java.util.regex.*;
+
+try
+{
+ File generatedPackage = new File( basedir, "target/generated-sources/main/java" );
+ System.out.println( "Checking for existence of generated package directory: " + generatedPackage );
+ if ( !generatedPackage.isDirectory() )
+ {
+ System.out.println( "FAILED" );
+ return false;
+ }
+
+ File classesDirectory = new File( basedir, "target/classes" );
+
+ String[] classes = { "org/richfaces/cdk/test/UITestComponent" };
+ for ( String generatedClass : classes )
+ {
+ File generatedClassFile = new File( generatedPackage, generatedClass + ".java" );
+ System.out.println( "Checking for existence of generated Class: " + generatedClassFile );
+ if ( !generatedClassFile.isFile() )
+ {
+ System.out.println( "FAILED" );
+ return false;
+ }
+ File compiledClassFile = new File( classesDirectory, generatedClass + ".class" );
+ System.out.println( "Checking for existence of compiled Class: " + compiledClassFile );
+ if ( !compiledClassFile.isFile() )
+ {
+ System.out.println( "FAILED" );
+ return false;
+ }
+ }
+}
+catch( Throwable t )
+{
+ t.printStackTrace();
+ return false;
+}
+
+return true;
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java 2009-11-05 00:56:46 UTC (rev 15828)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java 2009-11-05 01:07:38 UTC (rev 15829)
@@ -54,6 +54,7 @@
* @author asmirnov(a)exadel.com
*
* @goal generate
+ * @requiresDependencyResolution compile
* @phase generate-sources
*/
public class GenerateMojo extends AbstractMojo {
@@ -106,7 +107,7 @@
/**
* Directory where the output Java Files will be located.
*
- * @parameter expression="${project.build.directory}/cdk-generated/main/java"
+ * @parameter expression="${project.build.directory}/generated-sources/main/java"
*/
protected File outputJavaDirectory;
@@ -114,12 +115,12 @@
* Directory where the output Java Files will be located.
*
* @parameter
- * expression="${project.build.directory}/cdk-generated/main/resources"
+ * expression="${project.build.directory}/generated-sources/main/resources"
*/
protected File outputResourcesDirectory;
/**
- * @parameter expression="${project.build.directory}/cdk-generated/test/java"
+ * @parameter expression="${project.build.directory}/generated-sources/test/java"
*/
protected File outputTestDirectory;
@@ -127,7 +128,7 @@
* Directory where the output Java Files will be located.
*
* @parameter
- * expression="${project.build.directory}/cdk-generated/test/resources"
+ * expression="${project.build.directory}/generated-sources/test/resources"
*/
protected File outputTestResourcesDirectory;
@@ -239,7 +240,7 @@
}
// Set default naming conventions if it was not configured.
- if (namingConventionsConfigured) {
+ if (!namingConventionsConfigured) {
RichFacesConventions facesConventions = new RichFacesConventions();
try {
@@ -252,7 +253,7 @@
}
// Set default model validator if it was not configured.
- if (validatorConfigured) {
+ if (!validatorConfigured) {
ValidatorImpl validatorImpl = new ValidatorImpl();
try {
15 years, 2 months
JBoss Rich Faces SVN: r15828 - in root: ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-11-04 19:56:46 -0500 (Wed, 04 Nov 2009)
New Revision: 15828
Modified:
root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces.js
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java
root/ui/trunk/components/core/src/main/java/org/richfaces/resource/PushResource.java
Log:
Fixed a4j:push functionality broken by changes in JSF spec
Modified: root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces.js
===================================================================
--- root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces.js 2009-11-05 00:47:56 UTC (rev 15827)
+++ root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces.js 2009-11-05 00:56:46 UTC (rev 15828)
@@ -254,11 +254,11 @@
};
//
- var PUSH_RESOURCE_URL = "#{resource['org.richfaces.resource.PushResource']}";
var pushTracker = {};
richfaces.startPush = function(options) {
var clientId = options.clientId;
+ var pushResourceUrl = options.pushResourceUrl;
var pushId = options.pushId;
var interval = options.interval;
var ondataavailable = options.ondataavailable;
@@ -270,7 +270,7 @@
type: "HEAD",
//TODO - encodeURIComponent; URL sessionId handling check
//TODO - add pushUri supports
- url: PUSH_RESOURCE_URL + "?id=" + pushId,
+ url: pushResourceUrl + "?id=" + pushId,
dataType: "text",
complete: function(xhr) {
var isPushActive = !!pushTracker[pushId];
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java 2009-11-05 00:47:56 UTC (rev 15827)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java 2009-11-05 00:56:46 UTC (rev 15828)
@@ -42,6 +42,7 @@
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.UIPush;
import org.richfaces.component.html.HtmlPush;
+import org.richfaces.resource.PushResource;
/**
* @author shura
@@ -98,6 +99,7 @@
}
options.put("interval", new Integer(interval));
+ options.put("pushResourceUrl", new PushResource().getRequestPath());
options.put("pushId", push.getListenerId(context));
options.put("clientId", component.getClientId(context));
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/resource/PushResource.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/resource/PushResource.java 2009-11-05 00:47:56 UTC (rev 15827)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/resource/PushResource.java 2009-11-05 00:56:46 UTC (rev 15828)
@@ -40,7 +40,8 @@
//TODO make this a singleton
public class PushResource extends AbstractBaseResource {
- @Override
+
+ @Override
public boolean isCacheable(FacesContext context) {
return false;
}
15 years, 2 months
JBoss Rich Faces SVN: r15827 - in root: framework/trunk/impl/src/main/java/org/ajax4jsf/context and 6 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-11-04 19:47:56 -0500 (Wed, 04 Nov 2009)
New Revision: 15827
Modified:
root/framework/trunk/api/src/main/java/org/ajax4jsf/context/AjaxContext.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
root/framework/trunk/impl/src/main/java/org/richfaces/context/ComponentCallback.java
root/framework/trunk/impl/src/main/java/org/richfaces/context/ExecuteComponentCallback.java
root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextFactoryImpl.java
root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java
root/framework/trunk/impl/src/main/java/org/richfaces/context/RenderComponentCallback.java
root/framework/trunk/impl/src/main/java/org/richfaces/resource/AnimatedTestResource.java
root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces.js
root/framework/trunk/impl/src/test/resources/javascript/4_0_0.html
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/AjaxBehaviorRenderer.java
Log:
https://jira.jboss.org/jira/browse/RF-7823
Modified: root/framework/trunk/api/src/main/java/org/ajax4jsf/context/AjaxContext.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/ajax4jsf/context/AjaxContext.java 2009-11-05 00:45:08 UTC (rev 15826)
+++ root/framework/trunk/api/src/main/java/org/ajax4jsf/context/AjaxContext.java 2009-11-05 00:47:56 UTC (rev 15827)
@@ -65,6 +65,10 @@
public abstract Object getOncomplete();
+ public abstract void setOnbeforedomupdate(Object onbeforedomupdateFunction);
+
+ public abstract Object getOnbeforedomupdate();
+
public abstract void setViewIdHolder(ViewIdHolder viewIdHolder);
public abstract ViewIdHolder getViewIdHolder();
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2009-11-05 00:45:08 UTC (rev 15826)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2009-11-05 00:47:56 UTC (rev 15827)
@@ -23,23 +23,10 @@
package org.ajax4jsf.context;
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.application.AjaxViewHandler;
-import org.ajax4jsf.renderkit.AjaxContainerRenderer;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.ajax4jsf.renderkit.RendererUtils;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
-
-import org.richfaces.log.RichfacesLogger;
-
-import org.slf4j.Logger;
-
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
-
import java.lang.reflect.Method;
-
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -60,10 +47,18 @@
import javax.faces.context.ResponseWriter;
import javax.faces.render.RenderKit;
import javax.faces.render.RenderKitFactory;
-
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.application.AjaxViewHandler;
+import org.ajax4jsf.renderkit.AjaxContainerRenderer;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.log.RichfacesLogger;
+import org.slf4j.Logger;
+
/**
* This class incapsulated
*
@@ -80,6 +75,7 @@
boolean ajaxRequest = false;
String ajaxSingleClientId = null;
Object oncomplete = null;
+ Object onbeforedomupdate = null;
boolean selfRender = false;
String submittedRegionClientId = null;
ViewIdHolder viewIdHolder = null;
@@ -589,4 +585,20 @@
public void setOncomplete(Object oncomplete) {
this.oncomplete = oncomplete;
}
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.context.AjaxContext#getOnbeforedomupdate()
+ */
+ @Override
+ public Object getOnbeforedomupdate() {
+ return onbeforedomupdate;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.context.AjaxContext#setOnbeforedomupdate(java.lang.Object)
+ */
+ @Override
+ public void setOnbeforedomupdate(Object onbeforedomupdateFunction) {
+ this.onbeforedomupdate = onbeforedomupdateFunction;
+ }
}
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2009-11-05 00:45:08 UTC (rev 15826)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2009-11-05 00:47:56 UTC (rev 15827)
@@ -23,30 +23,10 @@
package org.ajax4jsf.renderkit;
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.component.AjaxClientBehavior;
-import org.ajax4jsf.component.AjaxComponent;
-import org.ajax4jsf.component.AjaxContainer;
-import org.ajax4jsf.component.AjaxLoadBundleComponent;
-import org.ajax4jsf.component.AjaxViewRoot;
-import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.javascript.JSFunction;
-import org.ajax4jsf.javascript.JSFunctionDefinition;
-import org.ajax4jsf.javascript.JSReference;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
-import org.ajax4jsf.util.ServicesUtils;
-
-import org.richfaces.log.RichfacesLogger;
-
-import org.slf4j.Logger;
-
import java.io.IOException;
-
import java.lang.reflect.Method;
-
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Locale;
@@ -59,9 +39,23 @@
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-
import javax.servlet.http.HttpServletResponse;
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.component.AjaxClientBehavior;
+import org.ajax4jsf.component.AjaxComponent;
+import org.ajax4jsf.component.AjaxContainer;
+import org.ajax4jsf.component.AjaxLoadBundleComponent;
+import org.ajax4jsf.component.AjaxViewRoot;
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.ajax4jsf.javascript.JSReference;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.util.ServicesUtils;
+import org.richfaces.log.RichfacesLogger;
+import org.slf4j.Logger;
+
/**
* @author shura
*
@@ -87,12 +81,13 @@
public static final String AJAX_SINGLE_PARAMETER_NAME = "ajaxSingle";
public static final String ALL = "@all";
public static final String FORM = "@form";
+ public static final String THIS = "@this";
+ public static final String NONE = "@none";
/**
* Attribute to keep
*/
public static final String LIMITRENDER_ATTR_NAME = "limitRender";
- public static final String NONE = "@none";
/**
* Attribute for keep JavaScript function name for call before updating
@@ -118,11 +113,11 @@
* Attribute for keep clientId of status component
*/
public static final String STATUS_ATTR_NAME = "status";
- public static final String THIS = "@this";
public static final String VALUE_ATTR = "value";
- public static final Collection<String> NONE_SET = Collections.singleton(NONE);
- public static final Collection<String> ALL_SET = Collections.singleton(ALL);
+ public static final String AJAX_COMPONENT_ID_PARAMETER = "org.richfaces.ajax.component";
+ public static final String BEHAVIOR_EVENT_PARAMETER = "javax.faces.behavior.event";
+
private static final RendererUtils RENDERER_UTILS = RendererUtils.getInstance();
private static final Class<?> OBJECT_ARRAY_CLASS = (new Object[0]).getClass();
private static final Logger LOG = RichfacesLogger.RENDERKIT.getLogger();
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2009-11-05 00:45:08 UTC (rev 15826)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2009-11-05 00:47:56 UTC (rev 15827)
@@ -891,6 +891,25 @@
}
/**
+ * @param ids
+ * @param keyword
+ * @since 4.0
+ *
+ * @return
+ */
+ private static boolean checkKeyword(Collection<String> ids, String keyword) {
+ if (ids.contains(keyword)) {
+ if (ids.size() != 1) {
+ //TODO log
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
* @param context
* @param component
* @param shortIds
@@ -902,17 +921,23 @@
// TODO - implement
// TODO add support for @*
- Set<String> result = new LinkedHashSet<String>();
+ Set<String> result = new LinkedHashSet<String>(shortIds.size());
- for (String id : shortIds) {
- if (AjaxRendererUtils.THIS.equals(id)) {
- result.add(component.getClientId(context));
- } else if (AjaxRendererUtils.FORM.equals(id)) {
- result.add(getNestingForm(context, component).getClientId(context));
- } else {
- UIComponent foundComponent = findComponentFor(component, id);
+ if (checkKeyword(shortIds, AjaxRendererUtils.ALL)) {
+ result.add(AjaxRendererUtils.ALL);
+ } else if (checkKeyword(shortIds, AjaxRendererUtils.NONE)) {
+ //do nothing, use empty set
+ } else {
+ for (String id : shortIds) {
+ if (AjaxRendererUtils.THIS.equals(id)) {
+ result.add(component.getClientId(context));
+ } else if (AjaxRendererUtils.FORM.equals(id)) {
+ result.add(getNestingForm(context, component).getClientId(context));
+ } else {
+ UIComponent foundComponent = findComponentFor(component, id);
- result.add((foundComponent != null) ? foundComponent.getClientId(context) : id);
+ result.add((foundComponent != null) ? foundComponent.getClientId(context) : id);
+ }
}
}
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/context/ComponentCallback.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/context/ComponentCallback.java 2009-11-05 00:45:08 UTC (rev 15826)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/context/ComponentCallback.java 2009-11-05 00:47:56 UTC (rev 15827)
@@ -23,10 +23,6 @@
package org.richfaces.context;
-import org.ajax4jsf.component.AjaxClientBehavior;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.ajax4jsf.renderkit.RendererUtils;
-
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;
@@ -39,24 +35,31 @@
import javax.faces.component.visit.VisitResult;
import javax.faces.context.FacesContext;
+import org.ajax4jsf.component.AjaxClientBehavior;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils;
+
/**
* User: akolonitsky
* Date: Oct 13, 2009
*/
abstract class ComponentCallback implements VisitCallback {
- private Collection<String> componentIds = new LinkedHashSet<String>();
- private final String behaviorEvent;
- private boolean handleAll;
- private boolean handleNone;
-
- ComponentCallback(String behaviorEvent, boolean handleNone, boolean handleAll) {
+
+ private Collection<String> componentIds = new LinkedHashSet<String>();
+
+ private final String behaviorEvent;
+ private final String defaultIdAttribute;
+
+ ComponentCallback(String behaviorEvent, String defaultIdAttribute) {
super();
+
this.behaviorEvent = behaviorEvent;
- this.handleNone = handleNone;
- this.handleAll = handleAll;
+ this.defaultIdAttribute = defaultIdAttribute;
}
- protected void addDefaultComponents(Collection<String> ids) {}
+ protected String getDefaultComponentId() {
+ return null;
+ }
private AjaxClientBehavior findBehavior(UIComponent target) {
if ((behaviorEvent == null) || !(target instanceof ClientBehaviorHolder)) {
@@ -94,36 +97,18 @@
attributeObject = getBehaviorAttributeValue(behavior);
}
+ //TODO - unit tests check for "@none" element
Collection<String> attributeIds = AjaxRendererUtils.asSet(attributeObject);
-
- if ((attributeIds == null) || attributeIds.isEmpty()) {
- return;
+ if (attributeIds == null) {
+ attributeIds = new LinkedHashSet<String>();
}
-
- if (attributeIds.contains(AjaxRendererUtils.ALL)) {
- if (!AjaxRendererUtils.ALL_SET.equals(attributeIds)) {
-
- // TODO: log
- }
-
- handleAll = true;
- } else {
- handleAll = false;
-
- if (attributeIds.contains(AjaxRendererUtils.NONE)) {
- if (!AjaxRendererUtils.NONE_SET.equals(attributeIds)) {
-
- // TODO: log
- }
-
- handleNone = true;
- } else {
-
- // asSet() returns copy of original set and we're free to modify it
- addDefaultComponents(attributeIds);
- componentIds.addAll(RendererUtils.getInstance().findComponentsFor(context, target, attributeIds));
- }
+
+ if (attributeIds.isEmpty() && defaultIdAttribute != null) {
+ // asSet() returns copy of original set and we're free to modify it
+ attributeIds.add(defaultIdAttribute);
}
+
+ componentIds.addAll(RendererUtils.getInstance().findComponentsFor(context, target, attributeIds));
}
public final VisitResult visit(VisitContext visitContext, UIComponent target) {
@@ -142,11 +127,4 @@
return componentIds;
}
- public boolean isHandleAll() {
- return handleAll;
- }
-
- public boolean isHandleNone() {
- return handleNone;
- }
}
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/context/ExecuteComponentCallback.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/context/ExecuteComponentCallback.java 2009-11-05 00:45:08 UTC (rev 15826)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/context/ExecuteComponentCallback.java 2009-11-05 00:47:56 UTC (rev 15827)
@@ -19,33 +19,24 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.context;
+import javax.faces.component.UIComponent;
+
import org.ajax4jsf.component.AjaxClientBehavior;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import java.util.Collection;
-
-import javax.faces.component.UIComponent;
-
/**
* @author akolonitsky
* @since Oct 13, 2009
*/
class ExecuteComponentCallback extends ComponentCallback {
- ExecuteComponentCallback(String behaviorEvent) {
- super(behaviorEvent, false, true);
+
+ ExecuteComponentCallback(String behaviorEvent) {
+ super(behaviorEvent, AjaxRendererUtils.ALL);
}
@Override
- protected void addDefaultComponents(Collection<String> ids) {
- super.addDefaultComponents(ids);
- ids.add(AjaxRendererUtils.THIS);
- }
-
- @Override
public Object getAttributeValue(UIComponent component) {
return component.getAttributes().get("execute");
}
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextFactoryImpl.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextFactoryImpl.java 2009-11-05 00:45:08 UTC (rev 15826)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextFactoryImpl.java 2009-11-05 00:47:56 UTC (rev 15827)
@@ -23,16 +23,20 @@
package org.richfaces.context;
+import java.util.Map;
+
import javax.faces.context.FacesContext;
import javax.faces.context.PartialViewContext;
import javax.faces.context.PartialViewContextFactory;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+
/**
* @author Nick Belaevski
* @since 4.0
*/
public class PartialViewContextFactoryImpl extends PartialViewContextFactory {
- public static final String RICHFACES_AJAX = "RICHFACES_AJAX";
+
private PartialViewContextFactory parentFactory;
public PartialViewContextFactoryImpl(PartialViewContextFactory parentFactory) {
@@ -42,14 +46,15 @@
@Override
public PartialViewContext getPartialViewContext(final FacesContext context) {
- PartialViewContext partialViewContext = parentFactory.getPartialViewContext(context);
- String clientId = context.getExternalContext().getRequestParameterMap().get(RICHFACES_AJAX);
-
- if (clientId != null) {
- partialViewContext = new PartialViewContextImpl(partialViewContext, clientId);
+ Map<String, String> requestParameterMap = context.getExternalContext().getRequestParameterMap();
+ String activatorComponentId = requestParameterMap.get(AjaxRendererUtils.AJAX_COMPONENT_ID_PARAMETER);
+ if (activatorComponentId != null) {
+ String behaviorEvent = requestParameterMap.get(AjaxRendererUtils.BEHAVIOR_EVENT_PARAMETER);
+
+ return new PartialViewContextImpl(context, activatorComponentId, behaviorEvent);
+ } else {
+ return parentFactory.getPartialViewContext(context);
}
-
- return partialViewContext;
}
@Override
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java 2009-11-05 00:45:08 UTC (rev 15826)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java 2009-11-05 00:47:56 UTC (rev 15827)
@@ -1,220 +1,570 @@
-/**
- * License Agreement.
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
*
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ * 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.
*
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
+ * 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
+ * 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * 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.context;
+import static org.ajax4jsf.renderkit.AjaxRendererUtils.ALL;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
-package org.richfaces.context;
-
-import org.ajax4jsf.component.AjaxOutput;
-
import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.visit.VisitCallback;
import javax.faces.component.visit.VisitContext;
import javax.faces.component.visit.VisitHint;
+import javax.faces.component.visit.VisitResult;
+import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
+import javax.faces.context.PartialResponseWriter;
import javax.faces.context.PartialViewContext;
-import javax.faces.context.PartialViewContextWrapper;
+import javax.faces.context.ResponseWriter;
import javax.faces.event.PhaseId;
-import java.util.*;
+import org.ajax4jsf.component.AjaxOutput;
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.javascript.ScriptUtils;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.log.RichfacesLogger;
+import org.slf4j.Logger;
/**
* @author Nick Belaevski
* @since 4.0
*/
-public class PartialViewContextImpl extends PartialViewContextWrapper {
- public static final String BEHAVIOR_EVENT_PARAMETER = "javax.faces.behavior.event";
- private String behaviorEvent = null;
- private boolean hasProcessedExecute = false;
- private boolean executeAll = true;
- private final String activatorId;
- private final PartialViewContext wrappedContext;
+public class PartialViewContextImpl extends PartialViewContext {
- public PartialViewContextImpl(PartialViewContext wrappedContext, String activatorId) {
- super();
- this.wrappedContext = wrappedContext;
- this.activatorId = activatorId;
- }
+ private static final Logger LOG = RichfacesLogger.CONTEXT.getLogger();
+
+ private static final String FACES_REQUEST_HEADER = "Faces-Request";
+ private static final String PARTIAL_AJAX = "partial/ajax";
+ private static final String PARTIAL_PROCESS = "partial/process";
+
+ private final static String EXTENSION_ID = "richfaces.extensions";
+
+ private static final String BEFOREDOMUPDATE_ELEMENT_NAME = "beforedomupdate";
+ private static final String COMPLETE_ELEMENT_NAME = "complete";
+ private static final String DATA_ELEMENT_NAME = "data";
+
+ private static final String ORIGINAL_WRITER = "org.richfaces.PartialViewContextImpl.ORIGINAL_WRITER";
+
+ private FacesContext facesContext;
+ private PartialResponseWriter partialResponseWriter;
- @Override
- public PartialViewContext getWrapped() {
- return wrappedContext;
- }
+ private Set<String> executeIds = null;
+ private Set<String> renderIds = null;
+
+ private Boolean ajaxRequest = null;
+ private Boolean partialRequest = null;
+ private Boolean renderAll = null;
- private VisitContext createVisitContext(FacesContext facesContext) {
- return VisitContext.createVisitContext(facesContext, Collections.singleton(activatorId),
- Collections.singleton(VisitHint.SKIP_UNRENDERED));
- }
+ private String activatorComponentId = null;
+ private String behaviorEvent = null;
+
+ private boolean released = false;
- // TODO: data table support
- private static Collection<String> getAjaxOutputComponentIds(FacesContext facesContext) {
- List<String> ids = new ArrayList<String>();
- Collection<AjaxOutput> ajaxOutputComponentsSet =
- PartialViewContextAjaxOutputTracker.getAjaxOutputComponentsSet(facesContext);
+ public PartialViewContextImpl(FacesContext facesContext, String activatorComponentId, String behaviorEvent) {
+ super();
+
+ this.facesContext = facesContext;
+
+ //activatorComponentId should not be null
+ this.activatorComponentId = activatorComponentId;
+ this.behaviorEvent = behaviorEvent;
+ }
+
+ @Override
+ public Collection<String> getExecuteIds() {
+ assertNotReleased();
- for (AjaxOutput ajaxOutput : ajaxOutputComponentsSet) {
- if (ajaxOutput.isAjaxRendered()) {
- UIComponent ajaxOutputComponent = (UIComponent) ajaxOutput;
+ if (executeIds == null) {
+ executeIds = new LinkedHashSet<String>();
+
+ setupExecuteIds(executeIds);
+ }
- ids.add(ajaxOutputComponent.getClientId(facesContext));
- }
- }
+ return executeIds;
+ }
- return ids;
- }
+ @Override
+ public Collection<String> getRenderIds() {
+ assertNotReleased();
- private void decodeBehaviorEvent(FacesContext context) {
- Map<String, String> requestParameterMap = context.getExternalContext().getRequestParameterMap();
+ if (renderIds == null) {
+ renderIds = new LinkedHashSet<String>();
+ }
- this.behaviorEvent = requestParameterMap.get(BEHAVIOR_EVENT_PARAMETER);
- }
+ return renderIds;
+ }
- private void processExecute(PartialViewContext partialViewContext) {
- if (hasProcessedExecute) {
- return;
- }
+ @Override
+ public boolean isAjaxRequest() {
+ assertNotReleased();
- hasProcessedExecute = true;
+ if (ajaxRequest == null) {
+ Map<String, String> requestHeaderMap = facesContext.getExternalContext().getRequestHeaderMap();
+ ajaxRequest = PARTIAL_AJAX.equals(requestHeaderMap.get(FACES_REQUEST_HEADER));
+ }
+
+ return ajaxRequest.booleanValue();
+ }
- FacesContext facesContext = FacesContext.getCurrentInstance();
+ @Override
+ public boolean isPartialRequest() {
+ assertNotReleased();
- decodeBehaviorEvent(facesContext);
+ if (partialRequest == null) {
+ if (isAjaxRequest()) {
+ partialRequest = true;
+ } else {
+ Map<String, String> requestHeaderMap = facesContext.getExternalContext().getRequestHeaderMap();
+ partialRequest = PARTIAL_PROCESS.equals(requestHeaderMap.get(FACES_REQUEST_HEADER));
+ }
+ }
+
+ return partialRequest.booleanValue();
+ }
- ComponentCallback executeCallback = new ExecuteComponentCallback(behaviorEvent);
- boolean visitResult = facesContext.getViewRoot().visitTree(createVisitContext(facesContext), executeCallback);
+ @Override
+ public void setPartialRequest(boolean isPartialRequest) {
+ assertNotReleased();
- if (!visitResult) {
+ partialRequest = isPartialRequest;
+ }
- // TODO:
- }
- executeAll = executeCallback.isHandleAll();
+ @Override
+ public boolean isExecuteAll() {
+ assertNotReleased();
- if (executeAll) {
- return;
- }
+ return getExecuteIds().contains(ALL);
+ }
- Collection<String> executeIds = partialViewContext.getExecuteIds();
+ @Override
+ public boolean isRenderAll() {
+ assertNotReleased();
- executeIds.clear();
+ if (renderAll == null) {
+ renderAll = getRenderIds().contains(ALL);
+ }
+
+ return renderAll;
+ }
- if (!executeCallback.isHandleNone()) {
- executeIds.addAll(executeCallback.getComponentIds());
+ @Override
+ public void setRenderAll(boolean isRenderAll) {
+ assertNotReleased();
- // TODO ids from wrapped object?
- }
- }
+ renderAll = isRenderAll;
+ }
- private void processRender(PartialViewContext partialViewContext) {
- FacesContext facesContext = FacesContext.getCurrentInstance();
+ @Override
+ public PartialResponseWriter getPartialResponseWriter() {
+ assertNotReleased();
- if (partialViewContext.isRenderAll()) {
- return;
- }
+ if (partialResponseWriter == null) {
+ partialResponseWriter = new PartialDelayedInitializationResponseWriter(facesContext);
+ }
+
+ return partialResponseWriter;
+ }
- RenderComponentCallback renderCallback = new RenderComponentCallback(behaviorEvent);
- boolean visitResult = facesContext.getViewRoot().visitTree(createVisitContext(facesContext), renderCallback);
+ @Override
+ public void processPartial(PhaseId phaseId) {
+ UIViewRoot viewRoot = facesContext.getViewRoot();
- if (!visitResult) {
+ if (phaseId == PhaseId.APPLY_REQUEST_VALUES ||
+ phaseId == PhaseId.PROCESS_VALIDATIONS ||
+ phaseId == PhaseId.UPDATE_MODEL_VALUES) {
- // TODO:
- }
+ Collection<String> ids = getExecuteIds();
- boolean renderAll = renderCallback.isHandleAll();
+ // Skip this processing if "none" is specified in the render list,
+ // or there were no execute phase client ids.
+ if (ids == null || ids.isEmpty()) {
+ // RELEASE_PENDING LOG ERROR OR WARNING
+ return;
+ }
+
+ try {
+ processComponents(viewRoot, phaseId, ids, facesContext);
+ } catch (Exception e) {
+ // RELEASE_PENDING LOG EXCEPTION
+ }
- partialViewContext.setRenderAll(renderAll);
+ // If we have just finished APPLY_REQUEST_VALUES phase, install the
+ // partial response writer. We want to make sure that any content
+ // or errors generated in the other phases are written using the
+ // partial response writer.
+ //
+ if (phaseId == PhaseId.APPLY_REQUEST_VALUES) {
+ PartialResponseWriter writer = getPartialResponseWriter();
+ facesContext.setResponseWriter(writer);
+ }
+ } else if (phaseId == PhaseId.RENDER_RESPONSE) {
+ Collection<String> ids = getRenderIds();
+ setupRenderIds(ids);
+
+ try {
+ PartialResponseWriter writer = getPartialResponseWriter();
+ ResponseWriter orig = facesContext.getResponseWriter();
+ facesContext.getAttributes().put(ORIGINAL_WRITER, orig);
+ facesContext.setResponseWriter(writer);
- if (renderAll) {
- return;
- }
+ ExternalContext exContext = facesContext.getExternalContext();
+ exContext.setResponseContentType("text/xml");
+ exContext.addResponseHeader("Cache-Control", "no-cache");
+ writer.startDocument();
+ if (isRenderAll()) {
+ renderAll(facesContext, viewRoot);
+ renderState(facesContext);
+ writer.endDocument();
+ return;
+ }
+
+ // Skip this processing if "none" is specified in the render list,
+ // or there were no render phase client ids.
+ if (ids == null || ids.isEmpty()) {
+ } else {
+ processComponents(viewRoot, phaseId, ids, facesContext);
+ }
- Collection<String> renderIds = partialViewContext.getRenderIds();
+ //TODO - render extensions for renderAll?
+ renderExtensions(facesContext, viewRoot);
- renderIds.clear();
+ renderState(facesContext);
+
+ writer.endDocument();
+ } catch (IOException ex) {
+ //TODO - review?
+ this.cleanupAfterView();
+ } catch (RuntimeException ex) {
+ //TODO - review?
+ this.cleanupAfterView();
+ // Throw the exception
+ throw ex;
+ }
+ }
+ }
+
+ private void setupExecuteIds(Collection<String> ids) {
+ ExecuteComponentCallback callback = new ExecuteComponentCallback(behaviorEvent);
- if (!renderCallback.isHandleNone()) {
- renderIds.addAll(renderCallback.getComponentIds());
+ if (visitActivatorComponent(activatorComponentId, callback)) {
+ ids.addAll(callback.getComponentIds());
+
+ if (!ids.contains(ALL)) {
+ addImplicitExecuteIds(ids);
+ }
+ } else {
+ //TODO - log or exception?
+ //TODO - process default execute value
+ }
+ }
+
+ private void setupRenderIds(Collection<String> ids) {
+ if (!isRenderAll()) {
+ RenderComponentCallback callback = new RenderComponentCallback(behaviorEvent);
+
+ if (visitActivatorComponent(activatorComponentId, callback)) {
+ ids.addAll(callback.getComponentIds());
- if (!renderCallback.isLimitRender()) {
- Collection<String> ajaxOutputComponentIds = getAjaxOutputComponentIds(facesContext);
+ if (!Boolean.TRUE.equals(renderAll) && !ids.contains(ALL)) {
+ addImplicitRenderIds(ids, callback.isLimitRender());
+ }
+ } else {
+ //TODO - the same as for "execute"
+ }
+ }
+ }
+
+ // Process the components specified in the phaseClientIds list
+ private void processComponents(UIComponent component, PhaseId phaseId,
+ Collection<String> phaseClientIds, FacesContext context) throws IOException {
- renderIds.addAll(ajaxOutputComponentIds);
-
- // TODO ids from wrapped object?
- }
- }
+ // We use the tree visitor mechanism to locate the components to
+ // process. Create our (partial) VisitContext and the
+ // VisitCallback that will be invoked for each component that
+ // is visited. Note that we use the SKIP_UNRENDERED hint as we
+ // only want to visit the rendered subtree.
+ EnumSet<VisitHint> hints = EnumSet.of(VisitHint.SKIP_UNRENDERED);
+ VisitContext visitContext = VisitContext.createVisitContext(facesContext, phaseClientIds, hints);
+ PhaseAwareVisitCallback visitCallback = new PhaseAwareVisitCallback(facesContext, phaseId);
+ component.visitTree(visitContext, visitCallback);
}
- @Override
- public void processPartial(PhaseId phaseId) {
- PartialViewContext wrapped = getWrapped();
+ private void renderAll(FacesContext context, UIComponent component) throws IOException {
+ // If this is a "render all via ajax" request,
+ // make sure to wrap the entire page in a <render> elemnt
+ // with the special id of VIEW_ROOT_ID. This is how the client
+ // JavaScript knows how to replace the entire document with
+ // this response.
+ PartialResponseWriter writer = getPartialResponseWriter();
+ writer.startUpdate(PartialResponseWriter.RENDER_ALL_MARKER);
- if (PhaseId.APPLY_REQUEST_VALUES.equals(phaseId)) {
- processExecute(wrapped);
- } else if (PhaseId.RENDER_RESPONSE.equals(phaseId)) {
- processRender(wrapped);
+ Iterator<UIComponent> itr = component.getFacetsAndChildren();
+ while (itr.hasNext()) {
+ UIComponent kid = itr.next();
+ kid.encodeAll(context);
}
- wrapped.processPartial(phaseId);
+ writer.endUpdate();
}
- @Override
- public void setPartialRequest(boolean isPartialRequest) {
- getWrapped().setPartialRequest(isPartialRequest);
+ private void renderState(FacesContext context) throws IOException {
+
+ // Get the view state and write it to the response..
+ PartialResponseWriter writer = getPartialResponseWriter();
+ writer.startUpdate(PartialResponseWriter.VIEW_STATE_MARKER);
+ String state = context.getApplication().getStateManager().getViewState(context);
+ writer.write(state);
+ writer.endUpdate();
+
}
/*
- * (non-Javadoc)
- * @see javax.faces.context.PartialViewContextWrapper#getRenderIds()
- */
- @Override
- public Collection<String> getRenderIds() {
- return getWrapped().getRenderIds();
- }
+ * (non-Javadoc)
+ *
+ * @see javax.faces.context.PartialViewContext#release()
+ */
+ @Override
+ public void release() {
+ assertNotReleased();
- /*
- * (non-Javadoc)
- * @see javax.faces.context.PartialViewContextWrapper#getExecuteIds()
- */
- @Override
- public Collection<String> getExecuteIds() {
- return getWrapped().getExecuteIds();
+ released = true;
+
+ facesContext = null;
+ partialResponseWriter = null;
+
+ executeIds = null;
+ renderIds = null;
+
+ ajaxRequest = null;
+ partialRequest = null;
+ renderAll = null;
+
+ activatorComponentId = null;
+ behaviorEvent = null;
+ }
+
+ protected void addImplicitExecuteIds(Collection<String> ids) {
+ if (!ids.isEmpty()) {
+ UIViewRoot root = facesContext.getViewRoot();
+ if (root.getFacetCount() > 0) {
+ if (root.getFacet(UIViewRoot.METADATA_FACET_NAME) != null) {
+ ids.add(UIViewRoot.METADATA_FACET_NAME);
+ }
+ }
+ }
+ }
+
+ protected void addImplicitRenderIds(Collection<String> ids, boolean limitRender) {
+ if (!limitRender) {
+ // TODO: data table support
+ Collection<AjaxOutput> ajaxOutputComponentsSet =
+ PartialViewContextAjaxOutputTracker.getAjaxOutputComponentsSet(facesContext);
+
+ for (AjaxOutput ajaxOutput : ajaxOutputComponentsSet) {
+ if (ajaxOutput.isAjaxRendered()) {
+ UIComponent ajaxOutputComponent = (UIComponent) ajaxOutput;
+
+ ids.add(ajaxOutputComponent.getClientId(facesContext));
+ }
+ }
+ }
+ }
+
+ protected void renderExtensions(FacesContext context, UIComponent component) throws IOException {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(facesContext);
+ Map<String, String> attributes = Collections.singletonMap(HTML.ID_ATTRIBUTE,
+ context.getExternalContext().encodeNamespace(EXTENSION_ID));
+ PartialResponseWriter writer = getPartialResponseWriter();
+
+ writer.startExtension(attributes);
+
+ Object onbeforedomupdate = ajaxContext.getOnbeforedomupdate();
+ if (onbeforedomupdate != null) {
+ writer.startElement(BEFOREDOMUPDATE_ELEMENT_NAME, component);
+ writer.writeText(onbeforedomupdate, null);
+ writer.endElement(BEFOREDOMUPDATE_ELEMENT_NAME);
+ }
+
+ Object oncomplete = ajaxContext.getOncomplete();
+ if (oncomplete != null) {
+ writer.startElement(COMPLETE_ELEMENT_NAME, component);
+ writer.writeText(oncomplete, null);
+ writer.endElement(COMPLETE_ELEMENT_NAME);
+ }
+
+ Object responseData = ajaxContext.getResponseData();
+ if (responseData != null) {
+ writer.startElement(DATA_ELEMENT_NAME, component);
+ writer.writeText(ScriptUtils.toScript(responseData), null);
+ writer.endElement(DATA_ELEMENT_NAME);
+ }
+
+ writer.endExtension();
+ }
+
+ private void assertNotReleased() {
+ if (released) {
+ throw new IllegalStateException("PartialViewContext already released!");
+ }
+ }
+
+ private boolean visitActivatorComponent(String componentActivatorId, VisitCallback visitCallback) {
+ Set<String> idsToVisit = Collections.singleton(componentActivatorId);
+ Set<VisitHint> visitHints = EnumSet.of(VisitHint.SKIP_UNRENDERED);
+ VisitContext visitContext = VisitContext.createVisitContext(facesContext, idsToVisit, visitHints);
+
+ boolean visitResult = facesContext.getViewRoot().visitTree(visitContext, visitCallback);
+ return visitResult;
+ }
+
+ private void cleanupAfterView() {
+ ResponseWriter orig = (ResponseWriter) facesContext.getAttributes().get(ORIGINAL_WRITER);
+ assert (null != orig);
+ // move aside the PartialResponseWriter
+ facesContext.setResponseWriter(orig);
}
- /*
- * (non-Javadoc)
- * @see javax.faces.context.PartialViewContextWrapper#isExecuteAll()
- */
- @Override
- public boolean isExecuteAll() {
- processExecute(getWrapped());
+ private static class PhaseAwareVisitCallback implements VisitCallback {
- return executeAll;
+ private PhaseId curPhase;
+ private FacesContext ctx;
+
+ private PhaseAwareVisitCallback(FacesContext ctx, PhaseId curPhase) {
+ this.ctx = ctx;
+ this.curPhase = curPhase;
+ }
+
+
+ public VisitResult visit(VisitContext context, UIComponent comp) {
+ try {
+ if (curPhase == PhaseId.APPLY_REQUEST_VALUES) {
+
+ // RELEASE_PENDING handle immediate request(s)
+ // If the user requested an immediate request
+ // Make sure to set the immediate flag here.
+
+ comp.processDecodes(ctx);
+ } else if (curPhase == PhaseId.PROCESS_VALIDATIONS) {
+ comp.processValidators(ctx);
+ } else if (curPhase == PhaseId.UPDATE_MODEL_VALUES) {
+ comp.processUpdates(ctx);
+ } else if (curPhase == PhaseId.RENDER_RESPONSE) {
+
+ PartialResponseWriter writer = ctx.getPartialViewContext().getPartialResponseWriter();
+
+ writer.startUpdate(comp.getClientId(ctx));
+ try {
+ // do the default behavior...
+ comp.encodeAll(ctx);
+ }
+ catch (Exception ce) {
+ if (LOG.isErrorEnabled()) {
+ LOG.error(ce.getMessage());
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(ce.getMessage(), ce);
+ }
+ }
+ writer.endUpdate();
+ }
+ else {
+ throw new IllegalStateException("I18N: Unexpected " +
+ "PhaseId passed to " +
+ " PhaseAwareContextCallback: " +
+ curPhase.toString());
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+
+ // Once we visit a component, there is no need to visit
+ // its children, since processDecodes/Validators/Updates and
+ // encodeAll() already traverse the subtree. We return
+ // VisitResult.REJECT to supress the subtree visit.
+ return VisitResult.REJECT;
+ }
}
- /*
- * (non-Javadoc)
- * @see javax.faces.context.PartialViewContextWrapper#isRenderAll()
- */
- @Override
- public boolean isRenderAll() {
- return getWrapped().isRenderAll();
- }
+
+ private static final class PartialDelayedInitializationResponseWriter extends PartialResponseWriter {
+
+ private static final String DEFAULT_CHARACTER_ENCODING = "ISO-8859-1";
+
+ private FacesContext facesContext;
+
+ private ResponseWriter responseWriter;
+
+ /**
+ * @param writer
+ */
+ public PartialDelayedInitializationResponseWriter(FacesContext facesContext) {
+ super(null);
+ this.facesContext = facesContext;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.context.PartialResponseWriter#getWrapped()
+ */
+ @Override
+ public ResponseWriter getWrapped() {
+ if (responseWriter == null) {
+ responseWriter = createResponseWriter();
+ }
+
+ return responseWriter;
+ }
+
+ private ResponseWriter createResponseWriter() {
+ ResponseWriter newResponseWriter = null;
+ ExternalContext externalContext = facesContext.getExternalContext();
+ String characterEncoding = externalContext.getRequestCharacterEncoding();
+
+ if (characterEncoding == null) {
+ characterEncoding = DEFAULT_CHARACTER_ENCODING;
+ }
+
+ externalContext.setResponseCharacterEncoding(characterEncoding);
+
+ Writer outputWriter = null;
+ try {
+ outputWriter = facesContext.getExternalContext().getResponseOutputWriter();
+ } catch (IOException e) {
+ LOG.error("Error creating partial context response writer: " + e.getMessage(), e);
+ }
+
+ newResponseWriter = facesContext.getRenderKit().
+ createResponseWriter(outputWriter, "text/xml", characterEncoding);
+
+ return newResponseWriter;
+ }
+ }
}
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/context/RenderComponentCallback.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/context/RenderComponentCallback.java 2009-11-05 00:45:08 UTC (rev 15826)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/context/RenderComponentCallback.java 2009-11-05 00:47:56 UTC (rev 15827)
@@ -34,10 +34,11 @@
* @since Oct 13, 2009
*/
class RenderComponentCallback extends ComponentCallback {
- private boolean limitRender = false;
+
+ private boolean limitRender = false;
RenderComponentCallback(String behaviorEvent) {
- super(behaviorEvent, false, false);
+ super(behaviorEvent, null);
}
public boolean isLimitRender() {
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/resource/AnimatedTestResource.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/resource/AnimatedTestResource.java 2009-11-05 00:45:08 UTC (rev 15826)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/resource/AnimatedTestResource.java 2009-11-05 00:47:56 UTC (rev 15827)
@@ -23,17 +23,17 @@
package org.richfaces.resource;
-import org.w3c.dom.Node;
-
-import java.awt.*;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.GraphicsEnvironment;
import java.awt.color.ColorSpace;
import java.awt.image.BufferedImage;
-
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-
import java.util.Iterator;
import javax.imageio.IIOImage;
@@ -45,6 +45,8 @@
import javax.imageio.metadata.IIOMetadataNode;
import javax.imageio.stream.ImageOutputStream;
+import org.w3c.dom.Node;
+
public class AnimatedTestResource extends TestResource2 {
private static final int DELAY_TIME = 50;
private static final int FRAMES_COUNT = 10;
Modified: root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces.js
===================================================================
--- root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces.js 2009-11-05 00:45:08 UTC (rev 15826)
+++ root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces.js 2009-11-05 00:47:56 UTC (rev 15827)
@@ -396,8 +396,8 @@
parameters.execute = "@component";
parameters.render = "@component";
- if (!parameters.RICHFACES_AJAX) {
- parameters.RICHFACES_AJAX = sourceId;
+ if (!parameters["org.richfaces.ajax.component"]) {
+ parameters["org.richfaces.ajax.component"] = sourceId;
}
var eventHandlers;
Modified: root/framework/trunk/impl/src/test/resources/javascript/4_0_0.html
===================================================================
--- root/framework/trunk/impl/src/test/resources/javascript/4_0_0.html 2009-11-05 00:45:08 UTC (rev 15826)
+++ root/framework/trunk/impl/src/test/resources/javascript/4_0_0.html 2009-11-05 00:47:56 UTC (rev 15827)
@@ -150,7 +150,7 @@
'execute': '@component',
'render': '@component',
'param': 'value',
- 'RICHFACES_AJAX': 'source',
+ 'org.richfaces.ajax.component': 'source',
'source': 'source'
});
}
Modified: root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/AjaxBehaviorRenderer.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/AjaxBehaviorRenderer.java 2009-11-05 00:45:08 UTC (rev 15826)
+++ root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/AjaxBehaviorRenderer.java 2009-11-05 00:47:56 UTC (rev 15827)
@@ -18,9 +18,6 @@
import org.ajax4jsf.component.behavior.AjaxBehavior;
import org.ajax4jsf.javascript.JSFunction;
-import org.richfaces.context.PartialViewContextFactoryImpl;
-import org.richfaces.context.PartialViewContextImpl;
-
/**
* @author Anton Belevich
*
@@ -103,8 +100,8 @@
String eventName = bContext.getEventName();
AjaxEventOptions options = AjaxRendererUtils.buildEventOptions(context, parent, behavior);
- options.setParameter(PartialViewContextImpl.BEHAVIOR_EVENT_PARAMETER, eventName);
- options.setParameter(PartialViewContextFactoryImpl.RICHFACES_AJAX, parent.getClientId());
+ options.setParameter(AjaxRendererUtils.BEHAVIOR_EVENT_PARAMETER, eventName);
+ options.setParameter(AjaxRendererUtils.AJAX_COMPONENT_ID_PARAMETER, parent.getClientId());
return options;
}
15 years, 2 months
JBoss Rich Faces SVN: r15826 - root/ui/trunk/components/core/src/main/resources/META-INF.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-11-04 19:45:08 -0500 (Wed, 04 Nov 2009)
New Revision: 15826
Added:
root/ui/trunk/components/core/src/main/resources/META-INF/behaviors-handler-delegate.faces-config.xml
Removed:
root/ui/trunk/components/core/src/main/resources/META-INF/behaviors.faces-config.xml
Log:
Renamed faces-config.xml for behaviors handler
Copied: root/ui/trunk/components/core/src/main/resources/META-INF/behaviors-handler-delegate.faces-config.xml (from rev 15753, root/ui/trunk/components/core/src/main/resources/META-INF/behaviors.faces-config.xml)
===================================================================
--- root/ui/trunk/components/core/src/main/resources/META-INF/behaviors-handler-delegate.faces-config.xml (rev 0)
+++ root/ui/trunk/components/core/src/main/resources/META-INF/behaviors-handler-delegate.faces-config.xml 2009-11-05 00:45:08 UTC (rev 15826)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
+ version="2.0">
+
+ <name>richfaces</name>
+
+ <ordering>
+ <before>
+ <others />
+ </before>
+ </ordering>
+
+ <factory>
+ <tag-handler-delegate-factory>org.ajax4jsf.facelets.tag.BehaviorsTagHandlerDelegateFactoryImpl</tag-handler-delegate-factory>
+ </factory>
+
+</faces-config>
\ No newline at end of file
Deleted: root/ui/trunk/components/core/src/main/resources/META-INF/behaviors.faces-config.xml
===================================================================
--- root/ui/trunk/components/core/src/main/resources/META-INF/behaviors.faces-config.xml 2009-11-05 00:39:05 UTC (rev 15825)
+++ root/ui/trunk/components/core/src/main/resources/META-INF/behaviors.faces-config.xml 2009-11-05 00:45:08 UTC (rev 15826)
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
- version="2.0">
-
- <name>richfaces</name>
-
- <ordering>
- <before>
- <others />
- </before>
- </ordering>
-
- <factory>
- <tag-handler-delegate-factory>org.ajax4jsf.facelets.tag.BehaviorsTagHandlerDelegateFactoryImpl</tag-handler-delegate-factory>
- </factory>
-
-</faces-config>
\ No newline at end of file
15 years, 2 months
JBoss Rich Faces SVN: r15825 - root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-11-04 19:39:05 -0500 (Wed, 04 Nov 2009)
New Revision: 15825
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/ELParserTest.java
Log:
CDK unit test failure fixed
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/ELParserTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/ELParserTest.java 2009-11-04 18:10:31 UTC (rev 15824)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/ELParserTest.java 2009-11-05 00:39:05 UTC (rev 15825)
@@ -157,7 +157,7 @@
@Test
public void testString() throws Exception {
assertEquals(resolveExpression("#{'nabc'}"), "\"nabc\"");
- assertEquals(resolveExpression("#{'\tabc'}"), "\" abc\"");
+ assertEquals(resolveExpression("#{'\tabc'}"), "\"\tabc\"");
assertEquals(resolveExpression("#{'/nabc'}"), "\"/nabc\"");
}
15 years, 2 months