You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by tm...@apache.org on 2006/10/14 17:56:40 UTC

svn commit: r463964 - in /struts/struts2/trunk/core/src/main: java/org/apache/struts2/components/ActionComponent.java java/org/apache/struts2/views/jsp/ActionTag.java resources/META-INF/struts-tags.tld

Author: tmjee
Date: Sat Oct 14 08:56:38 2006
New Revision: 463964

URL: http://svn.apache.org/viewvc?view=rev&rev=463964
Log:
WW-1477
 - added a flush attribute to action tag, cause flushing causes exception for some user. Although the exception is swallowed and things work as usual its kindof irritating, it would be nice if there's a way to get rid of such exception by optionally allowing flush to be turn on and off


Modified:
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ActionTag.java
    struts/struts2/trunk/core/src/main/resources/META-INF/struts-tags.tld

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java?view=diff&rev=463964&r1=463963&r2=463964
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java Sat Oct 14 08:56:38 2006
@@ -121,6 +121,7 @@
     protected String namespace;
     protected boolean executeResult;
     protected boolean ignoreContextParams;
+    protected boolean flush = true;
 
     public ActionComponent(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
         super(stack);
@@ -131,10 +132,12 @@
     public boolean end(Writer writer, String body) {
     	boolean end = super.end(writer, "", false);
 		try {
-			try {
-				writer.flush();
-			} catch (IOException e) {
-				LOG.warn("error while trying to flush writer ", e);
+			if (flush) {
+				try {
+					writer.flush();
+				} catch (IOException e) {
+					LOG.warn("error while trying to flush writer ", e);
+				}
 			}
 			executeAction();
 
@@ -290,5 +293,13 @@
      */
     public void setIgnoreContextParams(boolean ignoreContextParams) {
         this.ignoreContextParams = ignoreContextParams;
+    }
+    
+    /**
+     * whether the writer should be flush upon end of action component tag, default to true.
+     * @s.tagattribute required="false" type="Boolean" default="true"
+     */
+    public void setFlush(boolean flush) {
+    	this.flush = flush;
     }
 }

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ActionTag.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ActionTag.java?view=diff&rev=463964&r1=463963&r2=463964
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ActionTag.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ActionTag.java Sat Oct 14 08:56:38 2006
@@ -36,6 +36,7 @@
     protected String namespace;
     protected boolean executeResult;
     protected boolean ignoreContextParams;
+    protected boolean flush = true;
 
     public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
         return new ActionComponent(stack, req, res);
@@ -49,6 +50,7 @@
         action.setNamespace(namespace);
         action.setExecuteResult(executeResult);
         action.setIgnoreContextParams(ignoreContextParams);
+        action.setFlush(flush);
         action.start(pageContext.getOut());
     }
 
@@ -71,5 +73,13 @@
 
     public void setIgnoreContextParams(boolean ignoreContextParams) {
         this.ignoreContextParams = ignoreContextParams;
+    }
+    
+    public void setFlush(boolean flush) {
+    	this.flush = flush;
+    }
+    
+    public boolean getFlush() {
+    	return this.flush;
     }
 }

Modified: struts/struts2/trunk/core/src/main/resources/META-INF/struts-tags.tld
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/META-INF/struts-tags.tld?view=diff&rev=463964&r1=463963&r2=463964
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/META-INF/struts-tags.tld (original)
+++ struts/struts2/trunk/core/src/main/resources/META-INF/struts-tags.tld Sat Oct 14 08:56:38 2006
@@ -2969,7 +2969,14 @@
                 <![CDATA[whether the request parameters are to be included when the action is invoked]]></description>
 
         </attribute>
-
+		<attribute>
+         <name>flush</name>
+         <required>false</required>
+         <rtexprvalue>true</rtexprvalue>
+         
+         	<description><![CDATA[whether the writer should be flush upon end of the action tag, default to true.]]></description>
+         	
+      </attribute>
     </tag>
     <tag>