Title: [waffle-scm] [680] trunk/examples/freemarker-example: Added enum property selection to freemarker-example.

Diff

Modified: trunk/examples/freemarker-example/pom.xml (679 => 680)

--- trunk/examples/freemarker-example/pom.xml	2008-05-16 08:47:25 UTC (rev 679)
+++ trunk/examples/freemarker-example/pom.xml	2008-05-16 13:03:00 UTC (rev 680)
@@ -11,11 +11,6 @@
 
   <dependencies>
     <dependency>
-      <groupId>com.thoughtworks.paranamer</groupId>
-      <artifactId>paranamer</artifactId>
-      <scope>runtime</scope>
-    </dependency>
-    <dependency>
       <groupId>freemarker</groupId>
       <artifactId>freemarker</artifactId>
       <version>2.3.8</version>
@@ -27,26 +22,4 @@
     </dependency>
   </dependencies>
 
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>com.thoughtworks.paranamer</groupId>
-        <artifactId>paranamer-maven-plugin</artifactId>
-        <configuration>
-          <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
-          <outputDirectory>${project.build.outputDirectory}</outputDirectory>
-        </configuration>
-        <executions>
-          <execution>
-            <id>generate</id>
-            <phase>compile</phase>
-            <goals>
-              <goal>generate</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-
 </project>

Modified: trunk/examples/freemarker-example/src/main/java/org/codehaus/waffle/example/freemarker/controller/PersonController.java (679 => 680)

--- trunk/examples/freemarker-example/src/main/java/org/codehaus/waffle/example/freemarker/controller/PersonController.java	2008-05-16 08:47:25 UTC (rev 679)
+++ trunk/examples/freemarker-example/src/main/java/org/codehaus/waffle/example/freemarker/controller/PersonController.java	2008-05-16 13:03:00 UTC (rev 680)
@@ -1,5 +1,7 @@
 package org.codehaus.waffle.example.freemarker.controller;
 
+import static java.util.Arrays.asList;
+
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -7,6 +9,7 @@
 import java.util.List;
 
 import org.codehaus.waffle.example.freemarker.model.Person;
+import org.codehaus.waffle.example.freemarker.model.Person.Type;
 import org.codehaus.waffle.example.freemarker.persister.PersistablePerson;
 import org.codehaus.waffle.example.freemarker.persister.PersonPersister;
 import org.codehaus.waffle.view.ExportView;
@@ -33,6 +36,10 @@
         return persister.findAll();
     }
 
+    public List<Type> getTypes(){
+        return asList(Type.values());
+    }
+    
     public List<Long> getSelectedIds() {
         return selectedIds;
     }

Modified: trunk/examples/freemarker-example/src/main/java/org/codehaus/waffle/example/freemarker/model/Person.java (679 => 680)

--- trunk/examples/freemarker-example/src/main/java/org/codehaus/waffle/example/freemarker/model/Person.java	2008-05-16 08:47:25 UTC (rev 679)
+++ trunk/examples/freemarker-example/src/main/java/org/codehaus/waffle/example/freemarker/model/Person.java	2008-05-16 13:03:00 UTC (rev 680)
@@ -5,28 +5,34 @@
 
 public interface Person {
 
-    public Long getId();
+    enum Type {
+        WIZARD, APPRENTICE
+    }
+    
+    Long getId();
 
-    public String getFirstName();
+    String getFirstName();
 
-    public String getLastName();
+    String getLastName();
 
-    public String getEmail();
+    String getEmail();
 
-    public Date getDateOfBirth();
+    Date getDateOfBirth();
 
-    public Date getBirthDay();
+    Date getBirthDay();
     
-    public Date getBirthTime();
+    Date getBirthTime();
     
-    public List<String> getSkills();
+    List<String> getSkills();
     
-    public List<Integer> getLevels();
+    List<Integer> getLevels();
     
-    public List<Double> getGrades();
+    List<Double> getGrades();
+
+    Type getType(); 
     
-    public boolean isWizard();
+    boolean isWizard();
     
-    public String getNotes();
+    String getNotes();
     
 }

Modified: trunk/examples/freemarker-example/src/main/java/org/codehaus/waffle/example/freemarker/persister/PersistablePerson.java (679 => 680)

--- trunk/examples/freemarker-example/src/main/java/org/codehaus/waffle/example/freemarker/persister/PersistablePerson.java	2008-05-16 08:47:25 UTC (rev 679)
+++ trunk/examples/freemarker-example/src/main/java/org/codehaus/waffle/example/freemarker/persister/PersistablePerson.java	2008-05-16 13:03:00 UTC (rev 680)
@@ -20,6 +20,7 @@
     private List<Double> grades;
     private String notes;
     private boolean wizard;
+    private Type type;
 
     public PersistablePerson() {
         id = new Long(0);
@@ -33,6 +34,7 @@
         levels = new ArrayList<Integer>();
         grades = new ArrayList<Double>();
         notes = "";
+        type = Type.APPRENTICE;
         wizard = false;
     }
 
@@ -48,6 +50,7 @@
         this.levels = person.getLevels();
         this.grades = person.getGrades();
         this.notes = person.getNotes();
+        this.type = person.getType();
         this.wizard = person.isWizard();
     }
 
@@ -139,13 +142,21 @@
         this.notes = notes;
     }
 
-    public void setWizard(boolean wizard) {
-        this.wizard = wizard;
+    public Type getType() {
+        return type;
     }
 
+    public void setType(Type type) {
+        this.type = type;
+    }
+
     public boolean isWizard() {
         return wizard;
     }
 
+    public void setWizard(boolean wizard) {
+        this.wizard = wizard;
+    }
+
     
 }

Modified: trunk/examples/freemarker-example/src/main/webapp/people/edit.ftl (679 => 680)

--- trunk/examples/freemarker-example/src/main/webapp/people/edit.ftl	2008-05-16 08:47:25 UTC (rev 679)
+++ trunk/examples/freemarker-example/src/main/webapp/people/edit.ftl	2008-05-16 13:03:00 UTC (rev 680)
@@ -63,6 +63,10 @@
             <@w.textAsCSV "person.grades" person.getGrades()![] /> 
         </p>
         <p class="fieldRow">
+            <label for=""
+            <@w.selectSingle "person.type" controller.getTypes() person.getType()/>
+        </p>
+        <p class="fieldRow">
             <label for="" wizard:</label>
             <@w.text "person.wizard" "${person.wizard?string}"/>
         </p>

Modified: trunk/examples/freemarker-example/src/main/webapp/people/manage.ftl (679 => 680)

--- trunk/examples/freemarker-example/src/main/webapp/people/manage.ftl	2008-05-16 08:47:25 UTC (rev 679)
+++ trunk/examples/freemarker-example/src/main/webapp/people/manage.ftl	2008-05-16 13:03:00 UTC (rev 680)
@@ -16,7 +16,7 @@
             <th>Last Name</th>
             <th>Email</th>
             <th>Date of Birth</th>
-            <th>Is Wizard</th>
+            <th>Type</th>
             <th>Skills</th>
             <th>Select</th>
         </tr>
@@ -29,7 +29,7 @@
                 <td>${person.lastName}</td>
                 <td>${person.email}</td>
                 <td><#if person.dateOfBirth??>${person.dateOfBirth?string("dd/MM/yyyy")}</#if></td>
-                <td>${person.wizard?string}</td>
+                <td>${person.type}</td>
                 <td><@w.asCSV person.getSkills()![] /> </p></td>
                 <td><@w.checkbox "selectedIds" "${person.id}" /></td>
             </tr>


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to