Author: tmjee Date: Sat Jun 10 11:50:10 2006 New Revision: 413351 URL: http://svn.apache.org/viewvc?rev=413351&view=rev Log: WW-1338 - <saf:div ..> tag should be able to not auto start and depend make remote connection only when a topic of interest is received
Added: struts/action2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example8.jsp (with props) Modified: struts/action2/trunk/apps/showcase/src/main/webapp/WEB-INF/classes/struts.properties struts/action2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/index.jsp struts/action2/trunk/apps/showcase/src/main/webapp/ajax/remotelink/index.jsp struts/action2/trunk/core/src/main/java/org/apache/struts/action2/components/Div.java struts/action2/trunk/core/src/main/resources/template/ajax/div.ftl Modified: struts/action2/trunk/apps/showcase/src/main/webapp/WEB-INF/classes/struts.properties URL: http://svn.apache.org/viewvc/struts/action2/trunk/apps/showcase/src/main/webapp/WEB-INF/classes/struts.properties?rev=413351&r1=413350&r2=413351&view=diff ============================================================================== --- struts/action2/trunk/apps/showcase/src/main/webapp/WEB-INF/classes/struts.properties (original) +++ struts/action2/trunk/apps/showcase/src/main/webapp/WEB-INF/classes/struts.properties Sat Jun 10 11:50:10 2006 @@ -7,3 +7,6 @@ #struts.action.extension=jspa struts.url.http.port = 8080 struts.freemarker.manager.classname=customFreemarkerManager + +struts.serve.static=true +struts.serve.static.browserCache=false Added: struts/action2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example8.jsp URL: http://svn.apache.org/viewvc/struts/action2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example8.jsp?rev=413351&view=auto ============================================================================== --- struts/action2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example8.jsp (added) +++ struts/action2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example8.jsp Sat Jun 10 11:50:10 2006 @@ -0,0 +1,27 @@ + +<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@ taglib prefix="saf" uri="/struts-action" %> + +<html> +<head> + <title>Ajax Examples</title> + <jsp:include page="/ajax/commonInclude.jsp"/> +</head> + +<body> + +<saf:div + id="once" + theme="ajax" + cssStyle="border: 1px solid yellow;" + href="/AjaxTest.action" + updateFreq="0" + delay="0"> + Initial Content ... should not change</saf:div> + +<saf:include value="../footer.jsp"/> + +</body> +</html> + + Propchange: struts/action2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example8.jsp ------------------------------------------------------------------------------ svn:eol-style = native Modified: struts/action2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/index.jsp URL: http://svn.apache.org/viewvc/struts/action2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/index.jsp?rev=413351&r1=413350&r2=413351&view=diff ============================================================================== --- struts/action2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/index.jsp (original) +++ struts/action2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/index.jsp Sat Jun 10 11:50:10 2006 @@ -40,6 +40,10 @@ <li> <a href="example7.jsp">A div that calls the server, and JS in the resulting page is executed</a> </li> + + <li> + <a href="example8.jsp">A div that will not update itself (updateFreq=0 and delay=0)</a> + </li> </ol> Modified: struts/action2/trunk/apps/showcase/src/main/webapp/ajax/remotelink/index.jsp URL: http://svn.apache.org/viewvc/struts/action2/trunk/apps/showcase/src/main/webapp/ajax/remotelink/index.jsp?rev=413351&r1=413350&r2=413351&view=diff ============================================================================== --- struts/action2/trunk/apps/showcase/src/main/webapp/ajax/remotelink/index.jsp (original) +++ struts/action2/trunk/apps/showcase/src/main/webapp/ajax/remotelink/index.jsp Sat Jun 10 11:50:10 2006 @@ -40,6 +40,18 @@ delay="1000">Initial Content</saf:div> <br/><br/> +Fourth Component: +<saf:div + id="four" + theme="ajax" + cssStyle="border: 1px solid yellow;" + href="/AjaxTest.action" + listenTopics="myLink3_click" + delay="0" + updateFreq="0">Initial Content</saf:div> +<br/><br/> + + <saf:url id="remoteLink" value ="/AjaxRemoteLink.action" /> <saf:url id="testLink" value ="/AjaxTest.action" /> @@ -66,7 +78,7 @@ Remote DIV that is not connected to any remote links: <saf:div - id="four" + id="five" cssStyle="border: 1px solid yellow;" href="/AjaxTest.action" theme="ajax" @@ -82,6 +94,16 @@ showErrorTransportText="true" errorText="An Error ocurred">Update </saf:a> +<br/><br/> + +A Remote link that will update "Fourth Component" +<saf:a + id="link4" + theme="ajax" + href="%{remoteLink}" + notifyTopics="myLink3_click" + showErrorTransportText="true" + errorText="An Error Ocurred">Update</saf:a> <br/><br/> <saf:include value="../footer.jsp"/> Modified: struts/action2/trunk/core/src/main/java/org/apache/struts/action2/components/Div.java URL: http://svn.apache.org/viewvc/struts/action2/trunk/core/src/main/java/org/apache/struts/action2/components/Div.java?rev=413351&r1=413350&r2=413351&view=diff ============================================================================== --- struts/action2/trunk/core/src/main/java/org/apache/struts/action2/components/Div.java (original) +++ struts/action2/trunk/core/src/main/java/org/apache/struts/action2/components/Div.java Sat Jun 10 11:50:10 2006 @@ -18,6 +18,9 @@ package org.apache.struts.action2.components; import com.opensymphony.xwork.util.OgnlValueStack; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.struts.action2.views.util.UrlHelper; import javax.servlet.http.HttpServletRequest; @@ -49,6 +52,9 @@ * description="Render HTML div providing content from remote call via AJAX" */ public class Div extends RemoteCallUIBean { + + private static final Log _log = LogFactory.getLog(Div.class); + public static final String TEMPLATE = "div"; public static final String TEMPLATE_CLOSE = "div-close"; @@ -84,6 +90,22 @@ addParameter("delay", findString(delay)); } else { addParameter("delay", "0"); + } + + String tmpUpdateFreq = (String) getParameters().get("delay"); + String tmpDelay = (String) getParameters().get("updateFreq"); + try { + int _updateFreq = Integer.parseInt(tmpUpdateFreq); + int _delay = Integer.parseInt(tmpDelay); + + if (_updateFreq <= 0 && _delay <= 0) { + addParameter("autoStart", "false"); + } + } + catch(NumberFormatException e) { + // too bad, invalid updateFreq or delay provided, we + // can't determine autoStart mode. + _log.info("error while parsing updateFreq ["+tmpUpdateFreq+"] or delay ["+tmpDelay+"] to integer, cannot determine autoStart mode", e); } if (loadingText != null) { Modified: struts/action2/trunk/core/src/main/resources/template/ajax/div.ftl URL: http://svn.apache.org/viewvc/struts/action2/trunk/core/src/main/resources/template/ajax/div.ftl?rev=413351&r1=413350&r2=413351&view=diff ============================================================================== --- struts/action2/trunk/core/src/main/resources/template/ajax/div.ftl (original) +++ struts/action2/trunk/core/src/main/resources/template/ajax/div.ftl Sat Jun 10 11:50:10 2006 @@ -10,7 +10,8 @@ <#if parameters.updateFreq?exists>refresh='${parameters.updateFreq}'</#if> <#if parameters.listenTopics?exists>listenTopics='${parameters.listenTopics}'</#if> <#if parameters.afterLoading?exists>onLoad='${parameters.afterLoading}'</#if> - + <#if parameters.autoStart?exists>autoStart='${parameters.autoStart}'</#if> + <#if parameters.tabindex?exists> tabindex="${parameters.tabindex?html}"<#rt/> </#if>