You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2016/11/04 11:29:59 UTC
svn commit: r1768018 - in /myfaces/tobago/trunk:
tobago-core/src/main/java/org/apache/myfaces/tobago/component/
tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/
tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/...
Author: lofwyr
Date: Fri Nov 4 11:29:59 2016
New Revision: 1768018
URL: http://svn.apache.org/viewvc?rev=1768018&view=rev
Log:
TOBAGO-1617: New tag <tc:event> to be similar to <f:ajax> and to replace <tc:command> in facets
* implement this behavior inside of UIData
Added:
myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/DecodingCommandRendererBase.java
- copied, changed from r1767888, myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/EventRenderer.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/DecodingInputRendererBase.java
- copied, changed from r1767990, myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/DecodingRendererBase.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/RowRenderer.java
Removed:
myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/DecodingRendererBase.java
Modified:
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIData.java
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/RowTagDeclaration.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandRendererBase.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/EventRenderer.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/HiddenRenderer.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/LabelLayoutRendererBase.java
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java?rev=1768018&r1=1768017&r2=1768018&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java Fri Nov 4 11:29:59 2016
@@ -61,6 +61,7 @@ public enum RendererTypes {
Panel,
Popup,
Progress,
+ Row,
Script,
Section,
SegmentLayout,
@@ -129,6 +130,7 @@ public enum RendererTypes {
public static final String PANEL = "Panel";
public static final String POPUP = "Popup";
public static final String PROGRESS = "Progress";
+ public static final String ROW = "Row";
public static final String SCRIPT = "Script";
public static final String SECTION = "Section";
public static final String SEGMENT_LAYOUT = "SegmentLayout";
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIData.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIData.java?rev=1768018&r1=1768017&r2=1768018&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIData.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIData.java Fri Nov 4 11:29:59 2016
@@ -31,6 +31,9 @@ import org.slf4j.LoggerFactory;
import javax.faces.FacesException;
import javax.faces.component.ContextCallback;
+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.model.DataModel;
import javax.swing.tree.TreeNode;
@@ -107,8 +110,9 @@ public abstract class AbstractUIData ext
* Creates the TreeDataModel which should be used.
* Override this method to use a custom model for an unsupported tree model.
* (Currently Tobago supports {@link TreeNode} out of the box.
- * @param value The reference to the data model
- * (comes from the value attribute of the {@link javax.faces.component.UIData})
+ *
+ * @param value The reference to the data model
+ * (comes from the value attribute of the {@link javax.faces.component.UIData})
* @param showRoot comes from the showRoot attribute.
*/
protected void createTreeDataModel(final Object value, final boolean showRoot) {
@@ -255,4 +259,56 @@ public abstract class AbstractUIData ext
return null;
}
}
+
+ /**
+ * This is, because we need to visit the UIRow for each row, which is not done in the base implementation.
+ */
+ @Override
+ public boolean visitTree(VisitContext context, VisitCallback callback) {
+
+ if (super.visitTree(context, callback)) {
+ return true;
+ }
+
+ // save the current row index
+ int oldRowIndex = getRowIndex();
+ // set row index to -1 to process the facets and to get the rowless clientId
+ setRowIndex(-1);
+ // push the Component to EL
+ pushComponentToEL(context.getFacesContext(), this);
+
+ try {
+ // iterate over the rows
+ int rowsToProcess = getRows();
+ // if getRows() returns 0, all rows have to be processed
+ if (rowsToProcess == 0) {
+ rowsToProcess = getRowCount();
+ }
+ int rowIndex = getFirst();
+ for (int rowsProcessed = 0; rowsProcessed < rowsToProcess; rowsProcessed++, rowIndex++) {
+ setRowIndex(rowIndex);
+ if (!isRowAvailable()) {
+ return false;
+ }
+ // visit the children of every child of the UIData that is an instance of UIColumn
+ for (int i = 0, childCount = getChildCount(); i < childCount; i++) {
+ UIComponent child = getChildren().get(i);
+ if (child instanceof AbstractUIRow) {
+ if (child.visitTree(context, callback)) {
+ return true;
+ }
+
+ }
+ }
+ }
+ } finally {
+ // pop the component from EL and restore the old row index
+ popComponentFromEL(context.getFacesContext());
+ setRowIndex(oldRowIndex);
+ }
+
+ // Return false to allow the visiting to continue
+ return false;
+ }
+
}
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/RowTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/RowTagDeclaration.java?rev=1768018&r1=1768017&r2=1768018&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/RowTagDeclaration.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/RowTagDeclaration.java Fri Nov 4 11:29:59 2016
@@ -23,6 +23,7 @@ import org.apache.myfaces.tobago.apt.ann
import org.apache.myfaces.tobago.apt.annotation.Tag;
import org.apache.myfaces.tobago.apt.annotation.UIComponentTag;
import org.apache.myfaces.tobago.component.ClientBehaviors;
+import org.apache.myfaces.tobago.component.RendererTypes;
import org.apache.myfaces.tobago.internal.taglib.declaration.HasIdBindingAndRendered;
/**
@@ -34,6 +35,7 @@ import org.apache.myfaces.tobago.interna
uiComponent = "org.apache.myfaces.tobago.component.UIRow",
uiComponentBaseClass = "org.apache.myfaces.tobago.internal.component.AbstractUIRow",
uiComponentFacesClass = "javax.faces.component.UIColumn",
+ rendererType = RendererTypes.ROW,
behaviors = {
@Behavior(
name = ClientBehaviors.CLICK,
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandRendererBase.java?rev=1768018&r1=1768017&r2=1768018&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandRendererBase.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandRendererBase.java Fri Nov 4 11:29:59 2016
@@ -48,7 +48,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-public abstract class CommandRendererBase extends EventRenderer {
+public abstract class CommandRendererBase extends DecodingCommandRendererBase {
private static final Logger LOG = LoggerFactory.getLogger(CommandRendererBase.class);
Copied: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/DecodingCommandRendererBase.java (from r1767888, myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/EventRenderer.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/DecodingCommandRendererBase.java?p2=myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/DecodingCommandRendererBase.java&p1=myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/EventRenderer.java&r1=1767888&r2=1768018&rev=1768018&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/EventRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/DecodingCommandRendererBase.java Fri Nov 4 11:29:59 2016
@@ -20,6 +20,7 @@
package org.apache.myfaces.tobago.renderkit.html.standard.standard.tag;
import org.apache.myfaces.tobago.renderkit.RendererBase;
+import org.apache.myfaces.tobago.renderkit.util.RenderUtils;
import org.apache.myfaces.tobago.util.ComponentUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -28,9 +29,9 @@ import javax.faces.component.UIComponent
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
-public class EventRenderer extends RendererBase {
+public abstract class DecodingCommandRendererBase extends RendererBase {
- private static final Logger LOG = LoggerFactory.getLogger(EventRenderer.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DecodingCommandRendererBase.class);
@Override
public void decode(final FacesContext facesContext, final UIComponent component) {
@@ -50,6 +51,9 @@ public class EventRenderer extends Rende
}
commandActivated(component);
}
+
+ RenderUtils.decodeClientBehaviors(facesContext, component);
+
}
protected void commandActivated(final UIComponent component) {
Copied: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/DecodingInputRendererBase.java (from r1767990, myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/DecodingRendererBase.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/DecodingInputRendererBase.java?p2=myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/DecodingInputRendererBase.java&p1=myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/DecodingRendererBase.java&r1=1767990&r2=1768018&rev=1768018&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/DecodingRendererBase.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/DecodingInputRendererBase.java Fri Nov 4 11:29:59 2016
@@ -36,9 +36,9 @@ import javax.faces.component.UIComponent
import javax.faces.context.FacesContext;
import java.util.Map;
-public abstract class DecodingRendererBase extends RendererBase {
+public abstract class DecodingInputRendererBase extends RendererBase {
- private static final Logger LOG = LoggerFactory.getLogger(DecodingRendererBase.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DecodingInputRendererBase.class);
@Override
public void decode(final FacesContext facesContext, final UIComponent component) {
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/EventRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/EventRenderer.java?rev=1768018&r1=1768017&r2=1768018&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/EventRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/EventRenderer.java Fri Nov 4 11:29:59 2016
@@ -19,40 +19,5 @@
package org.apache.myfaces.tobago.renderkit.html.standard.standard.tag;
-import org.apache.myfaces.tobago.renderkit.RendererBase;
-import org.apache.myfaces.tobago.util.ComponentUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.event.ActionEvent;
-
-public class EventRenderer extends RendererBase {
-
- private static final Logger LOG = LoggerFactory.getLogger(EventRenderer.class);
-
- @Override
- public void decode(final FacesContext facesContext, final UIComponent component) {
-
- if (ComponentUtils.isOutputOnly(component)) {
- return;
- }
- final String sourceId = facesContext.getExternalContext().getRequestParameterMap().get("javax.faces.source");
- final String clientId = component.getClientId(facesContext);
- if (LOG.isDebugEnabled()) {
- LOG.debug("sourceId = '" + sourceId + "'");
- LOG.debug("clientId = '" + clientId + "'");
- }
- if (clientId.equals(sourceId)) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("queueEvent = '" + clientId + "'");
- }
- commandActivated(component);
- }
- }
-
- protected void commandActivated(final UIComponent component) {
- component.queueEvent(new ActionEvent(component));
- }
+public class EventRenderer extends DecodingCommandRendererBase {
}
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/HiddenRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/HiddenRenderer.java?rev=1768018&r1=1768017&r2=1768018&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/HiddenRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/HiddenRenderer.java Fri Nov 4 11:29:59 2016
@@ -33,7 +33,7 @@ import javax.faces.component.UIComponent
import javax.faces.context.FacesContext;
import java.io.IOException;
-public class HiddenRenderer extends DecodingRendererBase {
+public class HiddenRenderer extends DecodingInputRendererBase {
@Override
public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/LabelLayoutRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/LabelLayoutRendererBase.java?rev=1768018&r1=1768017&r2=1768018&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/LabelLayoutRendererBase.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/LabelLayoutRendererBase.java Fri Nov 4 11:29:59 2016
@@ -43,7 +43,7 @@ import java.io.IOException;
* Manages the rendering of the <b>label</b> and the <b>field</b> together with different possibilities for
* the position of the label (defined by {@link org.apache.myfaces.tobago.component.Attributes#labelLayout}
*/
-public abstract class LabelLayoutRendererBase extends DecodingRendererBase {
+public abstract class LabelLayoutRendererBase extends DecodingInputRendererBase {
@Override
public void encodeBegin(final FacesContext facesContext, final UIComponent component) throws IOException {
Added: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/RowRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/RowRenderer.java?rev=1768018&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/RowRenderer.java (added)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/RowRenderer.java Fri Nov 4 11:29:59 2016
@@ -0,0 +1,4 @@
+package org.apache.myfaces.tobago.renderkit.html.standard.standard.tag;
+
+public class RowRenderer extends DecodingCommandRendererBase {
+}