You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by im...@apache.org on 2008/03/29 17:43:48 UTC
svn commit: r642555 - in /myfaces/tomahawk/trunk/sandbox:
core/src/main/java/org/apache/myfaces/custom/ppr/
core/src/main/resources-facesconfig/META-INF/ core/src/main/tld/
examples/src/main/java/org/apache/myfaces/examples/ppr/
examples/src/main/webapp/
Author: imario
Date: Sat Mar 29 09:43:27 2008
New Revision: 642555
URL: http://svn.apache.org/viewvc?rev=642555&view=rev
Log:
allow to configure processComponentIds with pprSubmit to validate/update-model components in question only.
Pretty much like subForm, just that it is easier to configure and works with parts of the same form.
Added:
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/ContextCallback.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRFacesContextWrapper.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRLifecycle.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRLifecycleFactory.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRViewRootWrapper.java
myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroupProcessComponents.jsp
- copied, changed from r642510, myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroupLoadingMessage.jsp
Modified:
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPhaseListener.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRSubmit.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRSubmitRenderer.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRSubmitTag.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRSupport.java
myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml
myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld
myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/ppr/PPRExampleBean.java
myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/ContextCallback.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/ContextCallback.java?rev=642555&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/ContextCallback.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/ContextCallback.java Sat Mar 29 09:43:27 2008
@@ -0,0 +1,27 @@
+/*
+ * 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.
+*/
+package org.apache.myfaces.custom.ppr;
+
+import javax.faces.context.FacesContext;
+import javax.faces.component.UIComponent;
+
+interface ContextCallback
+{
+ void invokeContextCallback(FacesContext context, UIComponent component);
+}
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRFacesContextWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRFacesContextWrapper.java?rev=642555&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRFacesContextWrapper.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRFacesContextWrapper.java Sat Mar 29 09:43:27 2008
@@ -0,0 +1,217 @@
+/*
+ * 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.
+*/
+package org.apache.myfaces.custom.ppr;
+
+import javax.faces.application.Application;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseStream;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.RenderKit;
+import java.util.Iterator;
+
+/**
+ * Convenient class to wrap the current FacesContext.
+ * <p>
+ * A class of this name is provided in JSF1.2, but not in JSF1.1.
+ * <p>
+ * Any methods that do not actually need to be overridden are declared final
+ * in order to improve performance (helps the JVM to optimise away the call).
+ */
+class PPRFacesContextWrapper extends FacesContext
+{
+ //~ Instance fields -------------------------------------------------------
+
+ private final FacesContext _facesContext;
+ // private Method methodGetELContext = null;
+
+ public PPRFacesContextWrapper(FacesContext facesContext)
+ {
+ _facesContext = facesContext;
+ }
+
+ //~ Non-Final Methods -----------------------------------------------------
+
+ public void release()
+ {
+ _facesContext.release();
+ }
+
+ //~ Final Methods ---------------------------------------------------------
+
+ public final Application getApplication()
+ {
+ return _facesContext.getApplication();
+ }
+
+ public final Iterator getClientIdsWithMessages()
+ {
+ return _facesContext.getClientIdsWithMessages();
+ }
+
+ public final ExternalContext getExternalContext()
+ {
+ return _facesContext.getExternalContext();
+ }
+
+ public final FacesMessage.Severity getMaximumSeverity()
+ {
+ return _facesContext.getMaximumSeverity();
+ }
+
+ public final Iterator getMessages()
+ {
+ return _facesContext.getMessages();
+ }
+
+ public final Iterator getMessages(String clientId)
+ {
+ return _facesContext.getMessages(clientId);
+ }
+
+ public final RenderKit getRenderKit()
+ {
+ return _facesContext.getRenderKit();
+ }
+
+ public final boolean getRenderResponse()
+ {
+ return _facesContext.getRenderResponse();
+ }
+
+ public final boolean getResponseComplete()
+ {
+ return _facesContext.getResponseComplete();
+ }
+
+ public final void setResponseStream(ResponseStream responsestream)
+ {
+ _facesContext.setResponseStream(responsestream);
+ }
+
+ public final ResponseStream getResponseStream()
+ {
+ return _facesContext.getResponseStream();
+ }
+
+ public final void setResponseWriter(ResponseWriter responsewriter)
+ {
+ _facesContext.setResponseWriter(responsewriter);
+ }
+
+ public final ResponseWriter getResponseWriter()
+ {
+ return _facesContext.getResponseWriter();
+ }
+
+ public final void setViewRoot(UIViewRoot viewRoot)
+ {
+ _facesContext.setViewRoot(viewRoot);
+ }
+
+ public UIViewRoot getViewRoot()
+ {
+ return _facesContext.getViewRoot();
+ }
+
+ public final void addMessage(String clientId, FacesMessage message)
+ {
+ _facesContext.addMessage(clientId, message);
+ }
+
+ public final void renderResponse()
+ {
+ _facesContext.renderResponse();
+ }
+
+ public final void responseComplete()
+ {
+ _facesContext.responseComplete();
+ }
+
+ /**
+ * Implement getELContext by delegating call to another instance.
+ * <p>
+ * Note that this method was added in JSF1.2. In order for a JSF1.2
+ * implementation to be backwards-compatible with JSF1.1, the base
+ * class FacesContext therefore has to automatically do the delegation.
+ * Without automatic delegation, any JSF1.1 class that applies the decorator
+ * pattern to a FacesContext will just break in JSF1.2; the getELContext
+ * method is there (inherited from the base class) but does not correctly
+ * delegate.
+ * <p>
+ * Unfortunately, due to a design flaw in JSF1.2 it is simply not possible
+ * for the base class to delegate; the object to delegate to is not known
+ * to the base class! A partial solution that works in most cases is for
+ * the base class to delegate to the "core" instance of FacesContext for
+ * methods that are not overridden; Sun's RI does this correctly but
+ * unfortunately MyFaces 1.2.0-1.2.2 do not. See MYFACES-1820 for details.
+ * <p>
+ * The solution *here* is to require that a javax.el implementation is in
+ * the classpath even when running JSF1.1. It is then possible for this
+ * wrapper to override the method defined in JSF1.2 even when being
+ * compiled against the JSF1.1 implementation. It is mildly annoying to
+ * have to include javax.el in a JSF environment (ie when it will never
+ * be used) but better than the alternatives. Actually, for at least some
+ * JVMs, classes needed by a method are not loaded unless that method is
+ * actually referenced, so in some cases (including Sun Java 1.4-1.6) the
+ * el library *can* be omitted from the classpath with JSF1.1.
+ */
+ /*
+ public final ELContext getELContext()
+ {
+ // Here, we cannot call getELContext on FacesContext as it does not
+ // exist for JSF1.1; the solution is to use reflection instead. This
+ // method will never be called unless we are in a JSF1.2 environment
+ // so the target method will always exist when this is called.
+ try
+ {
+ if (methodGetELContext == null)
+ {
+ // Performance optimisation: find method, and cache it for later.
+ methodGetELContext = FacesContext.class.getDeclaredMethod("getELContext", (Class[]) null);
+ }
+ return (ELContext) methodGetELContext.invoke(_facesContext, (Object[]) null);
+ }
+ catch(NoSuchMethodException e)
+ {
+ // should never happen
+ Log log = LogFactory.getLog(this.getClass());
+ log.error("JSF1.2 method invoked in non-JSF-1.2 environment", e);
+ throw new IllegalStateException("JSF1.2 method invoked in non-JSF-1.2 environment");
+ }
+ catch(InvocationTargetException e)
+ {
+ // should never happen
+ Log log = LogFactory.getLog(this.getClass());
+ log.error("Method getELContext on wrapped instance threw exception", e);
+ throw new IllegalStateException("Method getELContext on wrapped instance threw exception");
+ }
+ catch(IllegalAccessException e)
+ {
+ // should never happen
+ Log log = LogFactory.getLog(this.getClass());
+ log.error("Method getElContext on wrapped instance is not accessable", e);
+ throw new IllegalStateException("Method getElContext on wrapped instance is not accessable");
+ }
+ }
+ */
+}
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRLifecycle.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRLifecycle.java?rev=642555&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRLifecycle.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRLifecycle.java Sat Mar 29 09:43:27 2008
@@ -0,0 +1,81 @@
+/*
+ * 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.
+*/
+package org.apache.myfaces.custom.ppr;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseListener;
+import javax.faces.lifecycle.Lifecycle;
+
+public class PPRLifecycle extends Lifecycle
+{
+ private final Lifecycle delegate;
+
+ public PPRLifecycle(Lifecycle delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ public void addPhaseListener(PhaseListener listener)
+ {
+ this.delegate.addPhaseListener(listener);
+ }
+
+ public void execute(final FacesContext context) throws FacesException
+ {
+ if (PPRSupport.isPartialRequest(context))
+ {
+ FacesContext wrappedContext = new PPRFacesContextWrapper(context)
+ {
+ public UIViewRoot getViewRoot()
+ {
+ UIViewRoot viewRoot = context.getViewRoot();
+ if (viewRoot == null)
+ {
+ return null;
+ }
+
+ return new PPRViewRootWrapper(context, viewRoot);
+ }
+ };
+
+ this.delegate.execute(wrappedContext);
+ }
+ else
+ {
+ this.delegate.execute(context);
+ }
+ }
+
+ public PhaseListener[] getPhaseListeners()
+ {
+ return this.delegate.getPhaseListeners();
+ }
+
+ public void removePhaseListener(PhaseListener listener)
+ {
+ this.delegate.removePhaseListener(listener);
+ }
+
+ public void render(FacesContext context) throws FacesException
+ {
+ this.delegate.render(context);
+ }
+}
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRLifecycleFactory.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRLifecycleFactory.java?rev=642555&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRLifecycleFactory.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRLifecycleFactory.java Sat Mar 29 09:43:27 2008
@@ -0,0 +1,39 @@
+package org.apache.myfaces.custom.ppr;
+
+import javax.faces.lifecycle.LifecycleFactory;
+import javax.faces.lifecycle.Lifecycle;
+import java.util.Iterator;
+
+public class PPRLifecycleFactory extends LifecycleFactory
+{
+ private final LifecycleFactory delegate;
+
+ private final PPRLifecycle pprLifecycle;
+
+ public PPRLifecycleFactory(LifecycleFactory delegate)
+ {
+ this.delegate = delegate;
+
+ pprLifecycle = new PPRLifecycle(this.delegate.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE));
+ }
+
+ public void addLifecycle(String lifecycleId, Lifecycle lifecycle)
+ {
+ this.delegate.addLifecycle(lifecycleId, lifecycle);
+ }
+
+ public Lifecycle getLifecycle(String lifecycleId)
+ {
+ if (LifecycleFactory.DEFAULT_LIFECYCLE.equals(lifecycleId))
+ {
+ return pprLifecycle;
+ }
+
+ return this.delegate.getLifecycle(lifecycleId);
+ }
+
+ public Iterator getLifecycleIds()
+ {
+ return this.delegate.getLifecycleIds();
+ }
+}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPhaseListener.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPhaseListener.java?rev=642555&r1=642554&r2=642555&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPhaseListener.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPhaseListener.java Sat Mar 29 09:43:27 2008
@@ -306,13 +306,13 @@
}
//Check which messages components this group wants to append to
if (ppr.getAppendMessages() != null) {
- List appendMessagesForThisGroup = getComponentsByCommaSeparatedIdList(context, ppr, ppr.getAppendMessages(), HtmlMessages.class);
+ List appendMessagesForThisGroup = PPRSupport.getComponentsByCommaSeparatedIdList(context, ppr, ppr.getAppendMessages(), HtmlMessages.class);
toAppendMessagesComponents.addAll(appendMessagesForThisGroup);
}
//Check which messages components this group should refresh
if (ppr.getReplaceMessages() != null) {
- List replaceMessagesForThisGroup = getComponentsByCommaSeparatedIdList(context, ppr, ppr.getReplaceMessages(), HtmlMessages.class);
+ List replaceMessagesForThisGroup = PPRSupport.getComponentsByCommaSeparatedIdList(context, ppr, ppr.getReplaceMessages(), HtmlMessages.class);
toReplaceMessagesComponents.addAll(replaceMessagesForThisGroup);
}
@@ -398,31 +398,6 @@
}
- private List getComponentsByCommaSeparatedIdList(FacesContext context, UIComponent comp, String idList, Class desiredType)
- {
- List retval = new ArrayList();
- UIComponent currentComponent = null;
- String[] ids = StringUtils.split(idList, ',');
- for (int i = 0; i < ids.length; i++) {
- String id = StringUtils.trim(ids[i]);
- currentComponent = comp.findComponent(id);
- if (nullSafeCheckComponentType(desiredType, currentComponent)) {
- retval.add(currentComponent);
- }
- else {
- currentComponent = context.getViewRoot().findComponent(id);
- if (nullSafeCheckComponentType(desiredType, currentComponent)) {
- retval.add(currentComponent);
- }
- }
- }
- return retval;
- }
-
- private boolean nullSafeCheckComponentType(Class desiredType, UIComponent currentComponent)
- {
- return currentComponent != null && (desiredType == null || desiredType.isAssignableFrom(currentComponent.getClass()));
- }
private static List getComponentsByCommaSeparatedList(FacesContext context, UIComponent comp, String commaSeparatedIdList, Class componentType)
{
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRSubmit.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRSubmit.java?rev=642555&r1=642554&r2=642555&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRSubmit.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRSubmit.java Sat Mar 29 09:43:27 2008
@@ -18,7 +18,17 @@
*/
package org.apache.myfaces.custom.ppr;
+import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
+
import javax.faces.component.UIComponentBase;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import javax.faces.event.FacesEvent;
+import java.util.Map;
+import java.util.List;
+import java.util.Iterator;
+import java.util.ArrayList;
/**
* @author Thomas Spiegl
@@ -31,8 +41,74 @@
public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.PPRSubmit";
+ private String processComponentIds;
+
public String getFamily()
{
return COMPONENT_FAMILY;
+ }
+
+ public String getProcessComponentIds()
+ {
+ if (processComponentIds != null) {
+ return processComponentIds;
+ }
+ ValueBinding vb = getValueBinding("processComponentIds");
+ return vb != null ? RendererUtils.getStringValue(getFacesContext(), vb) : null;
+ }
+
+ public void setProcessComponentIds(String processComponentIds)
+ {
+ this.processComponentIds = processComponentIds;
+ }
+
+ public void restoreState(FacesContext context, Object state)
+ {
+ Object[] states = (Object[]) state;
+ super.restoreState(context, states[0]);
+ processComponentIds = (String) states[1];
+ }
+
+ public Object saveState(FacesContext context)
+ {
+ return new Object[]
+ {
+ super.saveState(context),
+ processComponentIds
+ };
+ }
+
+ public void queueEvent(FacesEvent event)
+ {
+ super.queueEvent(event);
+
+ FacesContext context = FacesContext.getCurrentInstance();
+
+ String processComponentIdsString = getProcessComponentIds();
+
+ Map requestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
+ List allProcessComponents = (List) requestMap.get(PPRSupport.PROCESS_COMPONENTS);
+
+ List processComponents = PPRSupport.getComponentsByCommaSeparatedIdList(
+ context,
+ this,
+ processComponentIdsString,
+ null
+ );
+
+ Iterator iterComponents = processComponents.iterator();
+ while (iterComponents.hasNext())
+ {
+ UIComponent component = (UIComponent) iterComponents.next();
+ String clientId = component.getClientId(context);
+
+ if (allProcessComponents == null)
+ {
+ allProcessComponents = new ArrayList();
+ requestMap.put(PPRSupport.PROCESS_COMPONENTS, allProcessComponents);
+ }
+
+ allProcessComponents.add(clientId);
+ }
}
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRSubmitRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRSubmitRenderer.java?rev=642555&r1=642554&r2=642555&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRSubmitRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRSubmitRenderer.java Sat Mar 29 09:43:27 2008
@@ -18,8 +18,7 @@
*/
package org.apache.myfaces.custom.ppr;
-import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
-import org.apache.myfaces.shared_tomahawk.renderkit.html.util.FormInfo;
+import org.apache.commons.lang.StringUtils;
import javax.faces.FacesException;
import javax.faces.component.UICommand;
@@ -36,13 +35,46 @@
*/
public class PPRSubmitRenderer extends Renderer
{
- public void encodeEnd(FacesContext context, UIComponent component) throws IOException
+ public void encodeBegin(FacesContext context, UIComponent component) throws IOException
{
+ super.encodeBegin(context, component);
+
+ final PPRSubmit pprSubmit = (PPRSubmit) component;
+ UICommand command = findCommandComponent(false, component);
+ if (!StringUtils.isEmpty(pprSubmit.getProcessComponentIds()) &&
+ (command == null || command.isImmediate())) {
+ throw new FacesException("PPRSubmit must embed a command component with immedate='false'.");
+ }
+
+ /*
UIComponent parent = component.getParent();
if (parent instanceof UICommand) {
- PPRSupport.initPPR(context, component);
+
+ UICommand command = (UICommand) parent;
+
+ if (!StringUtils.isEmpty(pprSubmit.getProcessComponentIds()))
+ {
+ if (!Boolean.TRUE.equals(command.getAttributes().get(PPRSupport.COMMAND_CONFIGURED_MARK)))
+ {
+ command.getAttributes().put(PPRSupport.COMMAND_CONFIGURED_MARK, Boolean.TRUE);
+ command.addActionListener(new PPRActionListener());
+ }
+ }
+ }
+ else {
+ throw new FacesException("PPRSubmitRenderer must be embedded in a command component.");
+ }
+ */
+ }
+
+ public void encodeEnd(FacesContext context, UIComponent component) throws IOException
+ {
+ UICommand command = findCommandComponent(true, component);
+
+ if (command != null) {
+ PPRSupport.initPPR(context, command);
List panelGroups = new ArrayList(5);
- String id = parent.getId();
+ String id = command.getId();
addPPRPanelGroupComponents(context.getViewRoot(), panelGroups);
for (int i = 0; i < panelGroups.size(); i++) {
PPRPanelGroup pprGroup = (PPRPanelGroup) panelGroups.get(i);
@@ -50,14 +82,33 @@
for (int j = 0; j < triggers.size(); j++) {
PartialTriggerParser.PartialTrigger trigger = (PartialTriggerParser.PartialTrigger) triggers.get(j);
if (trigger.getPartialTriggerId().equals(id)) {
- PPRSupport.encodeJavaScript(context, parent, pprGroup, trigger);
+ PPRSupport.encodeJavaScript(context, command, pprGroup, trigger);
}
}
}
}
else {
- throw new FacesException("PPRSubmitRenderer must be embedded in a command component.");
+ throw new FacesException("PPRSubmitRenderer must be embedded in or embed a command component.");
+ }
+ }
+
+ private UICommand findCommandComponent(boolean checkParent, UIComponent component)
+ {
+ if (checkParent) {
+ UIComponent parent = component.getParent();
+ if (parent instanceof UICommand) {
+ return (UICommand) parent;
+ }
+ }
+
+ if (component.getChildCount() > 0) {
+ UIComponent child = (UIComponent) component.getChildren().get(0);
+ if (child instanceof UICommand) {
+ return (UICommand) child;
+ }
}
+
+ return null;
}
public void addPPRPanelGroupComponents(UIComponent component, List list)
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRSubmitTag.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRSubmitTag.java?rev=642555&r1=642554&r2=642555&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRSubmitTag.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRSubmitTag.java Sat Mar 29 09:43:27 2008
@@ -18,13 +18,16 @@
*/
package org.apache.myfaces.custom.ppr;
-import javax.faces.webapp.UIComponentBodyTag;
+import org.apache.myfaces.shared_tomahawk.taglib.UIComponentBodyTagBase;
+
+import javax.faces.component.UIComponent;
/**
* @author Thomas Spiegl
*/
-public class PPRSubmitTag extends UIComponentBodyTag
+public class PPRSubmitTag extends UIComponentBodyTagBase
{
+ private String processComponentIds;
public String getComponentType()
{
@@ -34,5 +37,29 @@
public String getRendererType()
{
return PPRSubmit.DEFAULT_RENDERER_TYPE;
+ }
+
+ public void release()
+ {
+ super.release();
+
+ processComponentIds=null;
+ }
+
+ protected void setProperties(UIComponent component)
+ {
+ super.setProperties(component);
+
+ setStringProperty(component, "processComponentIds", processComponentIds);
+ }
+
+ public String getProcessComponentIds()
+ {
+ return processComponentIds;
+ }
+
+ public void setProcessComponentIds(String processComponentIds)
+ {
+ this.processComponentIds = processComponentIds;
}
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRSupport.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRSupport.java?rev=642555&r1=642554&r2=642555&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRSupport.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRSupport.java Sat Mar 29 09:43:27 2008
@@ -20,6 +20,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.commons.lang.StringUtils;
import org.apache.myfaces.custom.dojo.DojoConfig;
import org.apache.myfaces.custom.dojo.DojoUtils;
import org.apache.myfaces.custom.subform.SubForm;
@@ -38,6 +39,7 @@
import java.io.IOException;
import java.util.List;
import java.util.Map;
+import java.util.ArrayList;
/**
* @author Ernst Fastl
@@ -63,6 +65,12 @@
private static final String MY_FACES_PPR_INIT_CODE = "new org.apache.myfaces.PPRCtrl";
+
+ public final static String COMMAND_CONFIGURED_MARK = PPRSupport.class.getName() + "_CONFIGURED";
+
+ public final static String PROCESS_COMPONENTS = PPRSupport.class.getName() + "PROCESS_COMPONENTS";
+
+
public static boolean isPartialRequest(FacesContext facesContext)
{
return PPRPhaseListener.isPartialRequest(facesContext);
@@ -370,5 +378,40 @@
writer.writeAttribute(HTML.TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
writer.write(script);
writer.endElement(HTML.SCRIPT_ELEM);
+ }
+
+ /**
+ * get all components by given id-string-list ("id1,id2,id3") and appropriate type
+ *
+ * @param context
+ * @param comp
+ * @param idList
+ * @param desiredType
+ * @return
+ */
+ public static List getComponentsByCommaSeparatedIdList(FacesContext context, UIComponent comp, String idList, Class desiredType)
+ {
+ List retval = new ArrayList();
+ UIComponent currentComponent = null;
+ String[] ids = StringUtils.split(idList, ',');
+ for (int i = 0; i < ids.length; i++) {
+ String id = StringUtils.trim(ids[i]);
+ currentComponent = comp.findComponent(id);
+ if (nullSafeCheckComponentType(desiredType, currentComponent)) {
+ retval.add(currentComponent);
+ }
+ else {
+ currentComponent = context.getViewRoot().findComponent(id);
+ if (nullSafeCheckComponentType(desiredType, currentComponent)) {
+ retval.add(currentComponent);
+ }
+ }
+ }
+ return retval;
+ }
+
+ private static boolean nullSafeCheckComponentType(Class desiredType, UIComponent currentComponent)
+ {
+ return currentComponent != null && (desiredType == null || desiredType.isAssignableFrom(currentComponent.getClass()));
}
}
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRViewRootWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRViewRootWrapper.java?rev=642555&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRViewRootWrapper.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRViewRootWrapper.java Sat Mar 29 09:43:27 2008
@@ -0,0 +1,333 @@
+/*
+ * 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.
+*/
+package org.apache.myfaces.custom.ppr;
+
+import org.apache.myfaces.component.html.ext.UIComponentPerspective;
+import org.apache.myfaces.shared_tomahawk.component.ExecuteOnCallback;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+public class PPRViewRootWrapper extends UIViewRoot
+{
+ private final UIViewRoot delegateViewRoot;
+ private final FacesContext delegateFacesContext;
+
+ public PPRViewRootWrapper(FacesContext delegateFacesContext, UIViewRoot delegateViewRoot)
+ {
+ this.delegateViewRoot = delegateViewRoot;
+ this.delegateFacesContext = delegateFacesContext;
+ }
+
+ public boolean getRendersChildren()
+ {
+ return true;
+ }
+
+ public List getChildren()
+ {
+ return delegateViewRoot.getChildren();
+ }
+
+ public int getChildCount()
+ {
+ return delegateViewRoot.getChildCount();
+ }
+
+
+ public String getViewId()
+ {
+ return delegateViewRoot.getViewId();
+ }
+
+ public void setViewId(String viewId)
+ {
+ delegateViewRoot.setViewId(viewId);
+ }
+
+ public void queueEvent(FacesEvent event)
+ {
+ delegateViewRoot.queueEvent(event);
+ }
+
+ public void processDecodes(FacesContext context)
+ {
+ delegateViewRoot.processDecodes(delegateFacesContext);
+ }
+
+ public void processValidators(FacesContext context)
+ {
+ Map requestMap = delegateFacesContext.getExternalContext().getRequestMap();
+ List allProcessComponents = (List) requestMap.get(PPRSupport.PROCESS_COMPONENTS);
+ if (allProcessComponents != null)
+ {
+ invokeOnComponents(delegateFacesContext, allProcessComponents, new ContextCallback()
+ {
+ public void invokeContextCallback(FacesContext context, UIComponent target)
+ {
+ target.processValidators(context);
+ }
+ });
+ }
+ else
+ {
+ delegateViewRoot.processValidators(delegateFacesContext);
+ }
+ }
+
+ private void invokeOnComponents(FacesContext context, List componentClientIds, final ContextCallback contextCallback)
+ {
+ Iterator iterComponents = componentClientIds.iterator();
+ while (iterComponents.hasNext())
+ {
+ String componentId = (String) iterComponents.next();
+
+ UIComponent component = delegateFacesContext.getViewRoot().findComponent(componentId);
+ if (component instanceof UIComponentPerspective)
+ {
+ UIComponentPerspective uiComponentPerspective = (UIComponentPerspective) component;
+ ExecuteOnCallback getComponentCallback = new ExecuteOnCallback()
+ {
+ public Object execute(FacesContext context, UIComponent component)
+ {
+ contextCallback.invokeContextCallback(delegateFacesContext, component);
+ return null;
+ }
+ };
+ uiComponentPerspective.executeOn(context, getComponentCallback);
+ }
+ else
+ {
+ contextCallback.invokeContextCallback(delegateFacesContext, component);
+ }
+ }
+ }
+
+ public void processUpdates(FacesContext context)
+ {
+ Map requestMap = delegateFacesContext.getExternalContext().getRequestMap();
+ List allProcessComponents = (List) requestMap.get(PPRSupport.PROCESS_COMPONENTS);
+ if (allProcessComponents != null)
+ {
+ invokeOnComponents(delegateFacesContext, allProcessComponents, new ContextCallback()
+ {
+ public void invokeContextCallback(FacesContext context, UIComponent target)
+ {
+ target.processUpdates(context);
+ }
+ });
+ }
+ else
+ {
+ delegateViewRoot.processUpdates(delegateFacesContext);
+ }
+ }
+
+ public void processApplication(FacesContext context)
+ {
+ delegateViewRoot.processApplication(delegateFacesContext);
+ }
+
+ public void encodeBegin(FacesContext context)
+ throws java.io.IOException
+ {
+ delegateViewRoot.encodeBegin(delegateFacesContext);
+ }
+
+ /* Provides a unique id for this component instance.
+ */
+ public String createUniqueId()
+ {
+ return delegateViewRoot.createUniqueId();
+ }
+
+ public Locale getLocale()
+ {
+ return delegateViewRoot.getLocale();
+ }
+
+
+ public void setLocale(Locale locale)
+ {
+ delegateViewRoot.setLocale(locale);
+ }
+
+ public static final String COMPONENT_TYPE = "javax.faces.ViewRoot";
+ public static final String COMPONENT_FAMILY = "javax.faces.ViewRoot";
+
+ public String getFamily()
+ {
+ return COMPONENT_FAMILY;
+ }
+
+
+ public void setRenderKitId(String renderKitId)
+ {
+ delegateViewRoot.setRenderKitId(renderKitId);
+ }
+
+ public String getRenderKitId()
+ {
+ return delegateViewRoot.getRenderKitId();
+ }
+
+
+ public Object saveState(FacesContext context)
+ {
+ return delegateViewRoot.saveState(delegateFacesContext);
+ }
+
+ public void restoreState(FacesContext context, Object state)
+ {
+ delegateViewRoot.restoreState(delegateFacesContext, state);
+ }
+
+ public Map getAttributes()
+ {
+ return delegateViewRoot.getAttributes();
+ }
+
+ public ValueBinding getValueBinding(String name)
+ {
+ return delegateViewRoot.getValueBinding(name);
+ }
+
+ public void setValueBinding(String name, ValueBinding binding)
+ {
+ delegateViewRoot.setValueBinding(name, binding);
+ }
+
+ public String getClientId(FacesContext context)
+ {
+ return delegateViewRoot.getClientId(delegateFacesContext);
+ }
+
+ public String getId()
+ {
+ return delegateViewRoot.getId();
+ }
+
+ public void setId(String id)
+ {
+ delegateViewRoot.setId(id);
+ }
+
+ public UIComponent getParent()
+ {
+ return delegateViewRoot.getParent();
+ }
+
+ public void setParent(UIComponent parent)
+ {
+ delegateViewRoot.setParent(parent);
+ }
+
+ public UIComponent findComponent(String expr)
+ {
+ return delegateViewRoot.findComponent(expr);
+ }
+
+ public Map getFacets()
+ {
+ return delegateViewRoot.getFacets();
+ }
+
+ public UIComponent getFacet(String name)
+ {
+ return delegateViewRoot.getFacet(name);
+ }
+
+ public Iterator getFacetsAndChildren()
+ {
+ return delegateViewRoot.getFacetsAndChildren();
+ }
+
+ public void broadcast(FacesEvent event)
+ throws AbortProcessingException
+ {
+ delegateViewRoot.broadcast(event);
+ }
+
+ public void decode(FacesContext context)
+ {
+ delegateViewRoot.decode(delegateFacesContext);
+ }
+
+ public void encodeChildren(FacesContext context)
+ throws IOException
+ {
+ delegateViewRoot.encodeChildren(delegateFacesContext);
+ }
+
+ public void encodeEnd(FacesContext context)
+ throws IOException
+ {
+ delegateViewRoot.encodeEnd(delegateFacesContext);
+ }
+
+ public Object processSaveState(FacesContext context)
+ {
+ return delegateViewRoot.processSaveState(delegateFacesContext);
+ }
+
+ public void processRestoreState(FacesContext context, Object state)
+ {
+ delegateViewRoot.processRestoreState(delegateFacesContext, state);
+ }
+
+ public boolean isTransient()
+ {
+ return delegateViewRoot.isTransient();
+ }
+
+ public void setTransient(boolean transientFlag)
+ {
+ delegateViewRoot.setTransient(transientFlag);
+ }
+
+ public void setRendered(boolean rendered)
+ {
+ delegateViewRoot.setRendered(rendered);
+ }
+
+ public boolean isRendered()
+ {
+ return delegateViewRoot.isRendered();
+ }
+
+ public void setRendererType(String rendererType)
+ {
+ delegateViewRoot.setRendererType(rendererType);
+ }
+
+ public String getRendererType()
+ {
+ return delegateViewRoot.getRendererType();
+ }
+
+}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml?rev=642555&r1=642554&r2=642555&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml Sat Mar 29 09:43:27 2008
@@ -665,6 +665,10 @@
<property-resolver>org.apache.myfaces.custom.security.SecurityContextPropertyResolver</property-resolver>
</application>
+ <factory>
+ <lifecycle-factory>org.apache.myfaces.custom.ppr.PPRLifecycleFactory</lifecycle-factory>
+ </factory>
+
<!--custom validators -->
<validator>
<validator-id>org.apache.myfaces.validator.Url</validator-id>
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld?rev=642555&r1=642554&r2=642555&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld Sat Mar 29 09:43:27 2008
@@ -1372,6 +1372,15 @@
<tag-class>org.apache.myfaces.custom.ppr.PPRSubmitTag</tag-class>
<body-content>JSP</body-content>
<description>PPRSubmitTag can be attached to command components, enabling PPR-request inside UIData components</description>
+ <attribute>
+ <name>processComponentIds</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <description>
+ comma separated List of component ids to process. As usual the whole form will be transmitted and
+ rerendered, but only for the components configured validation and update-model will happen.
+ </description>
+ </attribute>
</tag>
<tag>
Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/ppr/PPRExampleBean.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/ppr/PPRExampleBean.java?rev=642555&r1=642554&r2=642555&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/ppr/PPRExampleBean.java (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/ppr/PPRExampleBean.java Sat Mar 29 09:43:27 2008
@@ -19,15 +19,15 @@
package org.apache.myfaces.examples.ppr;
-import org.apache.myfaces.examples.inputSuggestAjax.Address;
import org.apache.myfaces.custom.ppr.PPRPhaseListener;
+import org.apache.myfaces.examples.inputSuggestAjax.Address;
import javax.faces.FacesException;
-import javax.faces.context.FacesContext;
-import javax.faces.model.SelectItem;
-import javax.faces.component.UIData;
import javax.faces.component.UIComponent;
+import javax.faces.component.UIData;
+import javax.faces.context.FacesContext;
import javax.faces.event.ValueChangeEvent;
+import javax.faces.model.SelectItem;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -186,6 +186,11 @@
iterator.remove();
}
}
+ return null;
+ }
+
+ public String doNothingAction()
+ {
return null;
}
Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp?rev=642555&r1=642554&r2=642555&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp Sat Mar 29 09:43:27 2008
@@ -41,6 +41,7 @@
<h:outputLink value="pprPanelGroupDataScroller.jsf" ><f:verbatim>PPRPanelGroup - ajaxifying a datatable using PPR with partialTriggerPattern</f:verbatim></h:outputLink>
<h:outputLink value="pprPanelGroupPeriodicalUpdate.jsf" ><f:verbatim>PPRPanelGroup - parts of a page are getting automatically refreshed by AJAX-Calls (through periodic intervals)</f:verbatim></h:outputLink>
<h:outputLink value="pprPanelGroupDataTable.jsf" ><f:verbatim>PPRPanelGroup - dataTable example, server-side requested refresh example </f:verbatim></h:outputLink>
+ <h:outputLink value="pprPanelGroupProcessComponents.jsf" ><f:verbatim>PPRPanelGroup - form with validate/upate-model only configured components</f:verbatim></h:outputLink>
</h:panelGrid>
<h:outputText value="Resource Serving"/>
<h:panelGrid style="padding-left:25px">
Copied: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroupProcessComponents.jsp (from r642510, myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroupLoadingMessage.jsp)
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroupProcessComponents.jsp?p2=myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroupProcessComponents.jsp&p1=myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroupLoadingMessage.jsp&r1=642510&r2=642555&rev=642555&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroupLoadingMessage.jsp (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroupProcessComponents.jsp Sat Mar 29 09:43:27 2008
@@ -1,43 +1,44 @@
-<%@ page session="false" contentType="text/html;charset=utf-8"%>
-<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
-<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
-<%@ taglib uri="http://myfaces.apache.org/sandbox" prefix="s"%>
-<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
+<%@ page session="false" contentType="text/html;charset=utf-8" %>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ taglib uri="http://myfaces.apache.org/sandbox" prefix="s" %>
+<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t" %>
<!--
/*
- * 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.
- */
+* 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.
+*/
//-->
<html>
-<%@ include file="inc/head.inc"%>
+<%@ include file="inc/head.inc" %>
<body>
-<h1>PPR Examples - displaying an inline Loading Message during AJAX requests</h1>
+<h1>PPR Examples - submit a form but process only specific components</h1>
<span id="cnt">0</span>
seconds since last page refresh.
<script>
- var sec=0;
- function counter(){
- setTimeout("counter();",1000);
+ var sec = 0;
+ function counter()
+ {
+ setTimeout("counter();", 1000);
document.getElementById("cnt").innerHTML = sec++;
}
counter();
@@ -45,40 +46,58 @@
<f:view>
- <h:form id="mainform">
+ <h:form id="mainform">
- <h:panelGrid columns="2">
- <h:outputText value="Enter the value for update:" />
- <h:inputText value="#{pprExampleBean.textField}" />
-
- <h:outputText value="partial update button:" />
- <h:commandButton id="pprSubmitButton" value="PPR Submit" action="#{pprExampleBean.doTimeConsumingStuff}"/>
-
- <h:outputText value="PPRPanelGroup:" />
- <s:pprPanelGroup id="ppr1"
- partialTriggers="pprSubmitButton" inlineLoadingMessage="Loading...">
- <h:outputText value="#{pprExampleBean.textField}" />
- </s:pprPanelGroup>
- </h:panelGrid>
+ <h:panelGrid columns="2">
+ <h:outputText value="Enter the value for update:"/>
+ <h:inputText id="textfield1" value="#{pprExampleBean.textField}" required="true"/>
+
+ <h:outputText value="Leave empty for force validation error"/>
+ <h:inputText id="textfield2" value="#{pprExampleBean.inputTextValue}" required="true"/>
+
+ <h:outputText value="partial update button which failes:"/>
+ <h:commandButton id="pprSubmitButtonFail"
+ value="PPR Submit"
+ action="#{pprExampleBean.doNothingAction}"/>
+
+ <h:outputText value="partial update button which works:"/>
+ <s:pprSubmit processComponentIds="textfield1">
+ <h:commandButton id="pprSubmitButtonWork"
+ value="PPR Submit - Textfield1 only"
+ action="#{pprExampleBean.doNothingAction}" />
+ </s:pprSubmit>
+
+ <h:outputText value="PPRPanelGroup:"/>
+ <s:pprPanelGroup id="ppr1"
+ partialTriggers="pprSubmitButtonFail,pprSubmitButtonWork"
+ inlineLoadingMessage="Loading..."
+ replaceMessages="messages">
+ <h:outputText value="#{pprExampleBean.textField}"/>
+ </s:pprPanelGroup>
+ </h:panelGrid>
<s:fieldset legend="about this example">
<f:verbatim>
<br/>
- <br/>
- The inlineLoadingMessage attribute contains a message as a String <br/>
- which is displayed instead of the pprPanelGroup during the AJAX <br/>
- request.<br />
- <br/>
- This example shows a loading message while executing a 4 seconds <br/>
- timeout within the called action. <br/>
+ Both input fields in this form are required. Normally a PPR request will fail as long as
+ the validation chain reports a single error.
+ <br />
+ The second button configures the ppr request in a way that allows MyFaces to validate/model-update
+ only those fields in question.
+ <br />
+ <br />
+ If you press the first button nothing happens as long as the second textfield has no data.
+ <br />
+ If you press the second button it is sufficient to enter something into the first textfield.
</f:verbatim>
</s:fieldset>
</h:form>
+ <h:messages id="messages" />
</f:view>
-<%@include file="inc/page_footer.jsp"%>
+<%@include file="inc/page_footer.jsp" %>
</body>