You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ar...@apache.org on 2007/08/31 20:30:02 UTC
svn commit: r571531 - in /myfaces/trinidad/trunk/trinidad:
trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/
trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/
trinidad-build/src/main/resources/META-INF/maven-faces-...
Author: arobinson74
Date: Fri Aug 31 11:30:01 2007
New Revision: 571531
URL: http://svn.apache.org/viewvc?rev=571531&view=rev
Log:
JIRA TRINIDAD-663 - Create a new component UIXPartialTrigger to help with PPR functionality
Added:
myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXPartialTriggerTemplate.java (with props)
myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/PartialTriggerEvent.java (with props)
myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/PartialTriggerListener.java (with props)
myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/PartialTrigger.xml (with props)
Modified:
myfaces/trinidad/trunk/trinidad/trinidad-examples/trinidad-demo/src/main/webapp/demos/pprDemos.jspx
Added: myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXPartialTriggerTemplate.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXPartialTriggerTemplate.java?rev=571531&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXPartialTriggerTemplate.java (added)
+++ myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXPartialTriggerTemplate.java Fri Aug 31 11:30:01 2007
@@ -0,0 +1,68 @@
+/*
+ * 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.trinidad.component;
+
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.PhaseId;
+
+import org.apache.myfaces.trinidad.context.RequestContext;
+import org.apache.myfaces.trinidad.event.PartialTriggerEvent;
+
+/**
+ * This component queues
+ */
+public abstract class UIXPartialTriggerTemplate extends UIXComponentBase
+{
+/**/ public abstract String[] getPartialTargets();
+/**/ public abstract boolean isImmediate();
+
+ /**
+ * @see org.apache.myfaces.trinidad.component.UIXComponentBase#queueEvent(javax.faces.event.FacesEvent)
+ */
+ @Override
+ public void queueEvent(FacesEvent event)
+ {
+ PartialTriggerEvent triggerEvent = new PartialTriggerEvent(this);
+
+ triggerEvent.setPhaseId(isImmediate() ? PhaseId.ANY_PHASE :
+ event.getPhaseId());
+
+ super.queueEvent(triggerEvent);
+ super.queueEvent(event);
+ }
+
+ /**
+ * @see org.apache.myfaces.trinidad.component.UIXComponentBase#broadcast(javax.faces.event.FacesEvent)
+ */
+ @Override
+ public void broadcast(FacesEvent event) throws AbortProcessingException
+ {
+ String[] targets = getPartialTargets();
+ if (targets != null)
+ {
+ RequestContext arc = RequestContext.getCurrentInstance();
+ if (arc != null)
+ {
+ arc.addPartialTargets(this, targets);
+ }
+ }
+ super.broadcast(event);
+ }
+}
Propchange: myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXPartialTriggerTemplate.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXPartialTriggerTemplate.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/PartialTriggerEvent.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/PartialTriggerEvent.java?rev=571531&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/PartialTriggerEvent.java (added)
+++ myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/PartialTriggerEvent.java Fri Aug 31 11:30:01 2007
@@ -0,0 +1,60 @@
+/*
+ * 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.trinidad.event;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+/**
+ * Event used with the partialTrigger component
+ *
+ * @version $Name$ ($Revision$) $Date$
+ * @author Andrew Robinson
+ */
+public class PartialTriggerEvent extends FacesEvent
+{
+ /**
+ * @param uiComponent the source component of the event
+ */
+ public PartialTriggerEvent(UIComponent uiComponent)
+ {
+ super(uiComponent);
+ }
+
+ /**
+ * @see javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
+ */
+ @Override
+ public boolean isAppropriateListener(FacesListener faceslistener)
+ {
+ return faceslistener instanceof PartialTriggerListener;
+ }
+
+ /**
+ * @see javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
+ */
+ @Override
+ public void processListener(FacesListener faceslistener)
+ {
+ ((PartialTriggerListener)faceslistener).onPartialTrigger(this);
+ }
+
+ private static final long serialVersionUID = 1L;
+}
Propchange: myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/PartialTriggerEvent.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/PartialTriggerEvent.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/PartialTriggerListener.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/PartialTriggerListener.java?rev=571531&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/PartialTriggerListener.java (added)
+++ myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/PartialTriggerListener.java Fri Aug 31 11:30:01 2007
@@ -0,0 +1,33 @@
+/*
+ * 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.trinidad.event;
+
+/**
+ * Listener for {@link PartialTriggerEvent}
+ *
+ * @version $Name$ ($Revision$) $Date$
+ * @author Andrew Robinson
+ */
+public interface PartialTriggerListener
+{
+ /**
+ * Listen for partial trigger events
+ */
+ public void onPartialTrigger(PartialTriggerEvent evt);
+}
Propchange: myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/PartialTriggerListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/PartialTriggerListener.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/PartialTrigger.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/PartialTrigger.xml?rev=571531&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/PartialTrigger.xml (added)
+++ myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/PartialTrigger.xml Fri Aug 31 11:30:01 2007
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+
+-->
+<faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:tr="http://myfaces.apache.org/trinidad"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:mfp="http://myfaces.apache.org/maven-faces-plugin"
+ xmlns:mafp="http://myfaces.apache.org/maven-trinidad-plugin"
+ xmlns:xhtml="http://www.w3.org/1999/xhtml">
+ <component>
+ <description><![CDATA[Component that provides partialTriggers, partialTargets and immediate
+event broadcasting of events for PPR]]></description>
+ <icon>
+ <small-icon>/org/apache/myfaces/trinidad/metadata/icons/partialTrigger.png</small-icon>
+ </icon>
+ <component-type>org.apache.myfaces.trinidad.PartialTrigger</component-type>
+ <component-class>org.apache.myfaces.trinidad.component.UIXPartialTrigger</component-class>
+ <property>
+ <description><![CDATA[whether broadcasting of partial trigger events should be
+immediate.
+
+When immediate is true, all the PartialTriggerEvent events queued by this component will
+be marked with the 'ANY' JSF phase ID. This will cause the event to be broadcast at the
+end of the current phase. This makes it possible to perform partial triggering of components
+before the phase that the triggering component's event. For example, a UIXCommand will typically
+queue an ActionEvent with a phase of INVOKE_APPLICATION. If a partial trigger with
+immediate set to true is a parent component, listeners to the partial trigger will be queued for
+re-rendering during the APPLY_REQUEST_VALUES phase instead of INVOKE_APPLICATION.]]>
+ </description>
+ <property-name>immediate</property-name>
+ <property-class>boolean</property-class>
+ </property>
+ <property>
+ <description><![CDATA[the IDs of the components that should trigger a partial update.
+ This component will listen on the trigger components. If one of the
+ trigger components receives an event that will cause it to update
+ in some way, this component will request to be updated too.
+ Identifiers are relative to the source component, and must account for
+ NamingContainers. If your component is already inside of a naming
+ container, you can use a single colon to start the search from the root,
+ or multiple colons to move up through the NamingContainers - "::" will
+ search from the parent naming container, ":::" will search
+ from the grandparent naming container, etc. ]]>
+ </description>
+ <property-name>partialTriggers</property-name>
+ <property-class>java.lang.String[]</property-class>
+ <property-extension>
+ <mfp:property-metadata>
+ <mfp:preferred>true</mfp:preferred>
+ </mfp:property-metadata>
+ </property-extension>
+ </property>
+ <property>
+ <description><![CDATA[the IDs of the components that should be triggered
+ by a partial update.
+
+ This component will trigger the partial update of all of these
+ components if an event is broadcast by this component.
+ Identifiers are relative to the source component, and must account for
+ NamingContainers. If your component is already inside of a naming
+ container, you can use a single colon to start the search from the root,
+ or multiple colons to move up through the NamingContainers - "::" will
+ search from the parent naming container, ":::" will search
+ from the grandparent naming container, etc. ]]>
+ </description>
+ <property-name>partialTargets</property-name>
+ <property-class>java.lang.String[]</property-class>
+ </property>
+ <component-extension>
+ <mfp:component-family>org.apache.myfaces.trinidad.PartialTrigger</mfp:component-family>
+ <mfp:component-supertype>org.apache.myfaces.trinidad.ComponentBase</mfp:component-supertype>
+ <mfp:component-superclass>org.apache.myfaces.trinidad.component.UIXComponentBase</mfp:component-superclass>
+ <mfp:tag-name>tr:partialTrigger</mfp:tag-name>
+ <mfp:tag-class>org.apache.myfaces.trinidadinternal.taglib.UIXPartialTriggerTag</mfp:tag-class>
+ <mfp:long-description><![CDATA[<html><p>UIXPartialTrigger is a component that provides integration
+with the PPR functionality of Trinidad. It supports three main use cases.</p>
+<ol>
+<li>partialTriggers is supported. Being used as a parent component of several other components,
+it is able to trigger partial rendering if any of its children broadcast an event.</li>
+<li>partialTargets provides a way to force other components to be updated when a child component
+broadcasts an event.</li>
+<li>the ability to have the trigger happen immediately. Setting the immediate attribute to true
+will cause an event to be queued with the 'ANY' phase ID, executing the functionality at the
+end of the current phase</li>
+</ol>
+<p>This component does not render anything, it is used only for PPR integration.</p></html>
+]]>
+ </mfp:long-description>
+ <mfp:author>Andrew Robinson</mfp:author>
+ </component-extension>
+ </component>
+</faces-config>
\ No newline at end of file
Propchange: myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/PartialTrigger.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/PartialTrigger.xml
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/trinidad/trunk/trinidad/trinidad-examples/trinidad-demo/src/main/webapp/demos/pprDemos.jspx
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-examples/trinidad-demo/src/main/webapp/demos/pprDemos.jspx?rev=571531&r1=571530&r2=571531&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-examples/trinidad-demo/src/main/webapp/demos/pprDemos.jspx (original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-examples/trinidad-demo/src/main/webapp/demos/pprDemos.jspx Fri Aug 31 11:30:01 2007
@@ -278,8 +278,98 @@
<tr:selectItem label="Index" value="/index.jspx"/>
<tr:selectItem label="Component Demos" value="/componentDemos.jspx"/>
</tr:selectOneChoice>
+ </tr:panelHeader>
+ <tr:panelHeader
+ text="Partial trigger demonstrations">
+ <tr:panelGroupLayout
+ layout="vertical">
+ <tr:panelHeader
+ text="Trigger rendering with validation errors">
+ <tr:subform>
+ <tr:panelGroupLayout
+ layout="vertical">
+ <tr:inputText
+ id="partialTriggerText1"
+ label="This is required"
+ showRequired="true"
+ value="#{partialTriggerText1}"
+ required="true"
+ partialTriggers="partialTrigger1" />
+ <tr:partialTrigger
+ id="partialTrigger1"
+ immediate="true">
+ <tr:commandLink
+ id="partialTriggerLink1"
+ partialSubmit="true"
+ text="Trigger" />
+ </tr:partialTrigger>
+ </tr:panelGroupLayout>
+ </tr:subform>
+ </tr:panelHeader>
+ <tr:panelHeader
+ text="Trigger based on target rather then trigger">
+ <tr:subform>
+ <tr:panelGroupLayout
+ layout="vertical">
+ <tr:outputFormatted
+ id="partialTriggerTarget2"
+ styleUsage="instruction"
+ value="#{partialDemoUtil.status.linkUpdate}">
+ <f:convertDateTime pattern="HH:mm:ss"/>
+ </tr:outputFormatted>
+ <tr:partialTrigger
+ id="partialTrigger2"
+ partialTargets="partialTriggerTarget2">
+ <tr:commandLink
+ id="partialTriggerLink2"
+ partialSubmit="true"
+ text="Trigger"
+ actionListener="#{partialDemoUtil.action}" />
+ </tr:partialTrigger>
+ </tr:panelGroupLayout>
+ </tr:subform>
+ </tr:panelHeader>
+ <tr:panelHeader
+ text="Listen to a parent of several components that can trigger">
+ <tr:subform>
+ <tr:panelGroupLayout
+ layout="vertical">
+ <tr:outputFormatted
+ id="partialTriggerTarget3"
+ styleUsage="instruction"
+ partialTriggers="partialTrigger3"
+ value="#{partialDemoUtil.status.linkUpdate}">
+ <f:convertDateTime pattern="HH:mm:ss"/>
+ </tr:outputFormatted>
+ <tr:partialTrigger
+ id="partialTrigger3">
+ <tr:panelGroupLayout
+ layout="horizontal">
+ <tr:commandLink
+ id="partialTriggerLink3a"
+ partialSubmit="true"
+ text="Trigger A"
+ actionListener="#{partialDemoUtil.action}" />
+ <tr:spacer width="8" height="10"/>
+ <tr:commandLink
+ id="partialTriggerLink3b"
+ partialSubmit="true"
+ text="Trigger B"
+ actionListener="#{partialDemoUtil.action}" />
+ <tr:spacer width="8" height="10"/>
+ <tr:commandLink
+ id="partialTriggerLink3c"
+ partialSubmit="true"
+ text="Trigger C"
+ actionListener="#{partialDemoUtil.action}" />
+ </tr:panelGroupLayout>
+ </tr:partialTrigger>
+ </tr:panelGroupLayout>
+ </tr:subform>
+ </tr:panelHeader>
+ </tr:panelGroupLayout>
</tr:panelHeader>
- </tr:panelGroupLayout>
+ </tr:panelGroupLayout>
</tr:panelHeader>
</tr:panelPage>
</tr:form>