Commits

Anonymous committed bb48beb

Some Changes to the UI-Example

* make the UI-Tag example submitable, and dispatch to another page where the properties of the respective components from previous page is displayed

* added a new Select tag (favourite languages) where the list are obtained at the action class, instead of on-the-fly using ognl expression like anohter Select tag (favorite color)

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

  • Participants
  • Parent commits 8507857

Comments (0)

Files changed (3)

File webapps/showcase/src/java/com/opensymphony/webwork/showcase/UITagExample.java

 
 import com.opensymphony.xwork.ActionSupport;
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.io.File;
     File picture;
     String pictureContentType;
     String pictureFileName;
+    String favouriteLanguage;
+    
+    List favouriteLanguages = new ArrayList();
+    
+    public UITagExample() {
+    	favouriteLanguages.add(new Language("EnglishKey", "English Language"));
+    	favouriteLanguages.add(new Language("FrenchKey", "French Language"));
+    	favouriteLanguages.add(new Language("SpanishKey", "Spanish Language"));
+    }
+    
+    public List getFavouriteLanguages() {
+    	return favouriteLanguages;
+    }
 
     public String execute() throws Exception {
         return SUCCESS;
     public void setPictureFileName(String pictureFileName) {
         this.pictureFileName = pictureFileName;
     }
+    
+    public void setFavouriteLanguage(String favouriteLanguage) {
+    	this.favouriteLanguage = favouriteLanguage;
+    }
+    
+    public String getFavouriteLanguage() {
+    	return favouriteLanguage;
+    }
+    
+    public String doSubmit() {
+    	return SUCCESS;
+    }
+    
+    
+    
+    
+    
+    // === inner class 
+    public static class Language {
+    	String description;
+    	String key;
+    	
+    	public Language(String key, String description) {
+    		this.key = key;
+    		this.description = description;
+    	}
+    	
+    	public String getKey() { return key; }
+    	public String getDescription() { return description; }
+    	
+    }
 }

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

             <result>example.jsp</result>
             <result name="input">example.jsp</result>
         </action>
+        <action name="exampleSubmit" class="com.opensymphony.webwork.showcase.UITagExample" method="submit">
+        	<result>exampleSubmited.jsp</result>
+        </action>
     </package>
 </xwork>

File webapps/showcase/src/webapp/tags/ui/example.jsp

 
 <body>
 
-<ww:form method="post" enctype="multipart/form-data">
+<ww:form action="exampleSubmit" method="post" enctype="multipart/form-data">
     <ww:textfield label="Name" name="name"/>
     <ww:datepicker label="Birthday" name="birthday"/>
     <ww:textarea label="Biograph" name="bio" cols="20" rows="3"/>
     <ww:select label="Favorite Color" list="{'Red', 'Blue', 'Green'}" name="favoriteColor"
             emptyOption="true" headerKey="None" headerValue="None"/>
+    <ww:select label="Favourite Language" list="favouriteLanguages" name="favouriteLanguage"
+    		listKey="key" listValue="description" emptyOption="true" headerKey="None" 
+    		headerValue="None"/>
     <ww:checkboxlist label="Friends" list="{'Patrick', 'Jason', 'Jay', 'Toby', 'Rene'}" name="friends"/>
     <ww:checkbox label="Age 18+" name="legalAge"/>
     <ww:doubleselect label="State" name="region" list="{'North', 'South'}"
-                     doubleList="top == 'North' ? {'Oregon', 'Washington'} : {'Texas', 'Florida'}" doubleName="state"/>
+                     doubleList="top == 'North' ? {'Oregon', 'Washington'} : {'Texas', 'Florida'}" 
+                     doubleName="state"
+                     headerKey="-1" 
+                     headerValue="---------- Please Select ----------"
+                     emptyOption="true"
+                     />
     <ww:file label="Picture" name="picture"/>
+    
     <ww:submit/>
 </ww:form>