You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ca...@apache.org on 2007/05/20 16:56:07 UTC
svn commit: r539883 - in /myfaces/tomahawk/trunk/sandbox:
core/src/main/java/org/apache/myfaces/custom/ppr/ examples/src/main/webapp/
Author: cagatay
Date: Sun May 20 07:56:06 2007
New Revision: 539883
URL: http://svn.apache.org/viewvc?view=rev&rev=539883
Log:
Fix for TOMAHAWK-969, fixes ppr issue when trigger button comes after the last pprpanelgroup, Thanks to Ernst Fastl for providing the patch
Modified:
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/PPRPhaseListener.java
myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroupPartialTriggers.jsp
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=539883&r1=539882&r2=539883
==============================================================================
--- 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 Sun May 20 07:56:06 2007
@@ -50,8 +50,6 @@
private static Log log = LogFactory.getLog(PPRPanelGroupRenderer.class);
- 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";
@@ -67,8 +65,9 @@
final ExternalContext externalContext = facesContext.getExternalContext();
final Map requestMap = externalContext.getRequestMap();
-
- if (requestMap.containsKey(PPR_RESPONSE)) {
+
+ //Do not render the JavaScript if answering to a PPR response
+ if (requestMap.containsKey(PPR_RESPONSE)) {
return;
}
@@ -85,13 +84,18 @@
DojoUtils.addMainInclude(facesContext, pprGroup, javascriptLocation, new DojoConfig());
DojoUtils.addRequire(facesContext, pprGroup, "dojo.io.*");
DojoUtils.addRequire(facesContext, pprGroup, "dojo.event.*");
- addResource.addInlineScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, MY_FACES_PPR_INITIALIZED);
-
addResource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, PPRPanelGroup.class, PPR_JS_FILE);
}
StringBuffer script = new StringBuffer();
- final String formName = fi.getFormName();
+
+ // all JS is put inside a function passed to dojoOnLoad
+ //this is necessary in order to be able to replace all button onClick handlers
+
+ script.append("dojo.addOnLoad( function(){ ");
+
+
+ final String formName = fi.getFormName();
String pprCtrlReference = "dojo.byId('" + formName + "').myFacesPPRCtrl";
@@ -105,17 +109,13 @@
script.append(pprCtrlReference + ".registerOnSubmitInterceptor();");
}
- renderInlineScript(facesContext, pprGroup, script.toString());
}
String clientId = pprGroup.getClientId(facesContext);
if (pprGroup.getPeriodicalUpdate() != null) {
- script = new StringBuffer();
script.append(pprCtrlReference + ".startPeriodicalUpdate(" + pprGroup.getPeriodicalUpdate() + ",'" + clientId
+ "');");
-
- renderInlineScript(facesContext, pprGroup, script.toString());
}
String partialTriggerId;
@@ -126,22 +126,15 @@
String partialTriggerPattern = pprGroup.getPartialTriggerPattern();
if (partialTriggerPattern != null && partialTriggerPattern.trim().length() > 0) {
- script = new StringBuffer();
script.append(pprCtrlReference + "." + ADD_PARTIAL_TRIGGER_PATTERN_FUNCTION + "('" + partialTriggerPattern
+ "','" + clientId + "');");
-
- renderInlineScript(facesContext, pprGroup, script.toString());
}
String inlineLoadingMessage = pprGroup.getInlineLoadingMessage();
if (inlineLoadingMessage != null && inlineLoadingMessage.trim().length() > 0) {
- script = new StringBuffer();
script.append(pprCtrlReference + "." + ADD_INLINE_LOADING_MESSAGE_FUNCTION + "('" + inlineLoadingMessage + "','"
+ clientId + "');");
-
- renderInlineScript(facesContext, pprGroup, script.toString());
-
}
if (partialTriggers != null && partialTriggers.trim().length() > 0) {
@@ -154,12 +147,8 @@
}
if (partialTriggerComponent != null) {
partialTriggerClientId = partialTriggerComponent.getClientId(facesContext);
- script = new StringBuffer();
script.append(pprCtrlReference + "." + ADD_PARTIAL_TRIGGER_FUNCTION + "('" + partialTriggerClientId + "','"
+ clientId + "');");
-
- renderInlineScript(facesContext, pprGroup, script.toString());
-
} else {
if (log.isDebugEnabled()) {
log.debug("PPRPanelGroupRenderer Component with id " + partialTriggerId + " not found!");
@@ -167,7 +156,11 @@
}
}
}
- }
+
+ //closing the dojo.addOnLoad call
+ script.append("});");
+ renderInlineScript(facesContext, pprGroup, script.toString());
+ }
public void encodeBegin(FacesContext facesContext, UIComponent uiComponent) throws IOException {
if (uiComponent.getId() == null || uiComponent.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX)) {
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=539883&r1=539882&r2=539883
==============================================================================
--- 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 Sun May 20 07:56:06 2007
@@ -70,7 +70,10 @@
}
private void processPartialPageRequest(FacesContext context, final ExternalContext externalContext, Map externalRequestMap) {
- externalContext.getRequestMap().put(PPRPanelGroupRenderer.PPR_RESPONSE, Boolean.TRUE);
+ //If the PhaseListener is invoked the second time do nothing
+ if(externalContext.getRequestMap().containsKey(PPRPanelGroupRenderer.PPR_RESPONSE))
+ return;
+ externalContext.getRequestMap().put(PPRPanelGroupRenderer.PPR_RESPONSE, Boolean.TRUE);
ServletResponse response = (ServletResponse) externalContext.getResponse();
ServletRequest request = (ServletRequest) externalContext.getRequest();
Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroupPartialTriggers.jsp
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroupPartialTriggers.jsp?view=diff&rev=539883&r1=539882&r2=539883
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroupPartialTriggers.jsp (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pprPanelGroupPartialTriggers.jsp Sun May 20 07:56:06 2007
@@ -51,16 +51,15 @@
<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" />
-
+
<h:outputText value="Entered text will appear here:" />
<s:pprPanelGroup id="ppr1"
partialTriggers="pprSubmitButton">
<h:outputText value="#{pprExampleBean.textField}" />
</s:pprPanelGroup>
+ <h:outputText value="partial update button:" />
+ <h:commandButton id="pprSubmitButton" value="PPR Submit" />
</h:panelGrid>
<s:fieldset legend="about this example">
@@ -85,5 +84,6 @@
</body>
</html>
+