You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2008/03/18 18:49:05 UTC
svn commit: r638469 - in
/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component:
ComponentUtil.java Pager.java Sorter.java UILinkCommand.java UIPage.java
UIPanelBase.java UIPopup.java UIViewRoot.java
Author: bommel
Date: Tue Mar 18 10:49:01 2008
New Revision: 638469
URL: http://svn.apache.org/viewvc?rev=638469&view=rev
Log:
(TOBAGO-637) Generate Components, JSP Tags from annotations
added invokeOnComponent for tobago component
Modified:
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Pager.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Sorter.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UILinkCommand.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPage.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPanelBase.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPopup.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIViewRoot.java
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java?rev=638469&r1=638468&r2=638469&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java Tue Mar 18 10:49:01 2008
@@ -59,7 +59,7 @@
import org.apache.myfaces.tobago.renderkit.LayoutableRenderer;
import org.apache.myfaces.tobago.renderkit.LayoutRenderer;
import org.apache.myfaces.tobago.renderkit.html.StyleClasses;
-import org.apache.myfaces.tobago.util.Callback;
+import javax.faces.component.ContextCallback;
import org.apache.myfaces.tobago.util.RangeParser;
import org.apache.myfaces.tobago.util.TobagoCallback;
import org.apache.myfaces.tobago.internal.taglib.TagUtils;
@@ -1234,56 +1234,56 @@
}
public static void invokeOnComponent(FacesContext facesContext, String clientId, UIComponent component,
- Callback callback) {
+ ContextCallback contextCallback) {
List<UIComponent> list = new ArrayList<UIComponent>();
while (component != null) {
list.add(component);
component = component.getParent();
}
Collections.reverse(list);
- invokeOrPrepare(facesContext, list, clientId, callback);
+ invokeOrPrepare(facesContext, list, clientId, contextCallback);
}
private static void invokeOrPrepare(FacesContext facesContext, List<UIComponent> list, String clientId,
- Callback callback) {
+ ContextCallback contextCallback) {
if (list.size() == 1) {
- callback.execute(facesContext, list.get(0));
+ contextCallback.invokeContextCallback(facesContext, list.get(0));
} else if (list.get(0) instanceof UIData) {
- prepareOnUIData(facesContext, list, clientId, callback);
+ prepareOnUIData(facesContext, list, clientId, contextCallback);
} else if (list.get(0) instanceof UIForm) {
- prepareOnUIForm(facesContext, list, clientId, callback);
+ prepareOnUIForm(facesContext, list, clientId, contextCallback);
} else {
- prepareOnUIComponent(facesContext, list, clientId, callback);
+ prepareOnUIComponent(facesContext, list, clientId, contextCallback);
}
}
@SuppressWarnings("unchecked")
private static void prepareOnUIForm(FacesContext facesContext, List<UIComponent> list, String clientId,
- Callback callback) {
+ ContextCallback contextCallback) {
UIComponent currentComponent = list.remove(0);
if (!(currentComponent instanceof UIForm)) {
throw new IllegalStateException(currentComponent.getClass().getName());
}
// TODO is this needed?
- if (callback instanceof TobagoCallback) {
- if (PhaseId.APPLY_REQUEST_VALUES.equals(((TobagoCallback) callback).getPhaseId())) {
+ if (contextCallback instanceof TobagoCallback) {
+ if (PhaseId.APPLY_REQUEST_VALUES.equals(((TobagoCallback) contextCallback).getPhaseId())) {
currentComponent.decode(facesContext);
}
}
UIForm uiForm = (UIForm) currentComponent;
facesContext.getExternalContext().getRequestMap().put(UIForm.SUBMITTED_MARKER, uiForm.isSubmitted());
- invokeOrPrepare(facesContext, list, clientId, callback);
+ invokeOrPrepare(facesContext, list, clientId, contextCallback);
}
private static void prepareOnUIComponent(FacesContext facesContext, List<UIComponent> list, String clientId,
- Callback callback) {
+ ContextCallback contextCallback) {
list.remove(0);
- invokeOrPrepare(facesContext, list, clientId, callback);
+ invokeOrPrepare(facesContext, list, clientId, contextCallback);
}
private static void prepareOnUIData(FacesContext facesContext, List<UIComponent> list, String clientId,
- Callback callback) {
+ ContextCallback contextCallback) {
UIComponent currentComponent = list.remove(0);
if (!(currentComponent instanceof UIData)) {
throw new IllegalStateException(currentComponent.getClass().getName());
@@ -1309,7 +1309,7 @@
LOG.info("no match for \"^:\\d+:.*\"");
}
- invokeOrPrepare(facesContext, list, clientId, callback);
+ invokeOrPrepare(facesContext, list, clientId, contextCallback);
// we should reset rowIndex on UIData
uiData.setRowIndex(oldRowIndex);
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Pager.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Pager.java?rev=638469&r1=638468&r2=638469&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Pager.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Pager.java Tue Mar 18 10:49:01 2008
@@ -21,12 +21,12 @@
import org.apache.commons.logging.LogFactory;
import org.apache.myfaces.tobago.event.PageActionEvent;
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_FIRST;
+import org.apache.myfaces.tobago.compat.FacesUtils;
import javax.faces.context.FacesContext;
import javax.faces.el.EvaluationException;
import javax.faces.el.MethodBinding;
import javax.faces.el.MethodNotFoundException;
-import javax.faces.el.ValueBinding;
public class Pager extends MethodBinding {
@@ -99,9 +99,9 @@
default:
// can't happen
}
- ValueBinding valueBinding = sheet.getValueBinding(ATTR_FIRST);
- if (valueBinding != null) {
- valueBinding.setValue(facesContext, first);
+
+ if (FacesUtils.hasValueBindingOrValueExpression(sheet, ATTR_FIRST)) {
+ FacesUtils.setValueOfBindingOrExpression(facesContext, first, sheet, ATTR_FIRST);
} else {
sheet.setFirst(first);
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Sorter.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Sorter.java?rev=638469&r1=638468&r2=638469&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Sorter.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Sorter.java Tue Mar 18 10:49:01 2008
@@ -25,6 +25,7 @@
import org.apache.myfaces.tobago.model.SheetState;
import org.apache.myfaces.tobago.util.BeanComparator;
import org.apache.myfaces.tobago.util.ValueBindingComparator;
+import org.apache.myfaces.tobago.compat.FacesUtils;
import javax.faces.component.UIColumn;
import javax.faces.component.UIComponent;
@@ -84,9 +85,9 @@
ValueBinding valueBinding = child.getValueBinding("value");
String var = data.getVar();
- if (valueBinding != null) {
- if (isSimpleProperty(valueBinding.getExpressionString())) {
- String expressionString = valueBinding.getExpressionString();
+ if (FacesUtils.hasValueBindingOrValueExpression(child, "value")) {
+ String expressionString = FacesUtils.getExpressionString(child, "value");
+ if (isSimpleProperty(expressionString)) {
if (expressionString.startsWith("#{")
&& expressionString.endsWith("}")) {
expressionString =
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UILinkCommand.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UILinkCommand.java?rev=638469&r1=638468&r2=638469&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UILinkCommand.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UILinkCommand.java Tue Mar 18 10:49:01 2008
@@ -18,15 +18,19 @@
*/
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TAB_INDEX;
+import org.apache.myfaces.tobago.compat.FacesUtils;
+import org.apache.myfaces.tobago.compat.InvokeOnComponent;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
+import javax.faces.component.ContextCallback;
+import javax.faces.FacesException;
/*
* Date: Feb 17, 2007
* Time: 8:51:48 AM
*/
-public class UILinkCommand extends UICommand implements SupportsMarkup {
+public class UILinkCommand extends UICommand implements SupportsMarkup, InvokeOnComponent {
public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.LinkCommand";
@@ -75,6 +79,11 @@
public void setTabIndex(Integer tabIndex) {
this.tabIndex = tabIndex;
+ }
+
+ public boolean invokeOnComponent(FacesContext context, String clientId, ContextCallback callback)
+ throws FacesException {
+ return FacesUtils.invokeOnComponent(context, this, clientId, callback);
}
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPage.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPage.java?rev=638469&r1=638468&r2=638469&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPage.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPage.java Tue Mar 18 10:49:01 2008
@@ -31,11 +31,15 @@
import org.apache.myfaces.tobago.model.PageState;
import org.apache.myfaces.tobago.model.PageStateImpl;
import org.apache.myfaces.tobago.webapp.TobagoMultipartFormdataRequest;
+import org.apache.myfaces.tobago.compat.FacesUtils;
+import org.apache.myfaces.tobago.compat.InvokeOnComponent;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
+import javax.faces.component.ContextCallback;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
+import javax.faces.FacesException;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import java.io.IOException;
@@ -45,7 +49,7 @@
import java.util.Set;
import java.util.StringTokenizer;
-public class UIPage extends UIForm {
+public class UIPage extends UIForm implements InvokeOnComponent {
private static final Log LOG = LogFactory.getLog(UIPage.class);
@@ -443,5 +447,10 @@
values[3] = focusId;
values[4] = applicationIcon;
return values;
+ }
+
+ public boolean invokeOnComponent(FacesContext context, String clientId, ContextCallback callback)
+ throws FacesException {
+ return FacesUtils.invokeOnComponent(context, this, clientId, callback);
}
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPanelBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPanelBase.java?rev=638469&r1=638468&r2=638469&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPanelBase.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPanelBase.java Tue Mar 18 10:49:01 2008
@@ -19,8 +19,12 @@
import org.apache.myfaces.tobago.ajax.api.AjaxComponent;
import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
+import org.apache.myfaces.tobago.compat.FacesUtils;
+import org.apache.myfaces.tobago.compat.InvokeOnComponent;
import javax.faces.context.FacesContext;
+import javax.faces.component.ContextCallback;
+import javax.faces.FacesException;
import java.io.IOException;
/*
@@ -29,7 +33,7 @@
* Time: 3:05:19 PM
*/
public class UIPanelBase extends javax.faces.component.UIPanel
- implements AjaxComponent {
+ implements AjaxComponent, InvokeOnComponent {
public void encodeBegin(FacesContext facesContext) throws IOException {
// TODO change this should be renamed to DimensionUtils.prepare!!!
@@ -47,4 +51,8 @@
return AjaxUtils.encodeAjaxComponent(facesContext, this);
}
+ public boolean invokeOnComponent(FacesContext context, String clientId, ContextCallback callback)
+ throws FacesException {
+ return FacesUtils.invokeOnComponent(context, this, clientId, callback);
+ }
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPopup.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPopup.java?rev=638469&r1=638468&r2=638469&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPopup.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPopup.java Tue Mar 18 10:49:01 2008
@@ -21,6 +21,8 @@
import org.apache.commons.logging.LogFactory;
import org.apache.myfaces.tobago.ajax.api.AjaxComponent;
import org.apache.myfaces.tobago.TobagoConstants;
+import org.apache.myfaces.tobago.compat.FacesUtils;
+import org.apache.myfaces.tobago.compat.InvokeOnComponent;
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_HEIGHT;
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LEFT;
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TOP;
@@ -28,12 +30,14 @@
import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
+import javax.faces.component.ContextCallback;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
+import javax.faces.FacesException;
import java.io.IOException;
import java.util.Iterator;
-public class UIPopup extends UIPanelBase implements NamingContainer, AjaxComponent {
+public class UIPopup extends UIPanelBase implements NamingContainer, AjaxComponent, InvokeOnComponent {
private static final Log LOG = LogFactory.getLog(UIPopup.class);
@@ -251,5 +255,10 @@
int responseCode = super.encodeAjax(facesContext);
activated = false;
return responseCode;
+ }
+
+ public boolean invokeOnComponent(FacesContext context, String clientId, ContextCallback callback)
+ throws FacesException {
+ return FacesUtils.invokeOnComponent(context, this, clientId, callback);
}
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIViewRoot.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIViewRoot.java?rev=638469&r1=638468&r2=638469&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIViewRoot.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIViewRoot.java Tue Mar 18 10:49:01 2008
@@ -19,10 +19,13 @@
import org.apache.myfaces.tobago.context.ClientProperties;
import org.apache.myfaces.tobago.context.ResourceManagerImpl;
+import org.apache.myfaces.tobago.compat.FacesUtils;
+import org.apache.myfaces.tobago.compat.InvokeOnComponent;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.faces.component.UIComponent;
+import javax.faces.component.ContextCallback;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
@@ -39,7 +42,7 @@
* Date: Jun 13, 2005
* Time: 5:19:31 PM
*/
-public class UIViewRoot extends javax.faces.component.UIViewRoot {
+public class UIViewRoot extends javax.faces.component.UIViewRoot implements InvokeOnComponent {
private static final Log LOG = LogFactory.getLog(UIViewRoot.class);
@@ -207,5 +210,10 @@
if (context.getRenderResponse() || context.getResponseComplete()) {
clearEvents();
}
+ }
+
+ public boolean invokeOnComponent(FacesContext context, String clientId, ContextCallback callback)
+ throws FacesException {
+ return FacesUtils.invokeOnComponent(context, this, clientId, callback);
}
}