<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>UKoom &#187; Web MVC</title>
	<atom:link href="http://www.ukoom.com/category/java/webmvc/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ukoom.com</link>
	<description>Documentum, SharePoint, Alfresco, ECM...</description>
	<lastBuildDate>Thu, 13 May 2010 00:21:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Struts2 Result Type</title>
		<link>http://www.ukoom.com/struts2-result-type.htm</link>
		<comments>http://www.ukoom.com/struts2-result-type.htm#comments</comments>
		<pubDate>Wed, 20 Jan 2010 13:58:09 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Web MVC]]></category>
		<category><![CDATA[Struts]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=1020</guid>
		<description><![CDATA[Result Types are [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Result Types</strong> are classes that determine what happens after an Action executes and a Result is returned. Developers are free to create their own Result Types according to the needs of their application or environment. In WebWork 2 for example, Servlet and Velocity Result Types have been created to handle rendering views in web applications.</p>
<p><ins>Note:</ins> All built in webwork result types implement the <tt>com.opensymphony.xwork.Result</tt> interface, which represents a generic interface for all action execution results, whether that be displaying a webpage, generating an email, sending a JMS message, etc.</p>
<p>Result types define classes and map them to names to be referred in the action configuration results. This serves as a shorthand name-value pair for these classes.</p>
<div id="blog_text">
<div>一个提交到服务器的处理通常可以分为两个阶段，第一个阶段查询服务器状态（查询或者更新数据库），第二个阶段选择一个合适的结果页面其返回给用户（这里要讲的Result的内容）。</div>
<div>Struts2提供了对不同种类返回结果的支持，常见的有JSP，FreeMarker，Velocity等。</div>
<div>Struts2支持的不同类型的返回结果为：</div>
<table style="border: medium none ; border-collapse: collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="border: 1pt solid black; padding: 0cm 5.4pt; background: #bfbfbf none repeat scroll 0% 0%; width: 113.3pt;" width="151" valign="top">
<div><strong>名字</strong></div>
</td>
<td style="padding: 0cm 5.4pt; background: #bfbfbf none repeat scroll 0% 0%; width: 274.2pt;" width="366" valign="top">
<div><strong>说明</strong></div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt;" width="151" valign="top">
<div>Chain Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt;" width="366" valign="top">
<div>用来处理Action链</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt;" width="151" valign="top">
<div>Dispatcher Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt;" width="366" valign="top">
<div>用来转向页面，通常处理JSP</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt;" width="151" valign="top">
<div>FreeMarker Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt;" width="366" valign="top">
<div>处理FreeMarker模板</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt;" width="151" valign="top">
<div>HttpHeader Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt;" width="366" valign="top">
<div>用来控制特殊的Http行为</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt;" width="151" valign="top">
<div>Redirect Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt;" width="366" valign="top">
<div>重定向到一个URL</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt;" width="151" valign="top">
<div>Redirect Action Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt;" width="366" valign="top">
<div>重定向到一个Action</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt;" width="151" valign="top">
<div>Stream Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt;" width="366" valign="top">
<div>向浏览器发送InputSream对象，通常用来处理文件下载</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt;" width="151" valign="top">
<div>Velocity Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt;" width="366" valign="top">
<div>处理Velocity模板</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt;" width="151" valign="top">
<div>XLS Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt;" width="366" valign="top">
<div>处理XML/XLST模板</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt;" width="151" valign="top">
<div>PlainText Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt;" width="366" valign="top">
<div>显示原始文件内容，例如文件源代码</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt;" width="151" valign="top">
<div>S2PLUGINS:Tiles Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt;" width="366" valign="top">
<div>结合Tile使用</div>
</td>
</tr>
</tbody>
</table>
<div>另外第三方的Result类型还包括JasperReports Plugin，专门用来处理JasperReport类型的报表输出。</div>
<div>在struts-default.xml文件中已经有了对于所有类型Result的定义：</div>
<div>&lt;result-types&gt;</div>
<div><span>&lt;result-type name=&#8221;chain&#8221;</span></div>
<div><span>class=&#8221;com.opensymphony.xwork2.ActionChainResult&#8221;/&gt;</span></div>
<div><strong><span>&lt;result-type name=&#8221;dispatcher&#8221;</span></strong></div>
<div><strong><span>class=&#8221;org.apache.struts2.dispatcher.ServletDispatcherResult&#8221;</span></strong></div>
<div><strong><span>default=&#8221;true&#8221;/&gt;</span></strong></div>
<div><span>&lt;result-type name=&#8221;freemarker&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.views.freemarker.FreemarkerResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;httpheader&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.HttpHeaderResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;redirect&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.ServletRedirectResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;redirectAction&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.ServletActionRedirectResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;stream&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.StreamResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;velocity&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.VelocityResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;xslt&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.views.xslt.XSLTResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;plainText&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.PlainTextResult&#8221; /&gt;</span></div>
<div><span>&lt;!&#8211; Deprecated name form scheduled for removal in Struts 2.1.0.</span></div>
<div><span>The camelCase versions are preferred. See ww-1707 &#8211;&gt;</span></div>
<div><span>&lt;result-type name=&#8221;redirect-action&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.ServletActionRedirectResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;plaintext&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.PlainTextResult&#8221; /&gt;</span></div>
<div>&lt;/result-types&gt;</div>
<div>
<p>从上述代码中可以看出在不指定Result类型的时候使用dispatcher类型。</p></div>
<div>定义一个Result值，</div>
<div>&lt;result name=&#8221;success&#8221; type=&#8221;dispatcher&#8221;&gt;</div>
<div><span>&lt;param name=&#8221;location&#8221;&gt;/ThankYou.jsp&lt;/param&gt;</span></div>
<div>&lt;/result&gt;</div>
<div>由于type默认值是dispatcher，所以这里不需要定义，另外name的默认值为success所以这里也不需要定义。</div>
<div>上述代码可以简写为：</div>
<div>&lt;result&gt;</div>
<div><span>&lt;param name=&#8221;location&#8221;&gt;/ThankYou.jsp&lt;/param&gt;</span></div>
<div>
<p>&lt;/result&gt;</p></div>
<div>另外location参数也可以直接卸载result标签内部，所以上述代码的最简单的写法为：</div>
<div>&lt;result&gt;/ThankYou.jsp&lt;/result&gt;</div>
<div>我们也可以定义多个不同的Result</div>
<div>&lt;action name=&#8221;Hello&#8221;&gt;</div>
<div>&lt;result&gt;/hello/Result.jsp&lt;/result&gt;</div>
<div>&lt;result name=&#8221;error&#8221;&gt;/hello/Error.jsp&lt;/result&gt;</div>
<div>&lt;result name=&#8221;input&#8221;&gt;/hello/Input.jsp&lt;/result&gt;</div>
<div>&lt;/action&gt;</div>
<div>上述代码的含义为，名字为Hello的Action有三个返回结果，并且都是dispatcher类型（默认类型），这三个返回值的名字分别为 success（默认值），error，input，对应的页面的路径分别为/hello/Result.jsp，/hello/Error.jsp， /hello/Input.jsp。</div>
<div>有些时候我们需要一个定义在全局的Result，这个时候我们可以在package内部定义全局的Result，例如：</div>
<div>&lt;global-results&gt;</div>
<div>&lt;result name=&#8221;error&#8221;&gt;/Error.jsp&lt;/result&gt;</div>
<div>&lt;result name=&#8221;invalid.token&#8221;&gt;/Error.jsp&lt;/result&gt;</div>
<div>&lt;result name=&#8221;login&#8221; type=&#8221;redirect-action&#8221;&gt;Logon!input&lt;/result&gt;</div>
<div>
<p>&lt;/global-results&gt;</p></div>
<div><strong>动态返回结果</strong></div>
<div>有些时候，只有当Action执行完璧的时候我们才知道要返回哪个结果，这个时候我们可以在Action内部定义一个属性，这个属性用来存储Action执行完璧之后的Result值，例如：</div>
<div>private String nextAction;</div>
<div>public String getNextAction() {</div>
<div><span>return nextAction;</span></div>
<div>}</div>
<div>在strutx.xml配置文件中，我们可以使用${nextAction}来引用到Action中的属性，通过${nextAction}表示的内容来动态的返回结果，例如：</div>
<div>&lt;action name=&#8221;fragment&#8221;&gt;</div>
<div>&lt;result name=&#8221;next&#8221; type=&#8221;redirect-action&#8221;&gt;${nextAction}&lt;/result&gt;</div>
<div>&lt;/action&gt;</div>
<div>上述Action的execute方法返回next的时候，还需要根据nextAction的属性来判断具体定位到哪个Action。</div>
<div>如果想转发到另外个action可以设置type=chain 同时结果不加shtml</div>
</div>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.ukoom.com/freemarker-result.htm" title="FreeMarker Result">FreeMarker Result</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/struts2-result-type.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FreeMarker Result</title>
		<link>http://www.ukoom.com/freemarker-result.htm</link>
		<comments>http://www.ukoom.com/freemarker-result.htm#comments</comments>
		<pubDate>Wed, 20 Jan 2010 13:55:04 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Web MVC]]></category>
		<category><![CDATA[Struts]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=1018</guid>
		<description><![CDATA[Renders a view [...]]]></description>
			<content:encoded><![CDATA[<p>Renders a view using the Freemarker template engine.</p>
<p>The FreemarkarManager class configures the template loaders so that the template location can be either</p>
<ul>
<li>relative to the web root folder. eg <code>/WEB-INF/views/home.ftl</code></li>
<li>a classpath resuorce. eg <code>/com/company/web/views/home.ftl</code></li>
</ul>
<p>Parameters</p>
<p>* location (default) &#8211; the location of the template to process.</p>
<p>* parse &#8211; true by default. If set to false, the location param will not be parsed for Ognl expressions.</p>
<p>* contentType &#8211; defaults to &#8220;text/html&#8221; unless specified.</p>
<p>* writeIfCompleted &#8211; false by default, write to stream only if there isn&#8217;t any error processing the template. Setting template_exception_handler=rethrow in freemarker.properties will have the same effect.</p>
<p>Examples</p>
<pre><span>&lt;result name=<span>"success"</span> type=<span>"freemarker"</span>&gt;</span>foo.ftl<span>&lt;/result&gt;

Of course, we can also omit the 'type' setting by setting the result type
of struts. Please refer to another article of this site - Struts result type.

</span></pre>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 337px; width: 1px; height: 1px;">
<div id="blog_text" class="cnt">
<div>一个提交到服务器的处理通常可以分为两个阶段，第一个阶段查询服务器状态（查询或者更新数据库），第二个阶段选择一个合适的结果页面其返回给用户（这里要讲的Result的内容）。</div>
<div></div>
<div>Struts2提供了对不同种类返回结果的支持，常见的有JSP，FreeMarker，Velocity等。</div>
<div>Struts2支持的不同类型的返回结果为：</div>
<table style="border: medium none ; border-collapse: collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="border: 1pt solid black; padding: 0cm 5.4pt; background: #bfbfbf none repeat scroll 0% 0%; width: 113.3pt;" width="151" valign="top">
<div><strong>名字</strong></div>
</td>
<td style="padding: 0cm 5.4pt; background: #bfbfbf none repeat scroll 0% 0%; width: 274.2pt; border: 1pt 1pt 1pt medium solid solid solid none -moz-use-text-color;" width="366" valign="top">
<div><strong>说明</strong></div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt; border: medium 1pt 1pt none solid solid -moz-use-text-color;" width="151" valign="top">
<div>Chain Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt; border: medium 1pt 1pt medium none solid solid none -moz-use-text-color;" width="366" valign="top">
<div>用来处理Action链</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt; border: medium 1pt 1pt none solid solid -moz-use-text-color;" width="151" valign="top">
<div>Dispatcher Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt; border: medium 1pt 1pt medium none solid solid none -moz-use-text-color;" width="366" valign="top">
<div>用来转向页面，通常处理JSP</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt; border: medium 1pt 1pt none solid solid -moz-use-text-color;" width="151" valign="top">
<div>FreeMarker Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt; border: medium 1pt 1pt medium none solid solid none -moz-use-text-color;" width="366" valign="top">
<div>处理FreeMarker模板</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt; border: medium 1pt 1pt none solid solid -moz-use-text-color;" width="151" valign="top">
<div>HttpHeader Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt; border: medium 1pt 1pt medium none solid solid none -moz-use-text-color;" width="366" valign="top">
<div>用来控制特殊的Http行为</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt; border: medium 1pt 1pt none solid solid -moz-use-text-color;" width="151" valign="top">
<div>Redirect Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt; border: medium 1pt 1pt medium none solid solid none -moz-use-text-color;" width="366" valign="top">
<div>重定向到一个URL</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt; border: medium 1pt 1pt none solid solid -moz-use-text-color;" width="151" valign="top">
<div>Redirect Action Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt; border: medium 1pt 1pt medium none solid solid none -moz-use-text-color;" width="366" valign="top">
<div>重定向到一个Action</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt; border: medium 1pt 1pt none solid solid -moz-use-text-color;" width="151" valign="top">
<div>Stream Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt; border: medium 1pt 1pt medium none solid solid none -moz-use-text-color;" width="366" valign="top">
<div>向浏览器发送InputSream对象，通常用来处理文件下载</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt; border: medium 1pt 1pt none solid solid -moz-use-text-color;" width="151" valign="top">
<div>Velocity Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt; border: medium 1pt 1pt medium none solid solid none -moz-use-text-color;" width="366" valign="top">
<div>处理Velocity模板</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt; border: medium 1pt 1pt none solid solid -moz-use-text-color;" width="151" valign="top">
<div>XLS Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt; border: medium 1pt 1pt medium none solid solid none -moz-use-text-color;" width="366" valign="top">
<div>处理XML/XLST模板</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt; border: medium 1pt 1pt none solid solid -moz-use-text-color;" width="151" valign="top">
<div>PlainText Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt; border: medium 1pt 1pt medium none solid solid none -moz-use-text-color;" width="366" valign="top">
<div>显示原始文件内容，例如文件源代码</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt; border: medium 1pt 1pt none solid solid -moz-use-text-color;" width="151" valign="top">
<div>S2PLUGINS:Tiles Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt; border: medium 1pt 1pt medium none solid solid none -moz-use-text-color;" width="366" valign="top">
<div>结合Tile使用</div>
</td>
</tr>
</tbody>
</table>
<div>另外第三方的Result类型还包括JasperReports Plugin，专门用来处理JasperReport类型的报表输出。</div>
<div></div>
<div>在struts-default.xml文件中已经有了对于所有类型Result的定义：</div>
<div>&lt;result-types&gt;</div>
<div><span>&lt;result-type name=&#8221;chain&#8221;</span></div>
<div><span>class=&#8221;com.opensymphony.xwork2.ActionChainResult&#8221;/&gt;</span></div>
<div><strong><span>&lt;result-type name=&#8221;dispatcher&#8221;</span></strong></div>
<div><strong><span>class=&#8221;org.apache.struts2.dispatcher.ServletDispatcherResult&#8221;</span></strong></div>
<div><strong><span>default=&#8221;true&#8221;/&gt;</span></strong></div>
<div><span>&lt;result-type name=&#8221;freemarker&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.views.freemarker.FreemarkerResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;httpheader&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.HttpHeaderResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;redirect&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.ServletRedirectResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;redirectAction&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.ServletActionRedirectResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;stream&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.StreamResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;velocity&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.VelocityResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;xslt&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.views.xslt.XSLTResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;plainText&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.PlainTextResult&#8221; /&gt;</span></div>
<div><span>&lt;!&#8211; Deprecated name form scheduled for removal in Struts 2.1.0.</span></div>
<div><span>The camelCase versions are preferred. See ww-1707 &#8211;&gt;</span></div>
<div><span>&lt;result-type name=&#8221;redirect-action&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.ServletActionRedirectResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;plaintext&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.PlainTextResult&#8221; /&gt;</span></div>
<div>&lt;/result-types&gt;</div>
<div></div>
<div>
<p>从上述代码中可以看出在不指定Result类型的时候使用dispatcher类型。</p></div>
<div></div>
<div>定义一个Result值，</div>
<div>&lt;result name=&#8221;success&#8221; type=&#8221;dispatcher&#8221;&gt;</div>
<div><span>&lt;param name=&#8221;location&#8221;&gt;/ThankYou.jsp&lt;/param&gt;</span></div>
<div>&lt;/result&gt;</div>
<div>由于type默认值是dispatcher，所以这里不需要定义，另外name的默认值为success所以这里也不需要定义。</div>
<div>上述代码可以简写为：</div>
<div>&lt;result&gt;</div>
<div><span>&lt;param name=&#8221;location&#8221;&gt;/ThankYou.jsp&lt;/param&gt;</span></div>
<div>
<p>&lt;/result&gt;</p></div>
<div>另外location参数也可以直接卸载result标签内部，所以上述代码的最简单的写法为：</div>
<div>&lt;result&gt;/ThankYou.jsp&lt;/result&gt;</div>
<div></div>
<div>我们也可以定义多个不同的Result</div>
<div>&lt;action name=&#8221;Hello&#8221;&gt;</div>
<div>&lt;result&gt;/hello/Result.jsp&lt;/result&gt;</div>
<div>&lt;result name=&#8221;error&#8221;&gt;/hello/Error.jsp&lt;/result&gt;</div>
<div>&lt;result name=&#8221;input&#8221;&gt;/hello/Input.jsp&lt;/result&gt;</div>
<div>&lt;/action&gt;</div>
<div>上述代码的含义为，名字为Hello的Action有三个返回结果，并且都是dispatcher类型（默认类型），这三个返回值的名字分别为 success（默认值），error，input，对应的页面的路径分别为/hello/Result.jsp，/hello/Error.jsp， /hello/Input.jsp。</div>
<div></div>
<div>有些时候我们需要一个定义在全局的Result，这个时候我们可以在package内部定义全局的Result，例如：</div>
<div>&lt;global-results&gt;</div>
<div>&lt;result name=&#8221;error&#8221;&gt;/Error.jsp&lt;/result&gt;</div>
<div>&lt;result name=&#8221;invalid.token&#8221;&gt;/Error.jsp&lt;/result&gt;</div>
<div>&lt;result name=&#8221;login&#8221; type=&#8221;redirect-action&#8221;&gt;Logon!input&lt;/result&gt;</div>
<div>
<p>&lt;/global-results&gt;</p></div>
<div></div>
<div><strong>动态返回结果</strong></div>
<div>有些时候，只有当Action执行完璧的时候我们才知道要返回哪个结果，这个时候我们可以在Action内部定义一个属性，这个属性用来存储Action执行完璧之后的Result值，例如：</div>
<div>private String nextAction;</div>
<div></div>
<div>public String getNextAction() {</div>
<div><span>return nextAction;</span></div>
<div>}</div>
<div></div>
<div>在strutx.xml配置文件中，我们可以使用${nextAction}来引用到Action中的属性，通过${nextAction}表示的内容来动态的返回结果，例如：</div>
<div>&lt;action name=&#8221;fragment&#8221; class=&#8221;FragmentAction&#8221;&gt;</div>
<div>&lt;result name=&#8221;next&#8221; type=&#8221;redirect-action&#8221;&gt;${nextAction}&lt;/result&gt;</div>
<div>&lt;/action&gt;</div>
<div></div>
<div>上述Action的execute方法返回next的时候，还需要根据nextAction的属性来判断具体定位到哪个Action。</div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div>如果想转发到另外个action可以设置type=chain 同时结果不加shtml</div>
</div>
</div>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.ukoom.com/struts2-result-type.htm" title="Struts2 Result Type">Struts2 Result Type</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/freemarker-result.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GET POST 区别详解</title>
		<link>http://www.ukoom.com/get-post-%e5%8c%ba%e5%88%ab%e8%af%a6%e8%a7%a3.htm</link>
		<comments>http://www.ukoom.com/get-post-%e5%8c%ba%e5%88%ab%e8%af%a6%e8%a7%a3.htm#comments</comments>
		<pubDate>Wed, 13 Jan 2010 07:13:24 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[Web MVC]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=1010</guid>
		<description><![CDATA[1、Get是用来从服务器上获得数据，而Post是用来向服务器上传递数据。
2、Get将表单中数据的按照variable=value的形式，添加到action所指向的URL后面，并且两者使用“?”连接，而各个变量之间使用“&#38;”连接；Post是将表单中的数据放在form的数据体中，按照变量和值相对应的方式，传递到action所指向URL。
3、Get是不安全的，因为在传输过程，数据被放在请求的URL中，而如今现有的很多服务器、代理服务器或者用户代理都会将请求URL记录到日志文件中，然后放在某个地方，这样就可能会有一些隐私的信息被第三方看到。另外，用户也可以在浏览器上直接看到提交的数据，一些系统内部消息将会一同显示在用户面前。Post的所有操作对用户来说都是不可见的。
4、Get传输的数据量小，这主要是因为受URL长度限制；而Post可以传输大量的数据，所以在上传文件只能使用Post（当然还有一个原因，将在后面的提到）。
5、Get限制Form表单的数据集的值必须为ASCII字符；而Post支持整个ISO10646字符集。默认是用ISO-8859-1编码
6、Get是Form的默认方法。
以下的比较非常非常使用：
做java的web开发有段日子了，有个问题老是困扰着我，就是乱码问题，基本上是网上查找解决方案（网上资料真的很多），都是一大堆的介绍如何解决此类的乱码问题，但是没几个把问题的来龙去脉说清楚的，有时候看了些文章后，以为自己懂了，但是在开发中乱码问题又像鬼魂一样出来吓人，真是头大了！这篇文章是我长时间和乱码做斗争的一些理解的积累，还希望有更多的朋友给出指点和补充。
  form有2中方法把数据提交给服务器，get和post,分别说下吧。
（一）get提交
 [...]]]></description>
			<content:encoded><![CDATA[<p>1、Get是用来从服务器上获得数据，而Post是用来向服务器上传递数据。<br />
2、Get将表单中数据的按照variable=value的形式，添加到action所指向的URL后面，并且两者使用“?”连接，而各个变量之间使用“&amp;”连接；Post是将表单中的数据放在form的数据体中，按照变量和值相对应的方式，传递到action所指向URL。<br />
3、Get是不安全的，因为在传输过程，数据被放在请求的URL中，而如今现有的很多服务器、代理服务器或者用户代理都会将请求URL记录到日志文件中，然后放在某个地方，这样就可能会有一些隐私的信息被第三方看到。另外，用户也可以在浏览器上直接看到提交的数据，一些系统内部消息将会一同显示在用户面前。Post的所有操作对用户来说都是不可见的。<br />
4、Get传输的数据量小，这主要是因为受URL长度限制；而Post可以传输大量的数据，所以在上传文件只能使用Post（当然还有一个原因，将在后面的提到）。<br />
5、Get限制Form表单的数据集的值必须为ASCII字符；而Post支持整个ISO10646字符集。默认是用ISO-8859-1编码<br />
6、Get是Form的默认方法。<br />
以下的比较非常非常使用：<br />
做java的web开发有段日子了，有个问题老是困扰着我，就是乱码问题，基本上是网上查找解决方案（网上资料真的很多），都是一大堆的介绍如何解决此类的乱码问题，但是没几个把问题的来龙去脉说清楚的，有时候看了些文章后，以为自己懂了，但是在开发中乱码问题又像鬼魂一样出来吓人，真是头大了！这篇文章是我长时间和乱码做斗争的一些理解的积累，还希望有更多的朋友给出指点和补充。<br />
  form有2中方法把数据提交给服务器，get和post,分别说下吧。<br />
（一）get提交<br />
  1.首先说下客户端（浏览器）的form表单用get方法是如何将数据编码后提交给服务器端的吧。 </p>
<p>    对于get方法来说，都是把数据串联在请求的url后面作为参数，如：http://localhost:8080/servlet?msg=abc<br />
（很常见的一个乱码问题就要出现了，如果url中出现中文或其它特殊字符的话，如：http://localhost:8080 /servlet?msg=杭州，服务器端容易得到乱码），url拼接完成后，浏览器会对url进行URL encode，然后发送给服务器，URL encode的过程就是把部分url做为字符，按照某种编码方式（如：utf-8,gbk等）编码成二进制的字节码，然后每个字节用一个包含3个字符的字符串 &#8220;%xy&#8221; 表示，其中xy为该字节的两位十六进制表示形式。我这里说的可能不清楚，具体介绍可以看下java.net.URLEncoder类的介绍在这里。了解了 URL encode的过程，我们能看到2个很重要的问题，第一：需要URL encode的字符一般都是非ASCII的字符（笼统的讲），再通俗的讲就是除了英文字母以外的文字（如：中文，日文等）都要进行URL encode，所以对于我们来说，都是英文字母的url不会出现服务器得到乱码问题，出现乱码都是url里面带了中文或特殊字符造成的；第二：URL encode到底按照那种编码方式对字符编码？这里就是浏览器的事情了，而且不同的浏览器有不同的做法，中文版的浏览器一般会默认的使用GBK，通过设置浏览器也可以使用UTF-8，可能不同的用户就有不同的浏览器设置，也就造成不同的编码方式，所以很多网站的做法都是先把url里面的中文或特殊字符用 javascript做URL encode，然后再拼接url提交数据，也就是替浏览器做了URL encode，好处就是网站可以统一get方法提交数据的编码方式。 完成了URL encode，那么现在的url就成了ASCII范围内的字符了，然后以iso-8859-1的编码方式转换成二进制随着请求头一起发送出去。这里想多说几句的是，对于get方法来说，没有请求实体，含有数据的url都在请求头里面，之所以用URL encode，我个人觉的原因是：对于请求头来说最终都是要用iso-8859-1编码方式编码成二进制的101010&#8230;..的纯数据在互联网上传送，如果直接将含有中文等特殊字符做iso-8859-1编码会丢失信息，所以先做URL encode是有必要的。<br />
   2。服务器端（tomcat）是如何将数据获取到进行解码的。<br />
   第一步是先把数据用iso-8859-1进行解码，对于get方法来说，tomcat获取数据的是ASCII范围内的请求头字符，其中的请求url里面带有参数数据，如果参数中有中文等特殊字符，那么目前还是URL encode后的%XY状态，先停下，我们先说下开发人员一般获取数据的过程。通常大家都是request.getParameter(&#8221;name&#8221;)获取参数数据，我们在request对象或得的数据都是经过解码过的，而解码过程中程序里是无法指定，这里要说下，有很多新手说用 request.setCharacterEncoding(&#8221;字符集&#8221;)可以指定解码方式，其实是不可以的，看servlet的官方API说明有对此方法的解释：Overrides the name of the character encoding used in the body of this request. This method must be called prior to reading request parameters or reading input using getReader().可以看出对于get方法他是无能为力的。那么到底用什么编码方式解码数据的呢，这是tomcat的事情了，默认缺省用的是 iso-8859-1,这样我们就能找到为什么get请求带中文参数为什么在服务器端得到乱码了，原因是在客户端一般都是用UTF-8或GBK对数据 URL encode，这里用iso-8859-1方式URL decoder显然不行，在程序里我们可以直接<br />
Java代码<br />
1. new String(request.getParameter(&#8221;name&#8221;).getBytes(&#8221;iso-8859-1&#8243;),&#8221;客户端指定的URL encode编码方式&#8221;)<br />
还原回字节码，然后用正确的方式解码数据，网上的文章通常是在tomcat里面做个配置<br />
Xml代码<br />
1.<br />
这样是让tomcat在获取数据后用指定的方式URL decoder，URL decoder的介绍在这里<br />
（一）post提交<br />
1.客户端（浏览器）的form表单用post方法是如何将数据编码后提交给服务器端的。<br />
  在post方法里所要传送的数据也要URL encode，那么他是用什么编码方式的呢？<br />
   在form所在的html文件里如果有段，那么post就会用此处指定的编码方式编码。一般大家都认为这段代码是为了让浏览器知道用什么字符集来对网页解释，所以网站都会把它放在html代码的最前端，尽量不出现乱码，其实它还有个作用就是指定form表单的post方法提交数据的 URL encode编码方式。从这里可以看出对于get方法来数，浏览器对数据的URL encode的编码方式是有浏览器设置来决定，（可以用js做统一指定），而post方法，开发人员可以指定。<br />
2。服务器端（tomcat）是如何将数据获取到进行解码的。<br />
如果用tomcat默认缺省设置，也没做过滤器等编码设置，那么他也是用iso-8859-1解码的，但是request.setCharacterEncoding(&#8221;字符集&#8221;)可以派上用场。 </p>
<p>我发现上面说的tomcat所做的事情前提都是在请求头里没有指定编码方式，如果请求头里指定了编码方式将按照这种方式编码。<br />
   有2篇文章推荐下，地址分别是<br />
深入浅出URL编码：http://www.cnblogs.com/yencain/articles/1321386.html；<br />
表单用post方法提交数据时乱码问题：http://wanghuan8086.javaeye.com/blog/173869 </p>
<p>用post很重要的在form所在的html文件里如果有段<br />
强烈建议使用post提交</p>
<p>详细出处参考：http://www.jb51.net/web/12714.html<br />
http://www.cnblogs.com/hyddd/archive/2009/03/31/1426026.html</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.ukoom.com/java%e4%b8%adreplaceall%e5%92%8csplit%e4%b8%ad%e7%9a%84%e5%8f%8d%e6%96%9c%e6%9d%a0.htm" title="Java中replaceAll和split中的反斜杠">Java中replaceAll和split中的反斜杠</a></li><li><a href="http://www.ukoom.com/documentum-api-list_sessions.htm" title="Documentum API LIST_SESSIONS">Documentum API LIST_SESSIONS</a></li><li><a href="http://www.ukoom.com/webtop-6-5-sp1-loadrunner.htm" title="Webtop 6.5 SP1 LoadRunner">Webtop 6.5 SP1 LoadRunner</a></li><li><a href="http://www.ukoom.com/documentum-data-dictionary.htm" title="Documentum Data Dictionary">Documentum Data Dictionary</a></li><li><a href="http://www.ukoom.com/get-definition-for-view-in-oracle.htm" title="Get definition for view in Oracle">Get definition for view in Oracle</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/get-post-%e5%8c%ba%e5%88%ab%e8%af%a6%e8%a7%a3.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BlazeDS factory mechanism</title>
		<link>http://www.ukoom.com/blazeds-factory-mechanism.htm</link>
		<comments>http://www.ukoom.com/blazeds-factory-mechanism.htm#comments</comments>
		<pubDate>Wed, 23 Dec 2009 09:05:17 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Web MVC]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=988</guid>
		<description><![CDATA[BlazeDS provides a [...]]]></description>
			<content:encoded><![CDATA[<p>BlazeDS provides a factory mechanism that lets you plug in your own component creation and maintenance system to allow it to integrate with systems like EJB and Spring, which store components in their own namespace. You provide a class that implements the flex.messaging.FlexFactory interface. This class is used to create a FactoryInstance that corresponds to a component configured for a specific destination.</p>
<p>Remoting Service destinations use Java classes that you write to integrate with Flex clients. By default, BlazeDS creates these instances. If they are application-scoped components, they are stored in the ServletContext attribute space using the destination&#8217;s name as the attribute name. If you use session-scoped components, the components are stored in the FlexSession, also using the destination name as the attribute. If you specify an <samp>attribute-id</samp> element in the destination, you can control which attribute the component is stored in; this lets more than one destination share the same instance.</p>
<p>The following examples shows a destination definition that contains an <samp>attribute-id</samp> element:</p>
<pre>&lt;destination id="WeatherService"&gt;
    &lt;properties&gt;
        &lt;source&gt;weather.WeatherService&lt;/source&gt;
        &lt;scope&gt;application&lt;/scope&gt;
        &lt;attribute-id&gt;MyWeatherService&lt;/attribute-id&gt;
    &lt;/properties&gt;
&lt;/destination&gt;</pre>
<p>In this example, BlazeDS creates an instance of the class weather.WeatherService and stores it in the ServletContext object&#8217;s set of attributes with the name MyWeatherService. If you define a different destination with the same <samp>attribute-id</samp> value and the same Java class, BlazeDS uses the same component instance.</p>
<p>BlazeDS provides a factory mechanism that lets you plug in your own component creation and maintenance system to BlazeDS so it integrates with systems like EJB and Spring, which store components in their own namespace. You provide a class that implements the flex.messaging.FlexFactory interface. You use this class to create a FactoryInstance that corresponds to a component configured for a specific destination. Then the component uses the FactoryInstance to look up the specific component to use for a given request. The FlexFactory implementation can access configuration attributes from a BlazeDS configuration file and also can access FlexSession and ServletContext objects. For more information, see the documentation for the FlexFactory class in the public BlazeDS Javadoc documentation.</p>
<p>After you implement a FlexFactory class, you can configure it to be available to destinations by placing a <samp>factory</samp> element in the <samp>factories</samp> element in the services-config.xml file, as the following example shows. A single FlexFactory instance is created for each BlazeDS web application. This instance can have its own configuration properties, although in this example, there are no required properties to configure the factory.</p>
<pre>&lt;factories&gt;
    &lt;factory id="spring"/&gt;
&lt;/factories&gt;</pre>
<p>BlazeDS creates one FlexFactory instance for each <samp>factory</samp> element that you specify. BlazeDS uses this one global FlexFactory implementation for each destination that specifies that factory by its ID; the ID is identified by using a <samp>factory</samp> element in the <samp>properties</samp> section of the destination definition. For example, your remoting-config.xml file could have a destination similar to the following one:</p>
<pre>&lt;destination id="WeatherService"&gt;
    &lt;properties&gt;
        &lt;factory&gt;spring&lt;/factory&gt;
        &lt;source&gt;weatherBean&lt;/source&gt;
    &lt;/properties&gt;
&lt;/destination&gt;</pre>
<p>When the <samp>factory</samp> element is encountered at start up, BlazeDS calls the <samp>FlexFactory.createFactoryInstance()</samp> method. That method gets the <samp>source</samp> value and any other attributes it expects in the configuration. Any attributes that you access from the ConfigMap parameter are marked as expected and do not cause a configuration error, so you can extend the default BlazeDS configuration in this manner. When BlazeDS requires an instance of the component for this destination, it calls the <samp>FactoryInstance.lookup()</samp> method to retrieve the individual instance for the destination.</p>
<p>Optionally, factory instances can take additional attributes. There are two places you can do this. When you define the factory initially, you can provide extra attributes as part of the factory definition. When you define an instance of that factory, you can also add your own attributes to the destination definition to be used in creating the factory instance.</p>
<p>The boldface text in the following example shows an attribute added to the factory definition:</p>
<pre>&lt;factories&gt;
    &lt;factory id="myFactoryId"&gt;
        &lt;properties&gt;
<strong><samp>            &lt;myfactoryattributename&gt;</samp></strong>
<strong><samp>                myfactoryattributevalue</samp></strong>
<strong><samp>            &lt;/myfactoryattributename&gt;</samp></strong>
        &lt;/properties&gt;
    &lt;/factory&gt;
&lt;/factories&gt;</pre>
<p>You could use this type of configuration when you are integrating with the Spring Framework Java application framework to provide the Spring factory with a default path for initializing the Spring context that you use to look up all components for that factory. In the class that implements FlexFactory, you would include a call to retrieve the values of the <samp>myfactoryattributename</samp> from the <samp>configMap</samp> parameter to the <samp>initialize()</samp> method in the FlexFactory interface, as the following example shows:</p>
<pre>public void initialize(String id, ConfigMap configMap){
    System.out.println("**** MyFactory initialized with: " +
        configMap.getPropertyAsString("myfactoryattributename", "not set"));
}</pre>
<p>The <samp>initialize()</samp> method in the previous example retrieves a string value where the first parameter is the name of the attribute, and the second parameter is the default value to use if that value is not set. For more information about the various calls to retrieve properties in the config map, see the documentation for the flex.messaging.config.ConfigMap class in the public BlazeDS Javadoc documentation. Each factory instance can add configuration attributes that are used when that factory instance is defined, as the following example shows:</p>
<pre>&lt;destination id="myDestination"&gt;
    &lt;properties&gt;
        &lt;source&gt;mypackage.MyRemoteClass&lt;/source&gt;
        &lt;factory&gt;myFactoryId&lt;/factory&gt;
        &lt;myfactoryinstanceattribute&gt;
            myfoobar2value
        &lt;/myfactoryinstanceattribute&gt;
    &lt;/properties&gt;
&lt;/destination&gt;</pre>
<p>In the <samp>createFactoryInstance()</samp> method as part of the FlexFactory implementation, you access the attribute for that instance of the factory, as the following example shows:</p>
<pre>public FactoryInstance createFactoryInstance(String id, ConfigMap properties) {
    System.out.println("**** MyFactoryInstance instance initialized with myfactoryinstanceattribute=" +
    properties.getPropertyAsString("myfactoryinstanceattribute", "not set"));
….
}

All these info are from http://livedocs.adobe.com/blazeds/1/blazeds_devguide</pre>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.ukoom.com/flex-lc-ds-fds-and-blazeds.htm" title="Flex LC DS FDS and BlazeDS">Flex LC DS FDS and BlazeDS</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/blazeds-factory-mechanism.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex LC DS FDS and BlazeDS</title>
		<link>http://www.ukoom.com/flex-lc-ds-fds-and-blazeds.htm</link>
		<comments>http://www.ukoom.com/flex-lc-ds-fds-and-blazeds.htm#comments</comments>
		<pubDate>Mon, 21 Dec 2009 06:04:26 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Web MVC]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=976</guid>
		<description><![CDATA[* Flex 1.0 [...]]]></description>
			<content:encoded><![CDATA[<p>* Flex 1.0 (includes the SDK and Server) – Released March 2004</p>
<p>* Flex 1.5  – Released Nov 2004</p>
<p>* FDS (Flex Data Services) was decoupled from the Flex SDK in Flex 2.0 – Released 2006</p>
<p>* FDS was renamed LiveCycle Data Services – released as LC DS 2.5 in summer 2007</p>
<p>* LC DS 2.5.1 in fall 2007</p>
<p>* An open source version of remoting and messaging was released as Blaze DS in early 2008</p>
<p>* LC DS 2.6 was released in mid 2008</p>
<p>* LC DS 2.6.1 was released in Nov 2008</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.ukoom.com/blazeds-factory-mechanism.htm" title="BlazeDS factory mechanism">BlazeDS factory mechanism</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/flex-lc-ds-fds-and-blazeds.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Smart GWT FAQ</title>
		<link>http://www.ukoom.com/smart-gwt-faq.htm</link>
		<comments>http://www.ukoom.com/smart-gwt-faq.htm#comments</comments>
		<pubDate>Wed, 25 Nov 2009 06:49:10 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Web MVC]]></category>
		<category><![CDATA[GWT]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=821</guid>
		<description><![CDATA[http://forums.smartclient.com/showthread.php?t=8159
Client Coding

Can I [...]]]></description>
			<content:encoded><![CDATA[<p>http://forums.smartclient.com/showthread.php?t=8159</p>
<p><strong>Client Coding</strong></p>
<ul>
<li><strong><a name="aMix">Can I mix Smart GWT and GWT widgets?</a></strong>
<p>Yes, with caveats.</p>
<p>Smart GWT has interoperability support that allows a Smart GWT widget to be added to a GWT<br />
container and allows a GWT widget to be added to a Smart GWT container, and it&#8217;s appropriate to<br />
use this for:</p>
<ul>
<li>incremental migration to Smart GWT, such as introducing singular, sophisticated Smart GWT<br />
components like the Calendar or CubeGrid to an existing GWT application</li>
<li>using sophisticated third-party GWT widgets within Smart GWT, where Smart GWT doesn&#8217;t have<br />
corresponding built-in functionality</li>
</ul>
<p>However it does <strong>not</strong> make sense to freely intermix Smart GWT and GWT (or other)<br />
components, that is, for example, you should not place GWT widgets within a Smart GWT container<br />
that is in turn within a GWT container.  In general, don&#8217;t intermix widgets unless the need for<br />
a feature forces you to.</p>
<p>The reason for this is that there are limits to the maximum degree that two Ajax widget kits<br />
(including GWT) can interoperate &#8211; there are no standards that allow interoperability in the<br />
areas of management of tab order, zIndex management, pixel-perfect layout, section 508<br />
accessibility and multi-level modality.</p>
<p>Note that &#8220;bugs&#8221; reported when intermixing GWT and Smart GWT inappropriately (that is, in<br />
contradiction to these guidelines) are generally going to be marked WONTFIX, although we will<br />
revisit this in the future if core GWT begins to support APIs that would allow better<br />
interoperability.</li>
<li><strong><a name="aContainer">How do I make a Smart GWT widget fill a basic HTML container or GWT container?</a></strong>
<p>Because Smart GWT&#8217;s pixel-perfect layout and auto-sizing support goes beyond the capabilities of<br />
simple CSS layout, components need to know the actual pixel width they have been allocated;<br />
they cannot &#8220;flow into&#8221; an HTML element of unspecified size.</p>
<p>The issue here is that GWT&#8217;s containers do not provide an API similar to Smart GWT&#8217;s<br />
Canvas.getInnerWidth(), which in Smart GWT can be used by child components to find out<br />
the available space to draw themselves in, and hence recursively lay out out their own<br />
children. Nor do GWT containers they fire events when they are resized, or when the<br />
available width changes for various reasons (e.g. scrollbar(s) introduced, or CSS style<br />
changes add borders and hence reduce space).</p>
<p>A lot of parent&lt;-&gt;child coordination and signaling is required to really create an extensible<br />
pixel-perfect layout system.  Smart GWT/SmartClient has implemented all the necessary hooks to<br />
allow a third-party widget to be embedded inside a Canvas and participate in a precise layout,<br />
but GWT is not there yet.</p>
<p>If you absolutely must place a Smart GWT interface inside a GWT container and you want it to<br />
fill the container, the best approach is to listen for a window-level resize event and run<br />
your own layout calculations that ultimately call resizeTo() on your topmost Smart GWT<br />
widget.  All Smart GWT widgets nested under that topmost widget will then handle layout normally.</p>
<p>NOTE: Don&#8217;t bother trying to find a way to insert width:100% into Smart GWT&#8217;s rendered HTML,<br />
this won&#8217;t work.</li>
</ul>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.ukoom.com/wnd-and-doc-calling-native-javascript-with-jsni.htm" title="$wnd and $doc Calling native JavaScript with JSNI">$wnd and $doc Calling native JavaScript with JSNI</a></li><li><a href="http://www.ukoom.com/gwt-and-documentum.htm" title="GWT and Documentum">GWT and Documentum</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/smart-gwt-faq.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AJAX Upload progress monitor</title>
		<link>http://www.ukoom.com/ajax-upload-progress-monitor.htm</link>
		<comments>http://www.ukoom.com/ajax-upload-progress-monitor.htm#comments</comments>
		<pubDate>Fri, 27 Feb 2009 08:58:00 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web MVC]]></category>
		<category><![CDATA[Ajax]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=567</guid>
		<description><![CDATA[ 
 
Reference:
http://www.telio.be/blog/2006/01/06/ajax-upload-progress-monitor-for-commons-fileupload-example/
Related PostsJQuery ContextMenu [...]]]></description>
			<content:encoded><![CDATA[<p> </p>
<p> </p>
<p>Reference:<br />
<span lang="EN-US"><span style="font-size: small; font-family: Times New Roman;">http://www.telio.be/blog/2006/01/06/ajax-upload-progress-monitor-for-commons-fileupload-example/</span></span></p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.ukoom.com/jquery-contextmenu-plugin.htm" title="JQuery ContextMenu plugin">JQuery ContextMenu plugin</a></li><li><a href="http://www.ukoom.com/remove-title-and-rating-on-embeded-youtube-videos.htm" title="Remove Title and Rating on Embeded YouTube Videos">Remove Title and Rating on Embeded YouTube Videos</a></li><li><a href="http://www.ukoom.com/cool-effect.htm" title="Cool effect">Cool effect</a></li><li><a href="http://www.ukoom.com/auto-complete.htm" title="Auto Complete">Auto Complete</a></li><li><a href="http://www.ukoom.com/chat-with-website-visitors.htm" title="Chat with website visitors">Chat with website visitors</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/ajax-upload-progress-monitor.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upload files by using Struts2</title>
		<link>http://www.ukoom.com/upload-files-by-using-struts2.htm</link>
		<comments>http://www.ukoom.com/upload-files-by-using-struts2.htm#comments</comments>
		<pubDate>Mon, 29 Dec 2008 07:23:04 +0000</pubDate>
		<dc:creator>Rexleed</dc:creator>
				<category><![CDATA[Web MVC]]></category>
		<category><![CDATA[Struts2]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=365</guid>
		<description><![CDATA[The Struts 2 [...]]]></description>
			<content:encoded><![CDATA[<p>The Struts 2 framework provides built-in support for processing file uploads that conform to <span class="nobr"><a title="Visit page outside Confluence" rel="nofollow" href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867<sup><img class="rendericon" src="http://cwiki.apache.org/confluence/images/icons/linkext7.gif" border="0" alt="" width="7" height="7" align="absmiddle" /></sup></a></span>, &#8220;Form-based File Upload in HTML&#8221;. When correctly configured the framework will pass uploaded file(s) into your Action class. Support for individual and multiple file uploads are provided. When a file is uploaded it will typically be stored in a temporary directory. Uploaded files should be processed or moved by your Action class to ensure the data is not lost. Be aware that servers may have a security policy in place that prohibits you from writing to directories other than the temporary directory and the directories that belong to your web application.</p>
<h2>Dependencies</h2>
<p>The Struts 2 framework leverages add-on libraries to handle the parsing of uploaded files. These libraries are not included in the Struts distribution, you must add them into your project. The libraries needed are:</p>
<table class="confluenceTable" border="0">
<tbody>
<tr>
<th class="confluenceTh"> Library</th>
<th class="confluenceTh"> URL</th>
<th class="confluenceTh"> Struts 2.0.x</th>
<th class="confluenceTh"> Struts 2.1.x</th>
</tr>
<tr>
<td class="confluenceTd">Commons-FileUpload</td>
<td class="confluenceTd"><span class="nobr"><a title="Visit page outside Confluence" rel="nofollow" href="http://commons.apache.org/fileupload/">http://commons.apache.org/fileupload/<sup><img class="rendericon" src="http://cwiki.apache.org/confluence/images/icons/linkext7.gif" border="0" alt="" width="7" height="7" align="absmiddle" /></sup></a></span></td>
<td class="confluenceTd">1.1.1</td>
<td class="confluenceTd">1.2.1</td>
</tr>
<tr>
<td class="confluenceTd">Commons-IO</td>
<td class="confluenceTd"><span class="nobr"><a title="Visit page outside Confluence" rel="nofollow" href="http://commons.apache.org/io/">http://commons.apache.org/io/<sup><img class="rendericon" src="http://cwiki.apache.org/confluence/images/icons/linkext7.gif" border="0" alt="" width="7" height="7" align="absmiddle" /></sup></a></span></td>
<td class="confluenceTd">1.0</td>
<td class="confluenceTd">1.3.2</td>
</tr>
</tbody>
</table>
<p>References:</p>
<p>http://www.struts2.org/ajax-file-upload-in-struts2-using-ajax-file-upload-plugin/</p>
<p>http://www.javaeye.com/problems/1818</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.ukoom.com/interceptors-of-struts-2.htm" title="Interceptors of Struts 2">Interceptors of Struts 2</a></li><li><a href="http://www.ukoom.com/formatting-dates-and-numbers-in-struts2.htm" title="Formatting Dates and Numbers in Struts2">Formatting Dates and Numbers in Struts2</a></li><li><a href="http://www.ukoom.com/accessing-application-session-request-objects-in-struts.htm" title="Accessing application, session, request objects in Struts2">Accessing application, session, request objects in Struts2</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/upload-files-by-using-struts2.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interceptors of Struts 2</title>
		<link>http://www.ukoom.com/interceptors-of-struts-2.htm</link>
		<comments>http://www.ukoom.com/interceptors-of-struts-2.htm#comments</comments>
		<pubDate>Mon, 29 Dec 2008 07:18:38 +0000</pubDate>
		<dc:creator>Rexleed</dc:creator>
				<category><![CDATA[Web MVC]]></category>
		<category><![CDATA[Struts2]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=362</guid>
		<description><![CDATA[
Many Actions share [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ukoom.com/wp-content/uploads/2008/12/action-lifecycle.png"><img class="alignnone size-medium wp-image-363" title="action-lifecycle" src="http://www.ukoom.com/wp-content/uploads/2008/12/action-lifecycle-300x201.png" alt="" width="300" height="201" /></a></p>
<p>Many Actions share common concerns. Some Actions need input validated. Other Actions may need a file upload to be pre-processed. Another Action might need protection from a double submit. Many Actions need drop-down lists and other controls pre-populated before the page displays.</p>
<p>The framework makes it easy to share solutions to these concerns using an &#8220;Interceptor&#8221; strategy. When you request a resource that maps to an &#8220;action&#8221;, the framework invokes the Action object. But, before the Action is executed, the invocation can be intercepted by another object. After the Action executes, the invocation could be intercepted again. Unsurprisingly, we call these objects &#8220;Interceptors.&#8221;</p>
<p>Interceptors can execute code before and after an Action is invoked. Most of the framework&#8217;s core functionality is implemented as Interceptors. Features like double-submit guards, type conversion, object population, validation, file upload, page preparation, and more, are all implemented with the help of Interceptors. Each and every Interceptor is pluggable, so you can decide exactly which features an Action needs to support.</p>
<p>Interceptors can be configured on a per-action basis. Your own custom Interceptors can be mixed-and-matched with the Interceptors bundled with the framework. Interceptors &#8220;set the stage&#8221; for the Action classes, doing much of the &#8220;heavy lifting&#8221; before the Action executes.</p>
<p>In some cases, an Interceptor might keep an Action from firing, because of a double-submit or because validation failed. Interceptors can also change the state of an Action before it executes.</p>
<p>The Interceptors are defined in a stack that specifies the execution order. In some cases, the order of the Interceptors on the stack can be very important.</p>
<p>References:</p>
<p>http://docs.huihoo.com/apache/struts/apache-struts-2-document/interceptors.html</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.ukoom.com/upload-files-by-using-struts2.htm" title="Upload files by using Struts2">Upload files by using Struts2</a></li><li><a href="http://www.ukoom.com/formatting-dates-and-numbers-in-struts2.htm" title="Formatting Dates and Numbers in Struts2">Formatting Dates and Numbers in Struts2</a></li><li><a href="http://www.ukoom.com/accessing-application-session-request-objects-in-struts.htm" title="Accessing application, session, request objects in Struts2">Accessing application, session, request objects in Struts2</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/interceptors-of-struts-2.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Formatting Dates and Numbers in Struts2</title>
		<link>http://www.ukoom.com/formatting-dates-and-numbers-in-struts2.htm</link>
		<comments>http://www.ukoom.com/formatting-dates-and-numbers-in-struts2.htm#comments</comments>
		<pubDate>Fri, 19 Dec 2008 00:32:13 +0000</pubDate>
		<dc:creator>Rexleed</dc:creator>
				<category><![CDATA[Web MVC]]></category>
		<category><![CDATA[Struts2]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=324</guid>
		<description><![CDATA[Defining Formats
Struts2 supports [...]]]></description>
			<content:encoded><![CDATA[<h2>Defining Formats</h2>
<p>Struts2 supports localization (l10n) aware formatting of dates, times and numbers very easily, utilizing Java&#8217;s built-in date formatting features.</p>
<p>As seen in the <a title="Localization" href="http://struts.apache.org/2.x/docs/localization.html">Localization</a> chapter, it is quite easy to define hierarchical resource bundles with Struts2, giving the developer the opportunity to define locale dependent message formats. This is the entry point to define the needed date, time and number formats. Your default properties could contain the following generic formats:</p>
<div class="code">
<div class="codeContent">
<pre class="code-java">format.time = {0,time}
format.number = {0,number,#0.0##}
format.percent = {0,number,##0.00'%'}
format.money = {0,number,\u00A4##0.00}</pre>
</div>
</div>
<p>An appropriate en_US format definition extension could look like this:</p>
<div class="code">
<div class="codeContent">
<pre class="code-java">format.date = {0,date,MM/dd/yy}</pre>
</div>
</div>
<p>In parallel, you could add the following to your de_DE bundle:</p>
<div class="code">
<div class="codeContent">
<pre class="code-java">format.date = {0,date,dd.MM.yyyy}</pre>
</div>
</div>
<p>Read more on how to define message formats in Sun&#8217;s Java API docs for <span class="nobr"><a title="Visit page outside Confluence" rel="nofollow" href="http://java.sun.com/j2se/1.5.0/docs/api/java/text/MessageFormat.html">MessageFormat<sup><img class="rendericon" src="http://cwiki.apache.org/confluence/images/icons/linkext7.gif" border="0" alt="" width="7" height="7" align="absmiddle" /></sup></a></span>.</p>
<p>Now that we have our formats set up, it is quite easy to use them in our views.</p>
<h2><a name="FormattingDatesandNumbers-Formattingoutputusingthes:texttag"></a>Formatting output using the s:text tag</h2>
<p>Given you had a Float value myMoneyValue, accessible through the getter getMyMoneyValue in your action, the following code would print out localized representation of the value as a currency amount, using the format.money message format defined above with a <a title="text" href="http://struts.apache.org/2.x/docs/text.html">s:text</a> tag:</p>
<div class="code">
<div class="codeContent">
<pre class="code-java">&lt;s:text name=<span class="code-quote">"format.money"</span>&gt;
    &lt;s:param name=<span class="code-quote">"value"</span> value=<span class="code-quote">"myMoneyValue"</span>/&gt;

References:
http://struts.apache.org/2.x/docs/formatting-dates-and-numbers.html
&lt;/s:text&gt;</pre>
</div>
</div>
<p>The (first) parameter defines the value which is to replace the &#8216;0&#8242; placeholder in the defined message format.<br />
Another example, formatting a date value:</p>
<div class="code">
<div class="codeContent">
<pre class="code-java">&lt;s:text name=<span class="code-quote">"format.date"</span>&gt;&lt;s:param value=<span class="code-quote">"dueDate"</span>/&gt;&lt;/s:text&gt;</pre>
</div>
</div>
<table class="noteMacro" border="0" cellspacing="8" cellpadding="5" width="85%" align="center">
<colgroup>
<col width="24"></col>
<col></col>
</colgroup>
<tbody>
<tr>
<td valign="top"><img src="http://cwiki.apache.org/confluence/images/icons/emoticons/warning.gif" border="0" alt="" width="16" height="16" align="absmiddle" /></td>
<td>While the s:text tag is very useful to format numbers, date formatting has become a lot easier thanks to the <a title="date" href="http://struts.apache.org/2.x/docs/date.html">s:date</a> tag.</td>
</tr>
</tbody>
</table>
<h2><a name="FormattingDatesandNumbers-LocalizingformdatawithgetText"></a>Localizing form data with getText</h2>
<p>Placing a textfield in a form like this</p>
<div class="code">
<div class="codeContent">
<pre class="code-java">&lt;s:textfield key=<span class="code-quote">"orderItem.price"</span> /&gt;</pre>
</div>
</div>
<p>to input a number, one might have noticed that the number is always shown in the Java default number format. Not only that this is not &#8220;nice&#8221;, if you are in a non-en locale, it will also cause trouble when submitting the form since type conversion is locale aware. The solution is to again use the message formats as defined above, by using the getText Method of ActionSupport:</p>
<div class="code">
<div class="codeContent">
<pre class="code-java">&lt;s:textfield key=<span class="code-quote">"orderItem.price"</span> value=<span class="code-quote">"%{getText('format.number',{'orderItem.price'})}"</span> /&gt;</pre>
</div>
</div>
<p>This maps to the method signature getText( String key, Object[] params ) in ActionSupport.</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.ukoom.com/upload-files-by-using-struts2.htm" title="Upload files by using Struts2">Upload files by using Struts2</a></li><li><a href="http://www.ukoom.com/interceptors-of-struts-2.htm" title="Interceptors of Struts 2">Interceptors of Struts 2</a></li><li><a href="http://www.ukoom.com/accessing-application-session-request-objects-in-struts.htm" title="Accessing application, session, request objects in Struts2">Accessing application, session, request objects in Struts2</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/formatting-dates-and-numbers-in-struts2.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
