Revision: 1289
          http://stripes.svn.sourceforge.net/stripes/?rev=1289&view=rev
Author:   bengunter
Date:     2010-09-29 04:06:51 +0000 (Wed, 29 Sep 2010)

Log Message:
-----------
STS-391: Was doing things inside a loop that only needed to be done once and 
the try/finally needed to be outside the loop instead of inside.

Modified Paths:
--------------
    
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/LayoutComponentRenderer.java

Modified: 
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/LayoutComponentRenderer.java
===================================================================
--- 
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/LayoutComponentRenderer.java
  2010-09-29 03:52:46 UTC (rev 1288)
+++ 
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/LayoutComponentRenderer.java
  2010-09-29 04:06:51 UTC (rev 1289)
@@ -119,25 +119,27 @@
         final LayoutContext currentSource = getSourceContext();
         log.debug("Render component \"", componentName, "\" in ", 
getCurrentPage());
 
+        // Turn on the render phase flag and set the component to render
+        context.setComponentRenderPhase(true);
+        context.setComponent(componentName);
+        context.getOut().setSilent(true, pageContext);
+
         // Descend the stack from here, trying each context where the 
component is registered
-        for (LayoutContext source = currentSource == null ? context : 
currentSource.getPrevious(); source != null; source = source.getPrevious()) {
-            // Skip contexts where the desired component is not registered.
-            if (!source.getComponents().containsKey(componentName)) {
-                log.trace("Not rendering \"", componentName, "\" in context ", 
source
-                        .getRenderPage(), " -> ", source.getDefinitionPage());
-                continue;
-            }
+        try {
+            for (LayoutContext source = currentSource == null ? context : 
currentSource
+                    .getPrevious(); source != null; source = 
source.getPrevious()) {
 
-            // Turn on the render phase flag and set the component to render
-            sourceContext = source;
-            context.setComponentRenderPhase(true);
-            context.setComponent(componentName);
+                // Skip contexts where the desired component is not registered.
+                if (!source.getComponents().containsKey(componentName)) {
+                    log.trace("Not rendering \"", componentName, "\" in 
context ",
+                            source.getRenderPage(), " -> ", 
source.getDefinitionPage());
+                    continue;
+                }
+                sourceContext = source;
 
-            try {
                 log.debug("Start execute \"", componentName, "\" in ", 
context.getRenderPage(),
                         " -> ", context.getDefinitionPage(), " from ", 
source.getRenderPage(),
                         " -> ", source.getDefinitionPage());
-                context.getOut().setSilent(true, pageContext);
                 pageContext.include(source.getRenderPage(), false);
                 log.debug("End execute \"", componentName, "\" in ", 
context.getRenderPage(),
                         " -> ", context.getDefinitionPage(), " from ", 
source.getRenderPage(),
@@ -147,14 +149,14 @@
                 if (context.getComponent() == null)
                     return true;
             }
-            finally {
-                // Reset the context properties
-                context.setComponentRenderPhase(phaseFlag);
-                context.setComponent(component);
-                context.getOut().setSilent(silent, pageContext);
-                sourceContext = currentSource;
-            }
         }
+        finally {
+            // Reset the context properties
+            context.setComponentRenderPhase(phaseFlag);
+            context.setComponent(component);
+            context.getOut().setSilent(silent, pageContext);
+            sourceContext = currentSource;
+        }
 
         log.debug("Component \"", componentName, "\" evaluated to empty string 
in context ",
                 context.getRenderPage(), " -> ", context.getDefinitionPage());


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to