Commits

tm_jee  committed 0dd31d6

- added a tab panel wizard to showcase example
- it is basically a tab panels that uses scope interceptor to remember states of each tab when save button is clicked, when end button is clicked it uses the scope interceptor to clear out all the states saved previously.

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

  • Participants
  • Parent commits 29efdfe

Comments (0)

Files changed (4)

File webapps/showcase/src/java/com/opensymphony/webwork/showcase/wizard/TabbedWizardAction.java

+/**
+ * 
+ */
+package com.opensymphony.webwork.showcase.wizard;
+
+import com.opensymphony.xwork.ActionSupport;
+
+/**
+ * @author tmjee
+ *
+ */
+public class TabbedWizardAction extends ActionSupport {
+
+	private String name;
+	private String age;
+	private String gender;
+	private String favouriteColor;
+	
+	public String input() throws Exception {
+		print();
+		return SUCCESS;
+	}
+	
+	public String saveTabOne() throws Exception {
+		print();
+		return SUCCESS;
+	}
+	
+	public String saveTabTwo() throws Exception {
+		print();
+		return SUCCESS;
+	}
+	
+	public String end() throws Exception {
+		print();
+		return SUCCESS;
+	}
+	
+	void print() {
+		System.out.println("*** name="+name);
+		System.out.println("*** age="+age);
+		System.out.println("*** gender="+gender);
+		System.out.println("*** favouriteColor="+favouriteColor);
+	}
+
+	public String getAge() {
+		return age;
+	}
+
+	public void setAge(String age) {
+		this.age = age;
+	}
+
+	public String getFavouriteColor() {
+		return favouriteColor;
+	}
+
+	public void setFavouriteColor(String favouriteColor) {
+		this.favouriteColor = favouriteColor;
+	}
+
+	public String getGender() {
+		return gender;
+	}
+
+	public void setGender(String gender) {
+		this.gender = gender;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+}

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

 			<result name="input">/wizard/step2.jsp</result>
 			<result name="success">/wizard/step1.jsp</result>
 		</action>
+		
+		
+		
+		
+		<action name="startTabbedWizard" class="com.opensymphony.webwork.showcase.wizard.TabbedWizardAction" method="input">
+			<interceptor-ref name="scope">
+				<param name="key">tabbedWizard</param>
+				<param name="session">name,age,gender,favouriteColor</param>
+				<param name="type">start</param>
+			</interceptor-ref>
+			<interceptor-ref name="defaultStack" />
+			<result>/wizard/tabbedPanel.jsp</result>
+		</action>
+		
+		<action name="saveTabOne" class="com.opensymphony.webwork.showcase.wizard.TabbedWizardAction" method="saveTabOne">
+			<interceptor-ref name="scope">
+				<param name="key">tabbedWizard</param>
+				<param name="session">name,age,gender,favouriteColor</param>
+			</interceptor-ref>
+			<interceptor-ref name="defaultStack" />
+			<result>/wizard/tabbedPanel.jsp</result>
+		</action>
+		
+		<action name="saveTabTwo" class="com.opensymphony.webwork.showcase.wizard.TabbedWizardAction" method="saveTabTwo">
+			<interceptor-ref name="scope">
+				<param name="key">tabbedWizard</param>
+				<param name="session">name,age,gender,favouriteColor</param>
+			</interceptor-ref>
+			<interceptor-ref name="defaultStack" />
+			<result>/wizard/tabbedPanel.jsp</result>
+		</action>
+		
+		<action name="endTabbedWizard" class="com.opensymphony.webwork.showcase.wizard.TabbedWizardAction" method="end">
+			<interceptor-ref name="scope">
+				<param name="key">tabbedWizard</param>
+				<param name="session">name,age,gender,favouriteColor</param>
+				<param name="type">end</param>
+			</interceptor-ref>
+			<interceptor-ref name="defaultStack" />
+			<result type="redirect">/wizard/tabbedPanel.jsp</result>
+		</action>
 	</package>
 </xwork>
 

File webapps/showcase/src/webapp/wizard/index.jsp

 
 	<ww:url id="url" action="start" namespace="/wizard" />	
 	<ww:a href="%{#url}">Wizard Example</ww:a>
+	<ww:url id="url" action="startTabbedWizard" namespace="wizard" />
+	<ww:a href="%{#url}">Tabbed Panel Wizard Example</ww:a>
 	
 </body>
 </html>

File webapps/showcase/src/webapp/wizard/tabbedPanel.jsp

+<%@ page language="java" contentType="text/html; charset=UTF-8"
+    pageEncoding="UTF-8"%>
+<%@taglib prefix="ww" uri="/webwork" %>    
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Insert title here</title>
+<ww:head theme="ajax" />
+<link rel="stylesheet" type="text/css" href="<ww:url value="/webwork/tabs.css"/>">
+</head>
+<body>
+
+<ww:tabbedPanel id="tabpanel">
+	<ww:panel id="one" tabName="One" theme="ajax" >
+		<ww:form namespace="/wizard" method="post">
+			<ww:textfield name="name" label="Name" />
+			<ww:textfield name="age" label="Age" />
+			<ww:submit action="saveTabOne" value="Save" />
+			<ww:submit action="endTabbedWizard" value="End" />
+		</ww:form>
+	</ww:panel>
+	<ww:panel id="two" tabName="Two" theme="ajax" >
+		<ww:form namespace="/wizard" method="post">
+			<ww:radio list="%{#{'MALE':'Male', 'FEMALE':'Female'}}" label="Gender" name="gender"  />
+			<ww:select list="%{#{'RED':'Red', 'GREEN':'Green', 'BLUE':'Blue'}}" label="Favourite Color" name="favouriteColor"  />
+			<ww:submit action="saveTabTwo" value="Save" />
+			<ww:submit action="endTabbedWizard" value="End" />
+		</ww:form>
+	</ww:panel>
+</ww:tabbedPanel>
+
+
+</body>
+</html>