myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ima...@apache.org
Subject svn commit: r643368 - in /myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr: PPRPanelGroup.java PPRSubmitRenderer.java PPRSupport.java
Date Tue, 01 Apr 2008 11:58:03 GMT
Author: imario
Date: Tue Apr  1 04:57:05 2008
New Revision: 643368

URL: http://svn.apache.org/viewvc?rev=643368&view=rev
Log:
fixed when and how the ppr control will be initialized to make it work nicely with pprSubmit
and ppr requests

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/PPRSubmitRenderer.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRSupport.java

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=643368&r1=643367&r2=643368&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 Apr  1 04:57:05 2008
@@ -64,6 +64,8 @@
 
     private String _componentUpdateFunction;
 
+    private Boolean _initializationSent;
+
     public PPRPanelGroup()
     {
         setRendererType(DEFAULT_RENDERER_TYPE);
@@ -242,6 +244,21 @@
         this._replaceMessages = replaceMessages;
     }
 
+    /**
+     * flag to store the information if the initialization code has been sent to the client
+     * already. This gets state-saved to have it available between requests, e.g. to make
it work
+     * within ppr responses too.
+     */
+    public boolean getInitializationSent()
+    {
+        return Boolean.TRUE.equals(_initializationSent);
+    }
+
+    public void setInitializationSent(boolean initializationSent)
+    {
+        this._initializationSent = initializationSent?Boolean.TRUE:Boolean.FALSE;
+    }
+
     public void restoreState(FacesContext context, Object state)
     {
         Object[] values = (Object[]) state;
@@ -257,11 +274,12 @@
         _appendMessages = (String) values[9];
         _replaceMessages = (String) values[10];
         _componentUpdateFunction = (String) values[11];
+        _initializationSent = (Boolean) values[12];
     }
 
     public Object saveState(FacesContext context)
     {
-        Object[] values = new Object[12];
+        Object[] values = new Object[13];
         values[0] = super.saveState(context);
         values[1] = _partialTriggers;
         values[2] = _partialTriggerPattern;
@@ -274,6 +292,7 @@
         values[9] = _appendMessages;
         values[10] = _replaceMessages;
         values[11] = _componentUpdateFunction;
+        values[12] = _initializationSent;
         return values;
     }
 

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=643368&r1=643367&r2=643368&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
Tue Apr  1 04:57:05 2008
@@ -61,8 +61,9 @@
             for (int i = 0; i < panelGroups.size(); i++) {
                 PPRPanelGroup pprGroup = (PPRPanelGroup) panelGroups.get(i);
 
-                // will init only once, but initPPR awaits a PPRPanelGroup
-                PPRSupport.initPPR(context, pprGroup);
+                if (!PPRSupport.isPartialRequest(context)) {
+                    PPRSupport.initPPR(context, pprGroup);
+                }
 
                 List triggers = pprGroup.parsePartialTriggers();
                 for (int j = 0; j < triggers.size(); j++) {
@@ -70,7 +71,7 @@
 
                     // TODO: what about trigger patterns?
                     if (trigger.getPartialTriggerId().equals(id)) {
-                        PPRSupport.encodeJavaScript(context, command, pprGroup, trigger);
+                        PPRSupport.encodeJavaScriptTriggerOnly(context, command, pprGroup,
trigger);
                     }
                 }
             }
@@ -82,7 +83,7 @@
 
     /**
      * This component can be child of a command component or embed one as child.
-     * Try to find the command component that way.  
+     * Try to find the command component that way.
      */
     private UICommand findCommandComponent(boolean checkParent, UIComponent component)
     {

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=643368&r1=643367&r2=643368&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
Tue Apr  1 04:57:05 2008
@@ -168,7 +168,7 @@
         renderInlineScript(facesContext, pprGroup, script.toString());
     }
 
-    public static void encodeJavaScript(FacesContext context, UIComponent uiComponent, PPRPanelGroup
pprGroup,
+    public static void encodeJavaScriptTriggerOnly(FacesContext context, UIComponent uiComponent,
PPRPanelGroup pprGroup,
                                         PartialTriggerParser.PartialTrigger trigger) throws
IOException
     {
         StringBuffer script = new StringBuffer();
@@ -320,15 +320,13 @@
         if (fi == null) {
             throw new FacesException("PPRPanelGroup must be embedded in a form.");
         }
-        final ExternalContext externalContext = facesContext.getExternalContext();
-        final Map requestMap = externalContext.getRequestMap();
         final String formName = fi.getFormName();
 
         String pprCtrlReference = "dojo.byId('" + formName + "').myFacesPPRCtrl";
 
         //Each form containing PPRPanelGroups has its own PPRCtrl
-        if (!requestMap.containsKey(PPR_INITIALIZED + "." + formName)) {
-            requestMap.put(PPR_INITIALIZED + "." + formName, Boolean.TRUE);
+        if (!pprGroup.getInitializationSent()) {
+            pprGroup.setInitializationSent(true);
 
             script.append(pprCtrlReference + "=" + MY_FACES_PPR_INIT_CODE + "('" + formName
+ "'," + pprGroup.getShowDebugMessages().booleanValue() + "," + pprGroup.getStateUpdate().booleanValue()
+ ");\n");
 



Mime
View raw message