Author: musachy Date: Sat Feb 24 08:41:38 2007 New Revision: 511300 URL: http://svn.apache.org/viewvc?view=rev&rev=511300 Log: WW-1766 div tag needs the scriptSeparation attribute
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Div.java struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/DivTag.java struts/struts2/trunk/core/src/main/resources/template/ajax/div.ftl struts/struts2/trunk/core/src/site/resources/tags/div.html struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/DivTest.java struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/div-1.txt Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Div.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Div.java?view=diff&rev=511300&r1=511299&r2=511300 ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Div.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Div.java Sat Feb 24 08:41:38 2007 @@ -77,6 +77,7 @@ * 'indicator' element to be shown while the request executing<p/> * 'showErrorTransportText': whether errors should be displayed (on 'targets')</p> * 'showLoadingText' show loading text on targets</p> + * 'separateScript' Run scripts in a separate scope, unique for each Div<p/> * 'notifyTopics' comma separated list of topics names, that will be published. Three parameters are passed:<p/> * <ul> * <li>data: html or json object when type='load' or type='error'</li> @@ -117,6 +118,7 @@ protected String startTimerListenTopics; protected String stopTimerListenTopics; protected String refreshOnShow; + protected String separateScripts; public Div(ValueStack stack, HttpServletRequest request, HttpServletResponse response) { super(stack, request, response); @@ -145,6 +147,8 @@ addParameter("startTimerListenTopics", findString(startTimerListenTopics)); if (stopTimerListenTopics != null) addParameter("stopTimerListenTopics", findString(stopTimerListenTopics)); + if (separateScripts != null) + addParameter("separateScripts", findValue(separateScripts, Boolean.class)); } @StrutsTagAttribute(description="Start timer automatically", type="Boolean", defaultValue="true") @@ -180,5 +184,10 @@ @StrutsTagAttribute(description="Deprecated. Use 'notifyTopics'. Javascript code execute after reload") public void setAfterLoading(String afterLoading) { this.afterLoading = afterLoading; + } + + @StrutsTagAttribute(description="Run scripts in a separate scope, unique for each Div", defaultValue="true") + public void setSeparateScripts(String separateScripts) { + this.separateScripts = separateScripts; } } Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/DivTag.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/DivTag.java?view=diff&rev=511300&r1=511299&r2=511300 ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/DivTag.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/DivTag.java Sat Feb 24 08:41:38 2007 @@ -38,7 +38,8 @@ protected String startTimerListenTopics; protected String stopTimerListenTopics; protected String refreshOnShow; - + protected String separateScripts; + public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) { return new Div(stack, req, res); } @@ -53,6 +54,7 @@ div.setStartTimerListenTopics(startTimerListenTopics); div.setStopTimerListenTopics(stopTimerListenTopics); div.setRefreshOnShow(refreshOnShow); + div.setSeparateScripts(separateScripts); } public void setAutoStart(String autoStart) { @@ -77,5 +79,9 @@ public void setRefreshOnShow(String refreshOnShow) { this.refreshOnShow = refreshOnShow; + } + + public void setSeparateScripts(String separateScripts) { + this.separateScripts = separateScripts; } } Modified: struts/struts2/trunk/core/src/main/resources/template/ajax/div.ftl URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/template/ajax/div.ftl?view=diff&rev=511300&r1=511299&r2=511300 ============================================================================== --- struts/struts2/trunk/core/src/main/resources/template/ajax/div.ftl (original) +++ struts/struts2/trunk/core/src/main/resources/template/ajax/div.ftl Sat Feb 24 08:41:38 2007 @@ -17,6 +17,9 @@ <#if parameters.refreshOnShow?exists> refreshOnShow="${parameters.refreshOnShow?string?html}"<#rt/> </#if> + <#if parameters.separateScripts?exists> + scriptSeparation="${parameters.separateScripts?string?html}"<#rt/> + </#if> <#include "/${parameters.templateDir}/ajax/ajax-common.ftl" /> <#include "/${parameters.templateDir}/simple/scripting-events.ftl" /> > Modified: struts/struts2/trunk/core/src/site/resources/tags/div.html URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/site/resources/tags/div.html?view=diff&rev=511300&r1=511299&r2=511300 ============================================================================== --- struts/struts2/trunk/core/src/site/resources/tags/div.html (original) +++ struts/struts2/trunk/core/src/site/resources/tags/div.html Sat Feb 24 08:41:38 2007 @@ -348,6 +348,14 @@ <td align="left" valign="top">Define required position of required form element (left|right)</td> </tr> <tr> + <td align="left" valign="top">separateScripts</td> + <td align="left" valign="top">false</td> + <td align="left" valign="top">true</td> + <td align="left" valign="top">true</td> + <td align="left" valign="top">String</td> + <td align="left" valign="top">Run scripts in a separate scope, unique for each Div</td> + </tr> + <tr> <td align="left" valign="top">showErrorTransportText</td> <td align="left" valign="top">false</td> <td align="left" valign="top">true</td> Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/DivTest.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/DivTest.java?view=diff&rev=511300&r1=511299&r2=511300 ============================================================================== --- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/DivTest.java (original) +++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/DivTest.java Sat Feb 24 08:41:38 2007 @@ -68,6 +68,7 @@ tag.setHandler("l"); tag.setIndicator("m"); tag.setShowLoadingText("true"); + tag.setSeparateScripts("false"); tag.doStartTag(); tag.doEndTag(); Modified: struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/div-1.txt URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/div-1.txt?view=diff&rev=511300&r1=511299&r2=511300 ============================================================================== --- struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/div-1.txt (original) +++ struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/div-1.txt Sat Feb 24 08:41:38 2007 @@ -6,6 +6,7 @@ startTimerListenTopics="h" stopTimerListenTopics="i" refreshOnShow="true" + scriptSeparation="false" id="mylabel" href="a" loadingText="b"