Commits

Anonymous committed 2e5e30e

- WW-1166
- AJAX submit button with action parameter does not submit with action in the query parameters in Firefox 1.5
- added an example of such usage into showcase

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@2863573baa09-0c28-0410-bef9-dab3c582ae83

Comments (0)

Files changed (8)

webapps/showcase/src/java/com/opensymphony/webwork/showcase/ajax/AjaxTestAction.java

+/*
+ * Copyright (c) 2002-2007 by OpenSymphony
+ * All rights reserved.
+ */
 package com.opensymphony.webwork.showcase.ajax;
 
 import com.opensymphony.xwork.Action;

webapps/showcase/src/java/com/opensymphony/webwork/showcase/ajax/Example4ShowPanelAction.java

+/*
+ * Copyright (c) 2002-2007 by OpenSymphony
+ * All rights reserved.
+ */
 package com.opensymphony.webwork.showcase.ajax;
 
 import java.text.SimpleDateFormat;
 
 import com.opensymphony.xwork.ActionSupport;
 
+/**
+ * @version $Date$ $Id$
+ */
 public class Example4ShowPanelAction extends ActionSupport {
 
 	private String name;

webapps/showcase/src/java/com/opensymphony/webwork/showcase/ajax/MultipleRemoteButtonExampleAction.java

+/*
+ * Copyright (c) 2002-2007 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.webwork.showcase.ajax;
+
+import com.opensymphony.xwork.ActionSupport;
+
+/**
+ * @author tmjee
+ * @version $Date$ $Id$
+ */
+public class MultipleRemoteButtonExampleAction extends ActionSupport {
+
+	private static final long serialVersionUID = -838186476463481758L;
+	
+	private String buttonName;
+	
+	public String getButtonName() { return this.buttonName; }
+	
+	public String executeButton1() throws Exception {
+		buttonName = "Button 1";
+		return SUCCESS;
+	}
+	
+	public String executeButton2() throws Exception {
+		buttonName = "Button 2";
+		return SUCCESS;
+	}
+	
+	public String executeButton3() throws Exception {
+		buttonName = "Button 3";
+		return SUCCESS;
+	}
+	
+}

webapps/showcase/src/webapp/WEB-INF/classes/xwork-ajax.xml

         	<interceptor-ref name="defaultStack" />
     		<result type="freemarker">/ajax/tabbedpanel/nodecorate/panel3Submit.ftl</result>
     	</action>
+    	
+    	
+    	<action name="GetGreetingAndCurrentTime" class="com.opensymphony.webwork.showcase.ajax.MultipleRemoteButtonExampleAction">
+    		<result>/ajax/remoteforms/greetingAndCurrentTime.jsp</result>
+    	</action>
+    	<action name="button1" class="com.opensymphony.webwork.showcase.ajax.MultipleRemoteButtonExampleAction" method="executeButton1">
+    		<result>/ajax/remoteforms/greetingAndCurrentTime.jsp</result>
+    	</action>
+    	<action name="button2" class="com.opensymphony.webwork.showcase.ajax.MultipleRemoteButtonExampleAction" method="executeButton2">
+    		<result>/ajax/remoteforms/greetingAndCurrentTime.jsp</result>
+    	</action>
+    	<action name="button3" class="com.opensymphony.webwork.showcase.ajax.MultipleRemoteButtonExampleAction" method="executeButton3">
+    		<result>/ajax/remoteforms/greetingAndCurrentTime.jsp</result>
+    	</action>
     </package>
     
 </xwork>

webapps/showcase/src/webapp/ajax/remoteforms/example1.jsp

 
 <html>
 <head>
-    <title>Ajax Examples</title>
+    <title>Ajax Examples - Example 1</title>
     <jsp:include page="/ajax/commonInclude.jsp"/>
 
     <script language="JavaScript" type="text/javascript">

webapps/showcase/src/webapp/ajax/remoteforms/example2.jsp

+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ taglib prefix="ww" uri="/webwork" %>
+
+<html>
+<head>
+    <title>Ajax Examples - Example 2</title>
+    <jsp:include page="/ajax/commonInclude.jsp"/>
+</head>
+<body>
+	
+	<div id="result">
+		Initial content ...
+	</div>
+	
+	<ww:form action="GetGreetingAndCurrentTime" theme="ajax" namespace="/nodecorate">
+		<ww:textfield label="Name" name="name" value="Toby" />
+		
+		<ww:submit action="button1" id="buttonId1" theme="ajax" value="Button 1" resultDivId="result" />
+		<ww:submit action="button2" id="buttonId2" theme="ajax" value="Button 2" resultDivId="result" />
+		<ww:submit action="button3" id="buttonId3" theme="ajax" value="Button 3" resultDivId="result" />
+	</ww:form>
+	
+	
+</body>
+</html>
+

webapps/showcase/src/webapp/ajax/remoteforms/greetingAndCurrentTime.jsp

+<%@ page language="java" contentType="text/html; charset=UTF-8"
+    pageEncoding="UTF-8"%>
+<%@taglib prefix="ww" uri="/webwork" %>
+    
+<%
+response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
+response.setHeader("Pragma","no-cache"); //HTTP 1.0
+response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
+%>
+
+Hello <%=request.getParameter("name") %> <br/>
+You clicked on <ww:property value="%{buttonName}" /><br/>
+The current time is <%=System.currentTimeMillis() %>    
+    

webapps/showcase/src/webapp/ajax/remoteforms/index.jsp

 <html>
 <head>
     <title>Ajax Examples</title>
-    <jsp:include page="/ajax/commonInclude.jsp"/>
-
-    <script language="JavaScript" type="text/javascript">
-        function doSomething() {
-            alert('you can manipulate the form before it gets submitted');
-            return true;
-        }
-    </script>
-
 </head>
 
 <body>
 
-
-Remote form replacing another div:<br/>
-
-<div id='two' style="border: 1px solid yellow;"><b>initial content</b></div>
-<ww:form
-        id='theForm2'
-        cssStyle="border: 1px solid green;"
-        action='AjaxRemoteForm'
-        method='post'
-        theme="ajax">
-
-    <input type='text' name='data' value='WebWork User'>
-
-    <ww:submit value="GO2" theme="ajax" resultDivId="two"/>
-
-</ww:form>
-
-
-Remote form replacing the forms content:<br/>
-<ww:form
-        id='theForm3'
-        cssStyle="border: 1px solid green;"
-        action='AjaxRemoteForm'
-        method='post'
-        theme="ajax">
-
-    <input type='text' name='data' value='WebWork User'>
-
-    <ww:submit value="GO3" theme="ajax" resultDivId="theForm3"/>
-
-</ww:form>
-
-Remote form evaluating suplied JS on completion:<br/>
-<ww:form
-        id='theForm4'
-        cssStyle="border: 1px solid green;"
-        action='AjaxRemoteForm'
-        method='post'
-        theme="ajax">
-
-    <input type='text' name='data' value='WebWork User'>
-
-    <ww:submit value="GO4" theme="ajax" onLoadJS="alert('form submitted');"/>
-
-</ww:form>
-
-Remote form replacing the forms content after confirming results:<br/>
-<ww:form
-        id='theForm5'
-        cssStyle="border: 1px solid green;"
-        action='AjaxRemoteForm'
-        method='post'
-        theme="ajax">
-
-    <input type='text' name='data' value='WebWork User'>
-
-    <ww:submit value="GO5" theme="ajax" resultDivId="theForm5" preInvokeJS="confirm('sure?');"/>
-
-</ww:form>
-
-Remote form replacing the forms content after running a function:<br/>
-<ww:form
-        id='theForm6'
-        cssStyle="border: 1px solid green;"
-        action='AjaxRemoteForm'
-        method='post'
-        theme="ajax">
-
-    <input type='text' name='data' value='WebWork User'>
-
-    <ww:submit value="GO6" theme="ajax" resultDivId="theForm6" preInvokeJS="doSomething();"/>
-
-</ww:form>
-
-A form with no remote submit (so should not be ajaxified):<br/>
-<ww:form
-        id='theForm7'
-        cssStyle="border: 1px solid green;"
-        action='AjaxRemoteForm'
-        method='post'
-        theme="ajax">
-
-    <input type='text' name='data' value='WebWork User'>
-
-    <ww:submit value="Go AWAY" resultDivId="theForm7" />
-
-</ww:form>
+<ul>
+	<li>
+		<ww:url id="url" value="example1.jsp" />
+		<ww:a href="%{#url}">Remote form example with one submit button (webwork:BindButton)</ww:a>
+	</li>
+	<li>
+		<ww:url id="url" value="example2.jsp" />
+		<ww:a href="%{#url}">Remote form example with multiple submit button (webwork:BindButton)</ww:a>
+	</li>
+</ul>
 
 <ww:include value="../footer.jsp"/>