Author: nbelaevski
Date: 2010-05-03 08:52:15 -0400 (Mon, 03 May 2010)
New Revision: 16869
Added:
root/framework/trunk/api/src/main/java/org/richfaces/renderkit/MetaComponentRenderer.java
Removed:
root/framework/trunk/api/src/main/java/org/richfaces/component/PartiallyEncodedComponent.java
root/framework/trunk/api/src/main/java/org/richfaces/renderkit/PartialEncodingRenderer.java
Modified:
root/ui-sandbox/trunk/components/componentcontrol/
root/ui-sandbox/trunk/components/datascroller/api/
root/ui-sandbox/trunk/components/datascroller/ui/
root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/UIDataScroller.java
root/ui-sandbox/trunk/components/tables/ui/
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIExtendedDataTable.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
Log:
https://jira.jboss.org/jira/browse/RF-7856 refactoring
Deleted:
root/framework/trunk/api/src/main/java/org/richfaces/component/PartiallyEncodedComponent.java
===================================================================
---
root/framework/trunk/api/src/main/java/org/richfaces/component/PartiallyEncodedComponent.java 2010-05-03
12:03:25 UTC (rev 16868)
+++
root/framework/trunk/api/src/main/java/org/richfaces/component/PartiallyEncodedComponent.java 2010-05-03
12:52:15 UTC (rev 16869)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.richfaces.component;
-
-import java.io.IOException;
-import java.util.Collection;
-
-import javax.faces.component.visit.VisitCallback;
-import javax.faces.component.visit.VisitContext;
-
-/**
- * @author Nick Belaevski
- *
- */
-public interface PartiallyEncodedComponent {
-
- // TODO document this method
- public void encodePartially(VisitContext context, VisitCallback callback,
- Collection<String> subComponentIdentifiers) throws IOException;
-
-}
Added:
root/framework/trunk/api/src/main/java/org/richfaces/renderkit/MetaComponentRenderer.java
===================================================================
---
root/framework/trunk/api/src/main/java/org/richfaces/renderkit/MetaComponentRenderer.java
(rev 0)
+++
root/framework/trunk/api/src/main/java/org/richfaces/renderkit/MetaComponentRenderer.java 2010-05-03
12:52:15 UTC (rev 16869)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public interface MetaComponentRenderer {
+
+ public void encodeMetaComponent(FacesContext context, UIComponent component) throws
IOException;
+
+}
Deleted:
root/framework/trunk/api/src/main/java/org/richfaces/renderkit/PartialEncodingRenderer.java
===================================================================
---
root/framework/trunk/api/src/main/java/org/richfaces/renderkit/PartialEncodingRenderer.java 2010-05-03
12:03:25 UTC (rev 16868)
+++
root/framework/trunk/api/src/main/java/org/richfaces/renderkit/PartialEncodingRenderer.java 2010-05-03
12:52:15 UTC (rev 16869)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.richfaces.renderkit;
-
-import java.io.IOException;
-import java.util.Collection;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.visit.VisitCallback;
-import javax.faces.component.visit.VisitContext;
-
-/**
- * @author Nick Belaevski
- *
- */
-public interface PartialEncodingRenderer {
-
- // TODO document this method
- public void encodePartially(UIComponent component, VisitContext context,
VisitCallback callback,
- Collection<String> subComponentIdentifiers) throws IOException;
-}
Property changes on: root/ui-sandbox/trunk/components/componentcontrol
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: root/ui-sandbox/trunk/components/datascroller/api
___________________________________________________________________
Name: svn:ignore
+ target
.classpath
.project
.settings
Property changes on: root/ui-sandbox/trunk/components/datascroller/ui
___________________________________________________________________
Name: svn:ignore
+ target
.classpath
.project
.settings
Modified:
root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/UIDataScroller.java
===================================================================
---
root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/UIDataScroller.java 2010-05-03
12:03:25 UTC (rev 16868)
+++
root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/UIDataScroller.java 2010-05-03
12:52:15 UTC (rev 16869)
@@ -136,11 +136,15 @@
facesContext.getPartialViewContext().getRenderIds().add(dataScroller.getClientId(facesContext));
}
- String dataTableId = dataTable.getClientId(facesContext);
- if (dataTable instanceof PartiallyEncodedComponent) {
- dataTableId += "@body";
+ String dataTableId = null;
+ if (dataTable instanceof MetaComponentResolver) {
+ dataTableId = ((MetaComponentResolver) dataTable).resolveClientId(facesContext,
dataTable, "body");
}
+ if (dataTableId == null) {
+ dataTableId = dataTable.getClientId(facesContext);
+ }
+
facesContext.getPartialViewContext().getRenderIds().add(dataTableId);
}
}
Property changes on: root/ui-sandbox/trunk/components/tables/ui
___________________________________________________________________
Name: svn:ignore
- target
.classpath
.project
.settings
.clover
+ target
.classpath
.project
.settings
.clover
bin
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIExtendedDataTable.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIExtendedDataTable.java 2010-05-03
12:03:25 UTC (rev 16868)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIExtendedDataTable.java 2010-05-03
12:52:15 UTC (rev 16869)
@@ -23,11 +23,12 @@
package org.richfaces.component;
import java.io.IOException;
-import java.util.Collection;
import java.util.Map;
+import javax.faces.component.UIComponent;
import javax.faces.component.visit.VisitCallback;
import javax.faces.component.visit.VisitContext;
+import javax.faces.component.visit.VisitResult;
import javax.faces.context.FacesContext;
import javax.faces.render.Renderer;
@@ -35,39 +36,92 @@
import org.ajax4jsf.model.DataVisitor;
import org.ajax4jsf.model.Range;
import org.ajax4jsf.model.RepeatState;
-import org.richfaces.renderkit.PartialEncodingRenderer;
+import org.richfaces.context.ExtendedVisitContext;
+import org.richfaces.context.ExtendedVisitContextMode;
+import org.richfaces.log.RichfacesLogger;
+import org.richfaces.renderkit.MetaComponentRenderer;
+import org.slf4j.Logger;
/**
* @author Anton Belevich
*
*/
-public class UIExtendedDataTable extends UIDataTableBase implements
PartiallyEncodedComponent{
+public class UIExtendedDataTable extends UIDataTableBase {
public static final String SCROLL = "scroll";
public static final String SUBMITTED_CLIENT_FIRST =
"submittedClientFirst";
public static final String OLD_CLIENT_FIRST = "oldClientFirst";
+ private static final Logger RENDERKIT_LOG = RichfacesLogger.RENDERKIT.getLogger();
+
+ private final class MetaComponentRenderVisitCallback implements VisitCallback {
+
+ private VisitCallback delegateCallback;
+
+ public MetaComponentRenderVisitCallback(VisitCallback delegateCallback) {
+ super();
+ this.delegateCallback = delegateCallback;
+ }
+
+ @Override
+ public VisitResult visit(VisitContext visitContext, UIComponent target) {
+ if (UIExtendedDataTable.this.equals(target)) {
+ FacesContext context = visitContext.getFacesContext();
+ if
(SCROLL.equals(context.getAttributes().get(ExtendedVisitContext.META_COMPONENT_ID))) {
+ Map<String, Object> attributes = getAttributes();
+ Integer submittedClientFirst = (Integer)
attributes.remove(SUBMITTED_CLIENT_FIRST);
+ if (submittedClientFirst != null) {
+ attributes.put(OLD_CLIENT_FIRST, getClientFirst());
+ setClientFirst(submittedClientFirst);
+ }
+
+ Renderer renderer = getRenderer(context);
+ try {
+ ((MetaComponentRenderer) renderer).encodeMetaComponent(context,
target);
+ } catch (IOException e) {
+ if (RENDERKIT_LOG.isErrorEnabled()) {
+ RENDERKIT_LOG.error(e.getMessage());
+ }
+ if (RENDERKIT_LOG.isDebugEnabled()) {
+ RENDERKIT_LOG.debug(e.getMessage(), e);
+ }
+ }
+
+ return VisitResult.REJECT;
+ }
+ }
+
+ return delegateCallback.visit(visitContext, target);
+ }
+ }
+
protected enum PropertyKeys {
clientFirst, clientRows
}
@Override
- public void encodePartially(VisitContext context, VisitCallback callback,
- Collection<String> subComponentIdentifiers)
- throws IOException {
- if (subComponentIdentifiers.contains(SCROLL)) {
- Map<String, Object> attributes = getAttributes();
- Integer submittedClientFirst = (Integer)
attributes.remove(SUBMITTED_CLIENT_FIRST);
- if (submittedClientFirst != null) {
- attributes.put(OLD_CLIENT_FIRST, getClientFirst());
- setClientFirst(submittedClientFirst);
+ protected boolean visitDataChildren(VisitContext visitContext, final VisitCallback
callback, boolean resetKeyBeforeVisit) {
+ if (visitContext instanceof ExtendedVisitContext) {
+ ExtendedVisitContext extendedVisitContext = (ExtendedVisitContext)
visitContext;
+
+ if (extendedVisitContext.getVisitMode() == ExtendedVisitContextMode.RENDER)
{
+ if (resetKeyBeforeVisit) {
+ setRowKey(visitContext.getFacesContext(), null);
+ }
+
+ VisitResult result =
extendedVisitContext.invokeMetaComponentVisitCallback(this,
+ new MetaComponentRenderVisitCallback(callback), SCROLL);
+
+ if (result != VisitResult.ACCEPT) {
+ return result == VisitResult.COMPLETE;
+ }
}
}
- Renderer renderer = getRenderer(context.getFacesContext());
- ((PartialEncodingRenderer) renderer).encodePartially(this, context, callback,
subComponentIdentifiers);
+
+ return super.visitDataChildren(visitContext, callback, resetKeyBeforeVisit);
}
-
+
/**
* Walk ( visit ) this component on all data-aware children for each row from range.
*
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2010-05-03
12:03:25 UTC (rev 16868)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2010-05-03
12:52:15 UTC (rev 16869)
@@ -42,8 +42,6 @@
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
import javax.faces.component.UIComponent;
-import javax.faces.component.visit.VisitCallback;
-import javax.faces.component.visit.VisitContext;
import javax.faces.context.FacesContext;
import javax.faces.context.PartialResponseWriter;
import javax.faces.context.ResponseWriter;
@@ -60,13 +58,14 @@
import org.richfaces.component.UIDataTableBase;
import org.richfaces.component.UIExtendedDataTable;
import org.richfaces.component.util.HtmlUtil;
+import org.richfaces.context.ExtendedVisitContext;
import org.richfaces.model.SortMode;
@ResourceDependencies({ @ResourceDependency(library = "javax.faces", name =
"jsf-uncompressed.js"),
@ResourceDependency(name = "jquery.js"), @ResourceDependency(name =
"jquery.position.js"),
@ResourceDependency(name = "richfaces.js"), @ResourceDependency(name =
"extendedDataTable.js"),
@ResourceDependency(name = "extendedDataTable.css") })
-public class ExtendedDataTableRenderer extends AbstractRowsRenderer implements
PartialEncodingRenderer {
+public class ExtendedDataTableRenderer extends AbstractRowsRenderer implements
MetaComponentRenderer {
private static enum PartName {
frozen, normal
@@ -166,10 +165,10 @@
}
@Override
- public void encodePartially(UIComponent component, VisitContext visitContext,
VisitCallback callback,
- Collection<String> subComponentIdentifiers) throws IOException {
- if (subComponentIdentifiers.size() == 1 &&
subComponentIdentifiers.contains(UIExtendedDataTable.SCROLL)) {
- FacesContext context = visitContext.getFacesContext();
+ public void encodeMetaComponent(FacesContext context, UIComponent component) throws
IOException {
+ String metaComponentId = (String)
context.getAttributes().get(ExtendedVisitContext.META_COMPONENT_ID);
+
+ if (UIExtendedDataTable.SCROLL.equals(metaComponentId)) {
final PartialResponseWriter writer =
context.getPartialViewContext().getPartialResponseWriter();
UIExtendedDataTable table = (UIExtendedDataTable) component;
int clientFirst = table.getClientFirst();
@@ -253,7 +252,7 @@
table.restoreOrigValue(context);
}
} else {
- throw new IllegalArgumentException("Incorect subComponentIdentifiers:
" + subComponentIdentifiers);
+ throw new IllegalArgumentException("Unsupported metaComponentIdentifier:
" + metaComponentId);
}
}