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 2007/12/04 19:12:56 UTC
svn commit: r601026 - in
/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago:
component/ util/
Author: bommel
Date: Tue Dec 4 10:12:50 2007
New Revision: 601026
URL: http://svn.apache.org/viewvc?rev=601026&view=rev
Log:
(TOBAGO-566) Add subForm support for ajax requests (renderedpartially)
Added:
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/TobagoCallback.java (with props)
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/util/ApplyRequestValuesCallback.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ProcessValidationsCallback.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/UpdateModelValuesCallback.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=601026&r1=601025&r2=601026&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 Dec 4 10:12:50 2007
@@ -59,6 +59,7 @@
import org.apache.myfaces.tobago.renderkit.html.StyleClasses;
import org.apache.myfaces.tobago.util.Callback;
import org.apache.myfaces.tobago.util.RangeParser;
+import org.apache.myfaces.tobago.util.TobagoCallback;
import javax.faces.FactoryFinder;
import javax.faces.application.Application;
@@ -80,6 +81,7 @@
import javax.faces.el.ValueBinding;
import javax.faces.event.ActionEvent;
import javax.faces.event.ActionListener;
+import javax.faces.event.PhaseId;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;
import javax.faces.render.RenderKit;
@@ -558,7 +560,7 @@
(org.apache.myfaces.tobago.component.UISelectItem) kid));
} else {
list.add(new SelectItem(item.getItemValue() == null ? "" : item.getItemValue(),
- item.getItemLabel(),
+ item.getItemLabel() != null ? item.getItemLabel() : item.getItemValue().toString(),
item.getItemDescription()));
}
} else if (value instanceof SelectItem) {
@@ -1195,8 +1197,6 @@
* colonCount > 1: for each extra colon after 1, go up a naming container
* (to the view root, if naming containers run out)
*
- * @param
- * @param
*/
public static UIComponent findComponent(UIComponent from, String relativeId) {
@@ -1245,9 +1245,28 @@
callback.execute(facesContext, list.get(0));
} else if (list.get(0) instanceof UIData) {
prepareOnUIData(facesContext, list, clientId, callback);
+ } else if (list.get(0) instanceof UIForm) {
+ prepareOnUIForm(facesContext, list, clientId, callback);
} else {
prepareOnUIComponent(facesContext, list, clientId, callback);
}
+ }
+
+ private static void prepareOnUIForm(FacesContext facesContext, List<UIComponent> list, String clientId, Callback callback) {
+ 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())) {
+ currentComponent.decode(facesContext);
+ }
+ }
+ UIForm uiForm = (UIForm) currentComponent;
+ facesContext.getExternalContext().getRequestMap().put(UIForm.SUBMITTED_MARKER, Boolean.valueOf(uiForm.isSubmitted()));
+ invokeOrPrepare(facesContext, list, clientId, callback);
+
}
private static void prepareOnUIComponent(FacesContext facesContext, List<UIComponent> list, String clientId,
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ApplyRequestValuesCallback.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ApplyRequestValuesCallback.java?rev=601026&r1=601025&r2=601026&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ApplyRequestValuesCallback.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ApplyRequestValuesCallback.java Tue Dec 4 10:12:50 2007
@@ -21,14 +21,20 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import javax.faces.context.FacesContext;
import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseId;
-public class ApplyRequestValuesCallback implements Callback {
+public class ApplyRequestValuesCallback implements TobagoCallback {
+ @SuppressWarnings({"UnusedDeclaration"})
private static final Log LOG = LogFactory.getLog(ApplyRequestValuesCallback.class);
public void execute(FacesContext facesContext, UIComponent component) {
component.processDecodes(facesContext);
+ }
+
+ public PhaseId getPhaseId() {
+ return PhaseId.APPLY_REQUEST_VALUES;
}
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ProcessValidationsCallback.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ProcessValidationsCallback.java?rev=601026&r1=601025&r2=601026&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ProcessValidationsCallback.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ProcessValidationsCallback.java Tue Dec 4 10:12:50 2007
@@ -18,12 +18,23 @@
*/
+import org.apache.myfaces.tobago.component.UIForm;
+import org.apache.myfaces.tobago.component.ComponentUtil;
+
import javax.faces.context.FacesContext;
import javax.faces.component.UIComponent;
public class ProcessValidationsCallback implements Callback {
public void execute(FacesContext facesContext, UIComponent component) {
+ if (facesContext.getExternalContext().getRequestMap().get(UIForm.SUBMITTED_MARKER)==null||
+ ((Boolean)facesContext.getExternalContext().getRequestMap().get(UIForm.SUBMITTED_MARKER))) {
component.processValidators(facesContext);
+ } else {
+ // if we're not the submitted form, only process subforms.
+ for (UIForm subForm : ComponentUtil.findSubForms(component)) {
+ subForm.processValidators(facesContext);
+ }
+ }
}
}
Added: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/TobagoCallback.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/TobagoCallback.java?rev=601026&view=auto
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/TobagoCallback.java (added)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/TobagoCallback.java Tue Dec 4 10:12:50 2007
@@ -0,0 +1,24 @@
+package org.apache.myfaces.tobago.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import javax.faces.event.PhaseId;
+
+public interface TobagoCallback extends Callback {
+ PhaseId getPhaseId();
+}
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/TobagoCallback.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/TobagoCallback.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/UpdateModelValuesCallback.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/UpdateModelValuesCallback.java?rev=601026&r1=601025&r2=601026&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/UpdateModelValuesCallback.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/UpdateModelValuesCallback.java Tue Dec 4 10:12:50 2007
@@ -18,12 +18,23 @@
*/
+import org.apache.myfaces.tobago.component.UIForm;
+import org.apache.myfaces.tobago.component.ComponentUtil;
+
import javax.faces.context.FacesContext;
import javax.faces.component.UIComponent;
public class UpdateModelValuesCallback implements Callback {
public void execute(FacesContext facesContext, UIComponent component) {
+ if (facesContext.getExternalContext().getRequestMap().get(UIForm.SUBMITTED_MARKER) == null ||
+ ((Boolean) facesContext.getExternalContext().getRequestMap().get(UIForm.SUBMITTED_MARKER))) {
component.processUpdates(facesContext);
+ } else {
+ // if we're not the submitted form, only process subforms.
+ for (UIForm subForm : ComponentUtil.findSubForms(component)) {
+ subForm.processUpdates(facesContext);
+ }
+ }
}
}