You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gm...@apache.org on 2006/09/28 00:20:47 UTC
svn commit: r450600 - in /myfaces/tomahawk/trunk/sandbox:
core/src/main/java/org/apache/myfaces/custom/ppr/
core/src/main/resources/org/apache/myfaces/custom/ppr/resource/
core/src/main/tld/ examples/src/main/java/org/apache/myfaces/examples/ppr/
examp...
Author: gmuellan
Date: Wed Sep 27 15:20:43 2006
New Revision: 450600
URL: http://svn.apache.org/viewvc?view=rev&rev=450600
Log:
applied patches for ppr; TOMAHAWK-695, -696, -697, -700, -702, -707, -708; thanks to ernst fastl
Modified:
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroup.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupRenderer.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupTag.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPhaseListener.java
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ppr/resource/ppr.js
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/pprPanelGroup.jsp
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroup.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroup.java?view=diff&rev=450600&r1=450599&r2=450600
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroup.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroup.java Wed Sep 27 15:20:43 2006
@@ -16,8 +16,10 @@
package org.apache.myfaces.custom.ppr;
import org.apache.myfaces.component.html.ext.HtmlPanelGroup;
+import org.apache.myfaces.shared_tomahawk.util._ComponentUtils;
import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
/**
* @author Ernst Fastl
@@ -29,6 +31,10 @@
public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.PPRPanelGroup";
private String _partialTriggers;
+
+ private String _partialTriggerPattern;
+
+ private String _inlineLoadingMessage;
public PPRPanelGroup()
{
@@ -42,13 +48,39 @@
public String getPartialTriggers()
{
- return _partialTriggers;
+ if (_partialTriggers != null) return _partialTriggers;
+ ValueBinding vb = getValueBinding("partialTriggers");
+ return vb != null ? _ComponentUtils.getStringValue(getFacesContext(), vb) : null;
}
public void setPartialTriggers(String partialTriggers)
{
this._partialTriggers = partialTriggers;
}
+
+ public String getPartialTriggerPattern()
+ {
+ if (_partialTriggerPattern != null) return _partialTriggerPattern;
+ ValueBinding vb = getValueBinding("partialTriggerPattern");
+ return vb != null ? _ComponentUtils.getStringValue(getFacesContext(), vb) : null;
+ }
+
+ public void setPartialTriggerPattern(String partialTriggerPattern)
+ {
+ this._partialTriggerPattern = partialTriggerPattern;
+ }
+
+ public String getInlineLoadingMessage()
+ {
+ if (_inlineLoadingMessage != null) return _inlineLoadingMessage;
+ ValueBinding vb = getValueBinding("inlineLoadingMessage");
+ return vb != null ? _ComponentUtils.getStringValue(getFacesContext(), vb) : null;
+ }
+
+ public void setInlineLoadingMessage(String inlineLoadingMessage)
+ {
+ this._inlineLoadingMessage = inlineLoadingMessage;
+ }
public void restoreState(FacesContext context, Object state)
{
@@ -56,14 +88,16 @@
Object[] values = (Object[]) state;
super.restoreState(context, values[0]);
_partialTriggers = (String) values[1];
+ _partialTriggerPattern = (String) values[1];
}
public Object saveState(FacesContext context)
{
- Object[] values = new Object[2];
+ Object[] values = new Object[3];
values[0] = super.saveState(context);
values[1] = _partialTriggers;
+ values[2] = _partialTriggerPattern;
return values;
}
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupRenderer.java?view=diff&rev=450600&r1=450599&r2=450600
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupRenderer.java Wed Sep 27 15:20:43 2006
@@ -47,6 +47,8 @@
private static final String MY_FACES_PPR_INITIALIZED = "/*MyFaces PPR initialized*/";
private static final String ADD_PARTIAL_TRIGGER_FUNCTION = "addPartialTrigger";
+ private static final String ADD_PARTIAL_TRIGGER_PATTERN_FUNCTION = "addPartialTriggerPattern";
+ private static final String ADD_INLINE_LOADING_MESSAGE_FUNCTION = "addInlineLoadingMessage";
private static final String PPR_JS_FILE = "ppr.js";
private static final String MY_FACES_PPR_INIT_CODE = "new org.apache.myfaces.PPRCtrl";
@@ -100,32 +102,72 @@
String partialTriggerId = null;
String partialTriggerClientId = null;
UIComponent partialTriggerComponent = null;
+
String partialTriggers = ((PPRPanelGroup) uiComponent).getPartialTriggers();
String clientId = uiComponent.getClientId(facesContext);
- StringTokenizer st = new StringTokenizer(partialTriggers, ",; ", false);
- while (st.hasMoreTokens())
+
+ String partialTriggerPattern = ((PPRPanelGroup) uiComponent).getPartialTriggerPattern();
+ if(partialTriggerPattern != null && partialTriggerPattern.trim().length()>0)
{
- partialTriggerId = st.nextToken();
- partialTriggerComponent = uiComponent.findComponent(partialTriggerId);
- if (partialTriggerComponent != null)
- {
- partialTriggerClientId = partialTriggerComponent.getClientId(facesContext);
- writeInlineScript(facesContext, uiComponent,
+ writeInlineScript(facesContext, uiComponent,
"document.getElementById('" +
fi.getFormName() +
"').myFacesPPRCtrl." +
- ADD_PARTIAL_TRIGGER_FUNCTION +
+ ADD_PARTIAL_TRIGGER_PATTERN_FUNCTION +
"('" +
- partialTriggerClientId +
+ partialTriggerPattern +
"','" +
clientId +
"');");
- }
- else
+ }
+
+ String inlineLoadingMessage =((PPRPanelGroup) uiComponent).getInlineLoadingMessage();
+
+ if(inlineLoadingMessage!= null && inlineLoadingMessage.trim().length()>0)
+ {
+ writeInlineScript(facesContext, uiComponent,
+ "document.getElementById('" +
+ fi.getFormName() +
+ "').myFacesPPRCtrl." +
+ ADD_INLINE_LOADING_MESSAGE_FUNCTION +
+ "('" +
+ inlineLoadingMessage +
+ "','" +
+ clientId +
+ "');");
+ }
+
+ if(partialTriggers!= null && partialTriggers.trim().length()>0)
+ {
+ StringTokenizer st = new StringTokenizer(partialTriggers, ",; ", false);
+ while (st.hasMoreTokens())
{
- if (log.isDebugEnabled())
+ partialTriggerId = st.nextToken();
+ partialTriggerComponent = uiComponent.findComponent(partialTriggerId);
+ if(partialTriggerComponent == null)
+ {
+ partialTriggerComponent = FacesContext.getCurrentInstance().getViewRoot().findComponent(partialTriggerId);
+ }
+ if (partialTriggerComponent != null)
+ {
+ partialTriggerClientId = partialTriggerComponent.getClientId(facesContext);
+ writeInlineScript(facesContext, uiComponent,
+ "document.getElementById('" +
+ fi.getFormName() +
+ "').myFacesPPRCtrl." +
+ ADD_PARTIAL_TRIGGER_FUNCTION +
+ "('" +
+ partialTriggerClientId +
+ "','" +
+ clientId +
+ "');");
+ }
+ else
{
- log.debug("PPRPanelGroupRenderer Component with id " + partialTriggerId + " not found!");
+ if (log.isDebugEnabled())
+ {
+ log.debug("PPRPanelGroupRenderer Component with id " + partialTriggerId + " not found!");
+ }
}
}
}
@@ -148,8 +190,10 @@
{
PPRPanelGroup pprGroup = (PPRPanelGroup) uiComponent;
- if (pprGroup.getPartialTriggers() != null &&
- pprGroup.getPartialTriggers().length() > 0)
+ if ((pprGroup.getPartialTriggers() != null &&
+ pprGroup.getPartialTriggers().length() > 0) ||
+ (pprGroup.getPartialTriggerPattern() != null &&
+ pprGroup.getPartialTriggerPattern().length() > 0))
{
encodeJavaScript(facesContext, pprGroup);
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupTag.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupTag.java?view=diff&rev=450600&r1=450599&r2=450600
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupTag.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupTag.java Wed Sep 27 15:20:43 2006
@@ -25,6 +25,10 @@
public class PPRPanelGroupTag extends HtmlPanelGroupTag
{
private String _partialTriggers;
+
+ private String _partialTriggerPattern;
+
+ private String _inlineLoadingMessage;
public String getComponentType()
{
@@ -47,6 +51,8 @@
super.setProperties(component);
setStringProperty(component, "partialTriggers", _partialTriggers);
+ setStringProperty(component, "partialTriggerPattern", _partialTriggerPattern);
+ setStringProperty(component, "inlineLoadingMessage", _inlineLoadingMessage);
}
public String getPartialTriggers()
@@ -58,5 +64,23 @@
{
this._partialTriggers = partialTriggers;
}
+
+ public String getPartialTriggerPattern() {
+ return _partialTriggerPattern;
+ }
+
+ public void setPartialTriggerPattern(String triggerPattern) {
+ _partialTriggerPattern = triggerPattern;
+ }
+
+ public String getInlineLoadingMessage() {
+ return _inlineLoadingMessage;
+ }
+
+ public void setInlineLoadingMessage(String loadingMessage) {
+ _inlineLoadingMessage = loadingMessage;
+ }
+
+
}
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?view=diff&rev=450600&r1=450599&r2=450600
==============================================================================
--- 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 Wed Sep 27 15:20:43 2006
@@ -103,18 +103,24 @@
{
clientId = st.nextToken();
component = viewRoot.findComponent(clientId);
- out.print("<component id=\"" +
- component.getClientId(context) +
- "\"><![CDATA[");
- try
- {
- RendererUtils.renderChild(context, component);
+ if(component!=null) {
+ out.print("<component id=\"" +
+ component.getClientId(context) +
+ "\"><![CDATA[");
+ try
+ {
+ RendererUtils.renderChildren(context, component);
+ }
+ catch (IOException e)
+ {
+ throw new FacesException(e);
+ }
+ out.print("]]></component>");
}
- catch (IOException e)
+ else
{
- throw new FacesException(e);
+ log.debug("PPRPhaseListener component with id" + clientId + "not found!");
}
- out.print("]]></component>");
}
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ppr/resource/ppr.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ppr/resource/ppr.js?view=diff&rev=450600&r1=450599&r2=450600
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ppr/resource/ppr.js (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ppr/resource/ppr.js Wed Sep 27 15:20:43 2006
@@ -21,23 +21,46 @@
org.apache.myfaces.PPRCtrl = function(formId)
{
- this.partialTriggers = new Array;
+ if(typeof window.myFacesPartialTriggers == "undefined")
+ {
+ window.myFacesPartialTriggers = new Array;
+ }
+ if(typeof window.myFacesPartialTriggerPatterns == "undefined")
+ {
+ window.myFacesPartialTriggerPatterns = new Array;
+ }
+ if(typeof window.myFacesInlineLoadingMessage == "undefined")
+ {
+ window.myFacesInlineLoadingMessage = new Array;
+ }
this.replaceFormSubmitFunction(formId);
this.addButtonOnClickHandlers();
}
+//Method for JSF Components to register Regular Expressions for partial update triggering
+
+org.apache.myfaces.PPRCtrl.prototype.addInlineLoadingMessage= function(message, refreshZoneId)
+{
+ window.myFacesInlineLoadingMessage[refreshZoneId] = message;
+};
+
+org.apache.myfaces.PPRCtrl.prototype.addPartialTriggerPattern= function(pattern, refreshZoneId)
+{
+ window.myFacesPartialTriggerPatterns[refreshZoneId] = pattern;
+};
+
//Method for JSF Components to register their Partial Triggers
org.apache.myfaces.PPRCtrl.prototype.addPartialTrigger= function(inputElementId, refreshZoneId)
{
- if (this.partialTriggers[inputElementId] === undefined)
+ if (window.myFacesPartialTriggers[inputElementId] === undefined)
{
- this.partialTriggers[inputElementId] = refreshZoneId;
+ window.myFacesPartialTriggers[inputElementId] = refreshZoneId;
}
else
{
- this.partialTriggers[inputElementId] =
- this.partialTriggers[inputElementId] +
+ window.myFacesPartialTriggers[inputElementId] =
+ window.myFacesPartialTriggers[inputElementId] +
"," +
refreshZoneId;
}
@@ -49,15 +72,17 @@
{
if(type == "load")
{
- var componentUpdates = data.getElementsByTagName("component");
- var componentUpdate = null;
- var domElement = null;
- for (var i = 0; i < componentUpdates.length; i++)
- {
- componentUpdate = componentUpdates[i];
- domElement = document.getElementById(componentUpdate.getAttribute("id"));
- domElement.innerHTML = componentUpdate.firstChild.data;
- }
+ var componentUpdates = data.getElementsByTagName("component");
+ var componentUpdate = null;
+ var domElement = null;
+ for (var i = 0; i < componentUpdates.length; i++)
+ {
+ componentUpdate = componentUpdates[i];
+ domElement = document.getElementById(componentUpdate.getAttribute("id"));
+ domElement.innerHTML = componentUpdate.firstChild.data;
+ }
+ //ensure that new buttons in the ParitalUpdate also have onclick-handlers
+ this.formNode.myFacesPPRCtrl.addButtonOnClickHandlers();
}
else
{
@@ -70,11 +95,36 @@
org.apache.myfaces.PPRCtrl.prototype.ajaxSubmitFunction = function(triggerElement)
{
- if(typeof triggerElement != "undefined")
+ if(typeof triggerElement != "undefined" ||
+ typeof this.form.elements[this.form.name +':'+'_idcl'] != "undefined")
{
- var triggeredComponents = this.getTriggeredComponents(triggerElement);
+ var triggerId;
+ var content=new Array;
+ if(typeof triggerElement != "undefined")
+ {
+ triggerId=triggerElement.id;
+ var formName = this.form.name;
+ if (triggerElement.tagName.toLowerCase() == "input" &&
+ (triggerElement.type.toLowerCase() == "submit" ||
+ triggerElement.type.toLowerCase() == "image")
+ )
+ {
+ content[triggerElement.name]=triggerElement.value;
+ }
+ else
+ {
+ oamSetHiddenInput(formName,formName +':'+'_idcl',triggerElement.id);
+ }
+ }
+ else
+ {
+ triggerId=this.form.elements[this.form.name +':'+'_idcl'].value;
+ }
+
+ var triggeredComponents = this.getTriggeredComponents(triggerId);
if(triggeredComponents !=null)
{
+ this.displayInlineLoadingMessages(triggeredComponents);
var requestUri = "";
var formAction = this.form.attributes["action"];
if(formAction == null)
@@ -86,8 +136,7 @@
requestUri = formAction.nodeValue;
}
- var content=new Array;
- content[triggerElement.name]=triggerElement.value;
+
content["org.apache.myfaces.PPRCtrl.triggeredComponents"]=triggeredComponents;
content["org.apache.myfaces.PPRCtrl.ajaxRequest"]="true";
dojo.io.bind({
@@ -113,6 +162,30 @@
}
}
+//This Method replaces the content of the PPRPanelGroups which have
+//an inline-loading-message set with the loading message
+
+org.apache.myfaces.PPRCtrl.prototype.displayInlineLoadingMessages = function(components)
+{
+ if(typeof components != "string")
+ {
+ return;
+ }
+ var componentIds = components.split(',');
+ var domElement = null;
+ for (index in componentIds)
+ {
+ if(typeof window.myFacesInlineLoadingMessage[componentIds[index]] != "undefined")
+ {
+ domElement = document.getElementById(componentIds[index]);
+ if(domElement != null)
+ {
+ domElement.innerHTML = window.myFacesInlineLoadingMessage[componentIds[index]];
+ }
+ }
+ }
+}
+
//This Method replaces the mainform Submitfunciton to call AJAX submit
org.apache.myfaces.PPRCtrl.prototype.formSubmitReplacement = function(triggeredElement)
@@ -161,10 +234,13 @@
for (var i = 0; i < formButtons.length; i++)
{
var button = formButtons[i];
+ if(typeof button.onclick_orig == "undefined")
+ {
button.onclick_orig = button.onclick;
button.onclick = this.buttonOnClickHandler;
button.myFacesPPRCtrl=this;
- //dojo.event.connect(button,"onClick",this,"buttonOnClickHandler");
+ }
+
}
}
@@ -184,14 +260,45 @@
//Based on the Component which triggerd the submit this Method returns a comma-seperated
//list of component-ids which are to be updated via an AJAX call
-org.apache.myfaces.PPRCtrl.prototype.getTriggeredComponents = function(triggerElement)
-{
- if (typeof triggerElement != "undefined")
+
+org.apache.myfaces.PPRCtrl.prototype.getTriggeredComponents = function(triggerId)
+{
+ if (typeof triggerId != "undefined")
{
- if (typeof this.partialTriggers[triggerElement.id] != "undefined")
+ var retval = null;
+ if (typeof window.myFacesPartialTriggers[triggerId] != "undefined")
{
- return this.partialTriggers[triggerElement.id];
+ retval = window.myFacesPartialTriggers[triggerId];
}
+
+ for (refreshZoneId in window.myFacesPartialTriggerPatterns)
+ {
+ if(this.isMatchingPattern(window.myFacesPartialTriggerPatterns[refreshZoneId],triggerId) &&
+ typeof refreshZoneId == "string" )
+ if(retval == null || retval == "")
+ {
+ retval = refreshZoneId;
+ }
+ else
+ {
+ retval += "," + refreshZoneId;
+ }
+ }
+ return retval;
}
return null;
-};
\ No newline at end of file
+};
+
+org.apache.myfaces.PPRCtrl.prototype.isMatchingPattern = function(pattern,stringToMatch)
+{
+ if(typeof pattern != "string")
+ {
+ return false;
+ }
+ if(typeof stringToMatch != "string")
+ {
+ return false;
+ }
+ var expr = new RegExp(pattern);
+ return expr.test(stringToMatch);
+}
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?view=diff&rev=450600&r1=450599&r2=450600
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld Wed Sep 27 15:20:43 2006
@@ -1185,7 +1185,7 @@
&ui_select_items_attributes;
&select_items_attributes;
</tag>
- <!-- inputSuggest -->
+ <!-- Partial Page Rendering -->
<tag>
<name>pprPanelGroup</name>
<tag-class>org.apache.myfaces.custom.ppr.PPRPanelGroupTag</tag-class>
@@ -1197,9 +1197,24 @@
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<type>java.lang.String</type>
- <description>Comma or Space seperated List of ids from ui_command-items which trigger
- a partial update of this PanelGroup</description>
+ <description>Comma or Space seperated List of ids from ui_command-items which trigger a partial update of this PanelGroup</description>
</attribute>
+ <attribute>
+ <name>partialTriggerPattern</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.String</type>
+ <description>Regular Expression If the client Id of a submitting Component matches this Pattern the corresponding pprPanelGroup is updated via AJAX</description>
+ </attribute>
+ <attribute>
+ <name>inlineLoadingMessage</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.String</type>
+ <description>If this attribute is set the content of the PPRPanelGroup will be replaced by the provided
+ Loading-Message during partial update</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?view=diff&rev=450600&r1=450599&r2=450600
==============================================================================
--- 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 Wed Sep 27 15:20:43 2006
@@ -1,5 +1,7 @@
package org.apache.myfaces.examples.ppr;
+import javax.faces.event.ValueChangeEvent;
+
/**
* Created by IntelliJ IDEA.
* User: Ernst
@@ -10,6 +12,14 @@
public class PPRExampleBean
{
private String _textField;
+
+ private String _message;
+
+ private Boolean _partialUpdateConfiguredButton;
+
+ private Boolean _partialChangeCheckBox=Boolean.FALSE;
+
+ private String _partialChangeDropDown;
public String getTextField()
{
@@ -20,4 +30,53 @@
{
this._textField = textField;
}
+
+ public Boolean getPartialUpdateConfiguredButton() {
+ return _partialUpdateConfiguredButton;
+ }
+
+ public void setPartialUpdateConfiguredButton(
+ Boolean partialUpdateConfiguredButton) {
+ this._partialUpdateConfiguredButton = partialUpdateConfiguredButton;
+ }
+
+ public String testAction() {
+ setMessage("testAction called");
+ return "test";
+ }
+
+ public void testValueChangeListener(ValueChangeEvent event){
+
+ _message = "Value Change to: ";
+ if(event.getNewValue()!=null)
+ {
+ _message += event.getNewValue().toString();
+ }
+ }
+
+ public Boolean getPartialChangeCheckBox() {
+ return _partialChangeCheckBox;
+ }
+
+ public void setPartialChangeCheckBox(Boolean changeCheckBox) {
+ _partialChangeCheckBox = changeCheckBox;
+ }
+
+ public String getPartialChangeDropDown() {
+ return _partialChangeDropDown;
+ }
+
+ public void setPartialChangeDropDown(String changeDropDown) {
+ _partialChangeDropDown = changeDropDown;
+ }
+
+ public String getMessage() {
+ return _message;
+ }
+
+ public void setMessage(String message) {
+ this._message = message;
+ }
+
+
}
Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroup.jsp
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroup.jsp?view=diff&rev=450600&r1=450599&r2=450600
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroup.jsp (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroup.jsp Wed Sep 27 15:20:43 2006
@@ -1,17 +1,36 @@
-<%@ 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" %>
+<%@ 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"%>
+<!--
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed 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 Example </h1>
-<span id="cnt">0</span> seconds since last page refresh.
+<h1>PPR Example</h1>
+<span id="cnt">0</span>
+seconds since last page refresh.
<script>
var sec=0;
function counter(){
@@ -23,29 +42,89 @@
<f:view>
- <h:form id="mainform" >
-
-
-<t:messages id="messageList" styleClass="error" showDetail="true" summaryFormat="{0} "/>
- <h:inputText value="#{pprExampleBean.textField}" />
+ <h:form id="mainform">
- <h:commandButton id="pprSubmit1" value="PPR Submit" />
- <h:commandButton id="pprSubmit2" value="2 nd PPR Submit" />
- <h:commandButton id="normalSubmit" value="Submit" />
- <s:pprPanelGroup id="ppr1" partialTriggers="mainform:pprSubmit1,mainform:pprSubmit2">
- <h:outputText value="#{pprExampleBean.textField}" />
- </s:pprPanelGroup>
+ <t:messages id="messageList" styleClass="error" showDetail="true"
+ summaryFormat="{0} " />
+
+ <t:saveState value="#{pprExampleBean.partialChangeDropDown}" />
+ <t:saveState value="#{pprExampleBean.partialChangeCheckBox}" />
+
+ <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="pprSubmit1" value="PPR Submit" />
+
+ <h:outputText value="Click this for update:" />
+ <h:commandButton id="configuredSubmit" value="Configured Submit" />
+
+ <h:outputText value="update first group partialy:" />
+ <h:selectBooleanCheckbox value="#{pprExampleBean.partialUpdateConfiguredButton}"
+ onclick="oamSubmitForm('mainform',this.id);"/>
+
+ <h:outputText value="Click this for normal update with action:" />
+ <h:commandButton id="normalSubmit" value="testAction" action="#{pprExampleBean.testAction}"/>
+
+ <h:outputText value="Click this for partial update with action:" />
+ <h:commandButton id="partialAction" value="partial testAction" action="#{pprExampleBean.testAction}"/>
+
+ <h:outputText value="partialy submit by change:" />
+ <h:selectOneMenu id="partialDropDown" onchange="submit(this);"
+ value="#{pprExampleBean.partialChangeDropDown}"
+ valueChangeListener="#{pprExampleBean.testValueChangeListener}">
+ <f:selectItem itemLabel="test1" itemValue="test1"/>
+ <f:selectItem itemLabel="test2" itemValue="test2"/>
+ <f:selectItem itemLabel="test3" itemValue="test3"/>
+ </h:selectOneMenu>
+
+ <h:outputText value="partialy submit by change:" />
+ <h:selectBooleanCheckbox id="partialCheckBox"
+ value="#{pprExampleBean.partialChangeCheckBox}"
+ valueChangeListener="#{pprExampleBean.testValueChangeListener}"
+ onclick="oamSubmitForm('mainform',this.id);"/>
+
+ <h:outputText value="Command Link partial update:" />
+ <t:commandLink id="link" >
+ <h:outputText value="Click here" />
+ </t:commandLink>
+
+
+ <h:outputText value="First PPRPanelGroup:" />
+ <s:pprPanelGroup id="ppr1"
+ partialTriggers="secondform:pprSubmit3,partialCheckBox,partialDropDown,partialAction,link,pprSubmit1#{pprExampleBean.partialUpdateConfiguredButton ? ',configuredSubmit' : ''}">
+ <h:outputText value="#{pprExampleBean.textField}" />
+ </s:pprPanelGroup>
+ </h:panelGrid>
+ </h:form>
+ <h:form id="secondform">
+ <h:panelGrid columns="2">
+ <h:outputText value="Second PPRPanelGroup:" />
+ <s:pprPanelGroup id="ppr2"
+ partialTriggers="mainform:partialCheckBox,mainform:partialDropDown,mainform:partialAction,mainform:link,mainform:pprSubmit1">
+ <h:commandButton id="pprSubmit3" value="#{pprExampleBean.textField}" />
+ </s:pprPanelGroup>
+
+ <h:outputText value="Message:" />
+ <s:pprPanelGroup id="ppr3" partialTriggerPattern="mainform:.*">
+ <h:outputText value="#{pprExampleBean.message}" />
+ </s:pprPanelGroup>
+
+ <h:outputText value="Pattern Matching PPRPanelGroup:" />
+ <s:pprPanelGroup id="ppr4" partialTriggerPattern="mainform:.*"
+ inlineLoadingMessage="Loading...">
+ <h:outputText value="#{pprExampleBean.textField}" />
+ </s:pprPanelGroup>
+ </h:panelGrid>
- <s:pprPanelGroup id="ppr2" partialTriggers="mainform:pprSubmit1,mainform:pprSubmit2">
- <h:outputText value="#{pprExampleBean.textField}" />
- </s:pprPanelGroup>
+ </h:form>
- </h:form>
</f:view>
-<%@include file="inc/page_footer.jsp" %>
+<%@include file="inc/page_footer.jsp"%>
</body>