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/09/08 14:24:56 UTC
svn commit: r1759838 - in /myfaces/tobago/trunk:
tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIForm.java
tobago-example/tobago-example-demo/src/main/webapp/content/20-component/060-popup/popup.xhtml
Author: lofwyr
Date: Thu Sep 8 14:24:56 2016
New Revision: 1759838
URL: http://svn.apache.org/viewvc?rev=1759838&view=rev
Log:
TOBAGO-1568: Working on multi-form behavior
TOBAGO-1569: AJAX should be independent from Multi-Form concept
TOBAGO-1524: Use standard AJAX mechanism
* fix and simplification
Modified:
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIForm.java
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/060-popup/popup.xhtml
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIForm.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIForm.java?rev=1759838&r1=1759837&r2=1759838&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIForm.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIForm.java Thu Sep 8 14:24:56 2016
@@ -19,16 +19,14 @@
package org.apache.myfaces.tobago.internal.component;
+import org.apache.myfaces.tobago.util.AjaxUtils;
import org.apache.myfaces.tobago.util.ComponentUtils;
-import org.apache.myfaces.tobago.util.FacesVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.faces.component.UIComponent;
import javax.faces.component.UIForm;
import javax.faces.context.FacesContext;
-import javax.faces.event.AjaxBehaviorEvent;
-import javax.faces.event.FacesEvent;
import java.util.Iterator;
public abstract class AbstractUIForm extends UIForm {
@@ -68,17 +66,17 @@ public abstract class AbstractUIForm ext
if (LOG.isDebugEnabled()) {
LOG.debug("processValidators for form: {}", getClientId(facesContext));
}
- if (!isSubmitted()) {
- for (final AbstractUIForm subForm : ComponentUtils.findSubForms(this)) {
- subForm.processValidators(facesContext);
- }
- } else {
+ if (isSubmitted() || AjaxUtils.isAjaxRequest(facesContext)) {
// Process all facets and children of this component
final Iterator kids = getFacetsAndChildren();
while (kids.hasNext()) {
final UIComponent kid = (UIComponent) kids.next();
kid.processValidators(facesContext);
}
+ } else {
+ for (final AbstractUIForm subForm : ComponentUtils.findSubForms(this)) {
+ subForm.processValidators(facesContext);
+ }
}
}
@@ -88,53 +86,17 @@ public abstract class AbstractUIForm ext
if (LOG.isDebugEnabled()) {
LOG.debug("processUpdates for form: {}", getClientId(facesContext));
}
- if (!isSubmitted()) {
- for (final AbstractUIForm subForm : ComponentUtils.findSubForms(this)) {
- subForm.processUpdates(facesContext);
- }
- } else {
+ if (isSubmitted() || AjaxUtils.isAjaxRequest(facesContext)) {
// Process all facets and children of this component
final Iterator kids = getFacetsAndChildren();
while (kids.hasNext()) {
final UIComponent kid = (UIComponent) kids.next();
kid.processUpdates(facesContext);
}
- }
- }
-
- @Override
- public void queueEvent(final FacesEvent event) {
-
- if (event instanceof AjaxBehaviorEvent || isWrapped(event)) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("processing event={}", event);
- }
- setSubmitted(true);
} else {
- if (LOG.isDebugEnabled()) {
- LOG.debug("ignoring event={}", event);
- }
- }
- super.queueEvent(event);
- }
-
- // TBD: is it sufficient to check against the wrapper or must we analyse the wrapped?
- private boolean isWrapped(final FacesEvent event) {
- try {
- Class<?> wrapper = null;
- if (FacesVersion.isMyfaces()) {
- // XXX hack for MyFaces
- wrapper = Class.forName("javax.faces.component.UIData$FacesEventWrapper");
- } else if (FacesVersion.isMojarra()) {
- // XXX hack for Mojarra
- wrapper = Class.forName("javax.faces.component.WrapperEvent");
- } else {
- LOG.warn("Can't identify JSF implementation. Events in sheet may not work.");
+ for (final AbstractUIForm subForm : ComponentUtils.findSubForms(this)) {
+ subForm.processUpdates(facesContext);
}
- return wrapper != null && wrapper.equals(event.getClass());
- } catch (ClassNotFoundException e) {
- LOG.error("Can't find specific wrapper class.", e);
- return false;
}
}
}
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/060-popup/popup.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/060-popup/popup.xhtml?rev=1759838&r1=1759837&r2=1759838&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/060-popup/popup.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/060-popup/popup.xhtml Thu Sep 8 14:24:56 2016
@@ -59,7 +59,7 @@
<br/>The 'Cancel'-button calls the close-method in the controller and
has <code>immediate="true"</code>, so no submit is executed.</p>
- <tc:in id="in1" label="Required Field" required="true" value="#{popupController.popup1Text}"/>
+ <tc:in focus="true" id="in1" label="Required Field" required="true" value="#{popupController.popup1Text}"/>
<tc:buttons>
<tc:button id="submit1" label="Submit"/>
<tc:button id="submitClose1" label="Submit & Close" action="#{popupController.closePopup1}"/>