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 2008/01/22 16:12:20 UTC
svn commit: r614216 - 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/webapp/
Author: gmuellan
Date: Tue Jan 22 07:12:18 2008
New Revision: 614216
URL: http://svn.apache.org/viewvc?rev=614216&view=rev
Log:
added attribute "waitBeforePeriodicalUpdate" to pprPanelGroup
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/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/webapp/pprPanelGroupPeriodicalUpdate.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?rev=614216&r1=614215&r2=614216&view=diff
==============================================================================
--- 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 Tue Jan 22 07:12:18 2008
@@ -46,6 +46,8 @@
private String _excludeFromStoppingPeriodicalUpdate;
+ private Integer _waitBeforePeriodicalUpdate = new Integer(2000);
+
private String _partialTriggerPattern;
private String _inlineLoadingMessage;
@@ -139,6 +141,21 @@
_excludeFromStoppingPeriodicalUpdate = excludeFromStoppingPeriodicalUpdate;
}
+ public Integer getWaitBeforePeriodicalUpdate()
+ {
+ if(_waitBeforePeriodicalUpdate != null)
+ {
+ return _waitBeforePeriodicalUpdate;
+ }
+ ValueBinding vb = getValueBinding("waitBeforePeriodicalUpdate");
+ return (vb != null) ? (Integer) vb.getValue(getFacesContext()) : null;
+ }
+
+ public void setWaitBeforePeriodicalUpdate(Integer waitBeforePeriodicalUpdate)
+ {
+ _waitBeforePeriodicalUpdate = waitBeforePeriodicalUpdate;
+ }
+
public String getInlineLoadingMessage()
{
if(_inlineLoadingMessage != null)
@@ -195,11 +212,12 @@
_showDebugMessages = (Boolean) values[5];
_stateUpdate = (Boolean) values[6];
_excludeFromStoppingPeriodicalUpdate = (String) values[7];
+ _waitBeforePeriodicalUpdate = (Integer) values[8];
}
public Object saveState(FacesContext context)
{
- Object[] values = new Object[8];
+ Object[] values = new Object[9];
values[0] = super.saveState(context);
values[1] = _partialTriggers;
values[2] = _partialTriggerPattern;
@@ -208,6 +226,7 @@
values[5] = _showDebugMessages;
values[6] = _stateUpdate;
values[7] = _excludeFromStoppingPeriodicalUpdate;
+ values[8] = _waitBeforePeriodicalUpdate;
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?rev=614216&r1=614215&r2=614216&view=diff
==============================================================================
--- 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 Tue Jan 22 07:12:18 2008
@@ -251,7 +251,12 @@
// update
if(periodicalTriggers == null || periodicalTriggers.trim().length() <= 0)
{
- script.append(pprCtrlReference + ".startPeriodicalUpdate(" + pprGroup.getPeriodicalUpdate() + ",'" + clientId + "');");
+ Integer wait = null;
+ if(pprGroup.getExcludeFromStoppingPeriodicalUpdate() != null)
+ {
+ wait = pprGroup.getWaitBeforePeriodicalUpdate();
+ }
+ script.append(pprCtrlReference + ".startPeriodicalUpdate(" + pprGroup.getPeriodicalUpdate() + ",'" + clientId + "', " + wait + ");");
}
// Otherwise start it when the trigger happens
else
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?rev=614216&r1=614215&r2=614216&view=diff
==============================================================================
--- 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 Tue Jan 22 07:12:18 2008
@@ -43,6 +43,8 @@
private String _stateUpdate;
+ private String _waitBeforePeriodicalUpdate;
+
public String getComponentType()
{
return PPRPanelGroup.COMPONENT_TYPE;
@@ -62,6 +64,7 @@
_showDebugMessages = null;
_stateUpdate = null;
_excludeFromStoppingPeriodicalUpdate = null;
+ _waitBeforePeriodicalUpdate = null;
}
protected void setProperties(UIComponent component)
@@ -74,6 +77,7 @@
setIntegerProperty(component, "periodicalUpdate", _periodicalUpdate);
setStringProperty(component, "periodicalTriggers", _periodicalTriggers);
setStringProperty(component, "excludeFromStoppingPeriodicalUpdate", _excludeFromStoppingPeriodicalUpdate);
+ setIntegerProperty(component, "waitBeforePeriodicalUpdate", _waitBeforePeriodicalUpdate);
setBooleanProperty(component, "showDebugMessages", _showDebugMessages);
setBooleanProperty(component, "stateUpdate", _stateUpdate);
}
@@ -136,5 +140,10 @@
public void setExcludeFromStoppingPeriodicalUpdate(String excludeFromStoppingPeriodicalUpdate)
{
_excludeFromStoppingPeriodicalUpdate = excludeFromStoppingPeriodicalUpdate;
+ }
+
+ public void setWaitBeforePeriodicalUpdate(String waitBeforePeriodicalUpdate)
+ {
+ _waitBeforePeriodicalUpdate = waitBeforePeriodicalUpdate;
}
}
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?rev=614216&r1=614215&r2=614216&view=diff
==============================================================================
--- 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 Tue Jan 22 07:12:18 2008
@@ -29,6 +29,8 @@
this.showDebugMessages = showDebugMessages;
this.stateUpdate = stateUpdate;
this.linkIdRegexToExclude = '';
+ this.waitBeforePeriodicalUpdate = null;
+ this.periodicalRegexLinkFound = false;
this.subFormId = new Array();
@@ -212,8 +214,6 @@
returnValue = true;
}
- var linkFound = false;
-
if(ppr.linkIdRegexToExclude != '')
{
for(var i = 0; i < document.forms.length; i++)
@@ -224,18 +224,12 @@
if(clickedLink && clickedLink.value.match(ppr.linkIdRegexToExclude))
{
- ppr.blockPeriodicalUpdateDuringPost = false;
- linkFound = true;
+ ppr.periodicalRegexLinkFound = true;
break;
}
}
}
-
- if(!linkFound)
- {
- ppr.blockPeriodicalUpdateDuringPost = true;
- }
-
+ ppr.blockPeriodicalUpdateDuringPost = true;
return returnValue;
}
}
@@ -250,22 +244,33 @@
// init function of automatically partial page refresh
-org.apache.myfaces.PPRCtrl.prototype.startPeriodicalUpdate = function(refreshTimeout, refreshZoneId)
+org.apache.myfaces.PPRCtrl.prototype.startPeriodicalUpdate = function(refreshTimeout, refreshZoneId, waitBeforeUpdate)
{
var ppr = this;
- setTimeout(function(){ppr.doPeriodicalUpdate(refreshTimeout, refreshZoneId)}, refreshTimeout);
+ ppr.waitBeforePeriodicalUpdate = waitBeforeUpdate;
+ setTimeout(function(){ppr.doPeriodicalUpdate(refreshTimeout, refreshZoneId)}, refreshTimeout);
};
// periodically called when updating automatically
org.apache.myfaces.PPRCtrl.prototype.doPeriodicalUpdate = function(refreshTimeout, refreshZoneId)
{
- if(!this.blockPeriodicalUpdateDuringPost)
+ var content = new Array;
+ content["org.apache.myfaces.PPRCtrl.triggeredComponents"] = refreshZoneId;
+
+ if(!this.blockPeriodicalUpdateDuringPost)
{
- var content = new Array;
- content["org.apache.myfaces.PPRCtrl.triggeredComponents"] = refreshZoneId;
this.doAjaxSubmit(content, refreshTimeout, refreshZoneId);
}
+ else if(this.periodicalRegexLinkFound)
+ {
+ var ppr = this;
+ setTimeout(function() {
+ ppr.blockPeriodicalUpdateDuringPost = false;
+ ppr.periodicalRegexLinkFound = false;
+ ppr.doAjaxSubmit(content, refreshTimeout, refreshZoneId);
+ }, ppr.waitBeforePeriodicalUpdate)
+ }
};
//Callback Method which handles the AJAX Response
@@ -425,7 +430,7 @@
}
content["org.apache.myfaces.PPRCtrl.ajaxRequest"]="true";
- dojo.io.bind({
+ dojo.io.bind({
url : requestUri,
method : "post",
useCache: false,
@@ -436,11 +441,12 @@
formNode: this.form
});
- if(refreshTimeout && !this.blockPeriodicalUpdateDuringPost)
+ if(refreshTimeout)
{
- window.setTimeout(function() {
- ppr.doPeriodicalUpdate(refreshTimeout, refreshZoneId);
- }, refreshTimeout)
+ if(!this.blockPeriodicalUpdateDuringPost || !this.periodicalRegexLinkFound)
+ {
+ setTimeout(function() { ppr.doPeriodicalUpdate(refreshTimeout, refreshZoneId); }, refreshTimeout);
+ }
}
};
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=614216&r1=614215&r2=614216&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 Tue Jan 22 07:12:18 2008
@@ -1310,9 +1310,26 @@
<name>excludeFromStoppingPeriodicalUpdate</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
- <description>Regular expression of link-client-ids for which the periodical update should not be stopped.
- Normally when a link is clicked during periodical update, the update is stopped in order to prevent the server from getting
- unexpected requests. This behaviour may be unwanted e.g. in case of opening new windows with a link.
+ <description>Normally when a link is clicked during periodical update, the update is stopped in order to prevent the server from getting
+ unexpected requests. For any POST-request this is the wanted behaviour because the screen is completely refreshed and periodical
+ updating starts again after the response.
+ However, this behaviour may be unwanted e.g. in case of opening a new window with a link where the main screen should stay refreshed.
+ This attribute takes a regular expression of link-client-ids for which the periodical update should not be stopped.
+
+ If this value is given, there will be a default timeout of 2000 milliseconds before any periodical
+ update will start again. This is done as mentioned before in order to prevent the server from getting unexpected requests.
+ This timeout can be influenced via the waitBeforePeriodicalUpdate attribute.
+ </description>
+ </attribute>
+ <attribute>
+ <name>waitBeforePeriodicalUpdate</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <description>This attribute only works in combination with the excludeFromStoppingPeriodicalUpdate attribute. The value
+ in milliseconds tells the periodical update mechanism to stop for the given amount of time after clicking a link, specified by
+ the excludeFromStoppingPeriodicalUpdate attribute.
+
+ The default value is 2000 milliseconds.
</description>
</attribute>
<attribute>
Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroupPeriodicalUpdate.jsp
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroupPeriodicalUpdate.jsp?rev=614216&r1=614215&r2=614216&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroupPeriodicalUpdate.jsp (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroupPeriodicalUpdate.jsp Tue Jan 22 07:12:18 2008
@@ -102,8 +102,9 @@
<h:panelGrid>
<h:outputText value="List of updated addresses after 5000ms: (another ppr-group)"/>
- <s:pprPanelGroup id="periodicalUpdatedArea2" periodicalUpdate="2000" showDebugMessages="false"
- stateUpdate="false" excludeFromStoppingPeriodicalUpdate=".dontBlock">
+ <s:pprPanelGroup id="periodicalUpdatedArea2" periodicalUpdate="5000" showDebugMessages="false"
+ stateUpdate="false" excludeFromStoppingPeriodicalUpdate=".dontBlock"
+ waitBeforePeriodicalUpdate="5000">
<t:dataTable var="address" value="#{pprExampleBean.periodicalUpdatedValues}">
<t:column>
<f:facet name="header">
@@ -120,10 +121,10 @@
</t:dataTable>
</s:pprPanelGroup>
</h:panelGrid>
-
+
<h:commandButton action="#{pprExampleBean.doTimeConsumingStuff}" value="blocking of auto refresh"/>
- <h:commandLink action="#{pprExampleBean.doTimeConsumingStuff}" value="new window, blocking should not occur" id="dontBlock"
+ <h:commandLink action="#{pprExampleBean.doTimeConsumingStuff}" value="new window, blocking only occurs for 5 seconds" id="dontBlock"
target="_blank"/>
<h:commandLink action="#{pprExampleBean.doTimeConsumingStuff}" value="blocking should not occur" id="second_dontBlock"/>