You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by pl...@apache.org on 2005/11/23 17:29:05 UTC

svn commit: r348477 - in /incubator/tobago/trunk/tobago-example/tobago-example-addressbook/src/main: java/org/apache/myfaces/tobago/example/addressbook/ webapp/ webapp/WEB-INF/ webapp/tobago-resource/html/standard/standard/image/

Author: pleff
Date: Wed Nov 23 08:28:54 2005
New Revision: 348477

URL: http://svn.apache.org/viewcvs?rev=348477&view=rev
Log:
added portrait, upload is not implemented at the moment

Added:
    incubator/tobago/trunk/tobago-example/tobago-example-addressbook/src/main/webapp/tobago-resource/html/standard/standard/image/
Modified:
    incubator/tobago/trunk/tobago-example/tobago-example-addressbook/src/main/java/org/apache/myfaces/tobago/example/addressbook/Address.java
    incubator/tobago/trunk/tobago-example/tobago-example-addressbook/src/main/java/org/apache/myfaces/tobago/example/addressbook/Controller.java
    incubator/tobago/trunk/tobago-example/tobago-example-addressbook/src/main/webapp/WEB-INF/dialog-config.xml
    incubator/tobago/trunk/tobago-example/tobago-example-addressbook/src/main/webapp/editor.jsp

Modified: incubator/tobago/trunk/tobago-example/tobago-example-addressbook/src/main/java/org/apache/myfaces/tobago/example/addressbook/Address.java
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-example/tobago-example-addressbook/src/main/java/org/apache/myfaces/tobago/example/addressbook/Address.java?rev=348477&r1=348476&r2=348477&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-example/tobago-example-addressbook/src/main/java/org/apache/myfaces/tobago/example/addressbook/Address.java (original)
+++ incubator/tobago/trunk/tobago-example/tobago-example-addressbook/src/main/java/org/apache/myfaces/tobago/example/addressbook/Address.java Wed Nov 23 08:28:54 2005
@@ -24,6 +24,7 @@
 
 import java.util.Date;
 import java.util.Locale;
+import java.io.File;
 
 public class Address {
 
@@ -51,6 +52,7 @@
   private String jobPhone;
   private String jobEmail;
   private String jobHomePage;
+  private static final String EMPTY_PORTRAIT = "image/empty_portrait.png";
 
   public Address() {
     LOG.debug("Creating new Address");
@@ -249,7 +251,16 @@
     this.jobHomePage = jobHomePage;
   }
 
+  public String getImageFileName() {
+    String fileName = id + ".png";
+    if (new File(fileName).exists()) {
+      return fileName;
+    } else {
+      return EMPTY_PORTRAIT;
+    }
+  }
+
   public String toString() {
-    return id+": "+firstName+" "+lastName;
+    return id + ": " + firstName + " " + lastName;
   }
 }

Modified: incubator/tobago/trunk/tobago-example/tobago-example-addressbook/src/main/java/org/apache/myfaces/tobago/example/addressbook/Controller.java
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-example/tobago-example-addressbook/src/main/java/org/apache/myfaces/tobago/example/addressbook/Controller.java?rev=348477&r1=348476&r2=348477&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-example/tobago-example-addressbook/src/main/java/org/apache/myfaces/tobago/example/addressbook/Controller.java (original)
+++ incubator/tobago/trunk/tobago-example/tobago-example-addressbook/src/main/java/org/apache/myfaces/tobago/example/addressbook/Controller.java Wed Nov 23 08:28:54 2005
@@ -21,13 +21,13 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.commons.fileupload.FileItem;
 import org.apache.myfaces.tobago.model.SheetState;
 import org.springframework.context.ApplicationContext;
 import org.springframework.web.jsf.FacesContextUtils;
 
 import javax.faces.application.FacesMessage;
 import javax.faces.context.FacesContext;
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
@@ -49,6 +49,9 @@
 
   private AddressDAO addressDAO;
 
+  private FileItem uploadedFile;
+  private boolean renderFileUploadPopup;
+
   public Controller() {
     LOG.debug("Creating new Controller");
   }
@@ -124,10 +127,24 @@
     this.selectedAddresses = selectedAddresses;
   }
 
+  public boolean isRenderFileUploadPopup() {
+    return renderFileUploadPopup;
+  }
+
+  public void setRenderFileUploadPopup(boolean renderFileUploadPopup) {
+    LOG.debug(">>> "+renderFileUploadPopup);
+    this.renderFileUploadPopup = renderFileUploadPopup;
+  }
+
   public boolean isRenderPopup() {
     return renderPopup;
   }
 
+  public String cancelFileUploadPopup() {
+    setRenderFileUploadPopup(false);
+    return OUTCOME_EDITOR;
+  }
+
   public void setRenderPopup(boolean renderPopup) {
     this.renderPopup = renderPopup;
   }
@@ -165,4 +182,18 @@
   public void setRenderDayOfBirth(boolean renderDayOfBirth) {
     this.renderDayOfBirth = renderDayOfBirth;
   }
+
+  public FileItem getUploadedFile() {
+    return uploadedFile;
+  }
+
+  public void setUploadedFile(FileItem uploadedFile) {
+    this.uploadedFile = uploadedFile;
+  }
+
+  public String renderFileUploadPopup() {
+    setRenderFileUploadPopup(true);
+    return OUTCOME_EDITOR;
+  }
+
 }

Modified: incubator/tobago/trunk/tobago-example/tobago-example-addressbook/src/main/webapp/WEB-INF/dialog-config.xml
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-example/tobago-example-addressbook/src/main/webapp/WEB-INF/dialog-config.xml?rev=348477&r1=348476&r2=348477&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-example/tobago-example-addressbook/src/main/webapp/WEB-INF/dialog-config.xml (original)
+++ incubator/tobago/trunk/tobago-example/tobago-example-addressbook/src/main/webapp/WEB-INF/dialog-config.xml Wed Nov 23 08:28:54 2005
@@ -57,6 +57,8 @@
                   target="Exit"/>
       <transition outcome="store"
                   target="Store"/>
+      <transition outcome="editor"
+                  target="View"/>
     </view>
 
     <action name="Store"

Modified: incubator/tobago/trunk/tobago-example/tobago-example-addressbook/src/main/webapp/editor.jsp
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-example/tobago-example-addressbook/src/main/webapp/editor.jsp?rev=348477&r1=348476&r2=348477&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-example/tobago-example-addressbook/src/main/webapp/editor.jsp (original)
+++ incubator/tobago/trunk/tobago-example/tobago-example-addressbook/src/main/webapp/editor.jsp Wed Nov 23 08:28:54 2005
@@ -38,66 +38,100 @@
         <tc:messages />
 
         <tc:tabGroup>
-          <tc:tab labelWithAccessKey="#{bundle.editorTabPersonal}">
+        <tc:tab labelWithAccessKey="#{bundle.editorTabPersonal}">
+          <tc:panel>
+            <f:facet name="layout">
+              <tc:gridLayout rows="fixed;fixed"/>
+            </f:facet>
             <tc:panel>
               <f:facet name="layout">
-                <tc:gridLayout rows="fixed;fixed;fixed;fixed;fixed;fixed;fixed;fixed;fixed;fixed;fixed;fixed;1*" />
+                <tc:gridLayout columns="*;120px"/>
               </f:facet>
-              <tx:in value="#{controller.currentAddress.firstName}"
-                  label="#{bundle.editorFirstName}" required="true" />
-
-              <tx:label value="#{bundle.editorLastName}">
-                 <tc:in value="#{controller.currentAddress.lastName}" required="true"/>
-              </tx:label>
-
               <tc:panel>
                 <f:facet name="layout">
-                  <tc:gridLayout columns="6*;1*" />
+                  <tc:gridLayout rows="fixed;fixed;fixed;fixed;fixed;*"/>
                 </f:facet>
-                <tx:in value="#{controller.currentAddress.street}"
-                    label="#{bundle.editorStreet}" />
-                <tc:in value="#{controller.currentAddress.houseNumber}" />
-              </tc:panel>
+                <tx:in value="#{controller.currentAddress.firstName}"
+                       label="#{bundle.editorFirstName}" required="true"/>
 
+                <tx:label value="#{bundle.editorLastName}">
+                  <tc:in value="#{controller.currentAddress.lastName}"
+                         required="true"/>
+                </tx:label>
+
+                <tc:panel>
+                  <f:facet name="layout">
+                    <tc:gridLayout columns="6*;1*"/>
+                  </f:facet>
+                  <tx:in value="#{controller.currentAddress.street}"
+                         label="#{bundle.editorStreet}"/>
+                  <tc:in value="#{controller.currentAddress.houseNumber}"/>
+                </tc:panel>
+
+                <tc:panel>
+                  <f:facet name="layout">
+                    <tc:gridLayout columns="1*;1*"/>
+                  </f:facet>
+                  <tx:in value="#{controller.currentAddress.zipCode}"
+                         label="#{bundle.editorCity}"/>
+                  <tc:in value="#{controller.currentAddress.city}"/>
+                </tc:panel>
+
+                <tc:selectOneChoice
+                    value="#{controller.currentAddress.country}"
+                    label="#{bundle.editorCountry}">
+                  <f:selectItems value="#{countries}"/>
+                </tc:selectOneChoice>
+                <tc:cell></tc:cell>
+              </tc:panel>
               <tc:panel>
                 <f:facet name="layout">
-                  <tc:gridLayout columns="1*;1*" />
+                  <tc:gridLayout rows="160px" columns="120px"/>
                 </f:facet>
-                <tx:in value="#{controller.currentAddress.zipCode}"
-                    label="#{bundle.editorCity}" />
-                <tc:in value="#{controller.currentAddress.city}" />
+                <tc:button image="#{controller.currentAddress.imageFileName}"
+                    action="#{controller.currentAddress.renderFileUploadPopup}">
+                  <f:facet name="popup">
+                    <tc:popup width="300px" height="200px" left="200px"
+                              top="200px" rendered="#{controller.renderFileUploadPopup}"
+                              id="popup">
+                      <tc:file
+                          value="#{controller.currentAddress.uploadedFile}"/>
+                      <tc:button action="#{controller.cancelPopup}" label="OK" defaultCommand="true"/>
+                      <tc:button action="#{controller.cancelPopup}" label="Cancel"/>
+                    </tc:popup>
+                  </f:facet>
+                </tc:button>
               </tc:panel>
+            </tc:panel>
+              <tc:panel>
+                <f:facet name="layout">
+                  <tc:gridLayout rows="fixed;fixed;fixed;fixed;fixed;fixed;fixed;1*"/>
+                </f:facet>
+                <tx:in value="#{controller.currentAddress.phone}"
+                       label="#{bundle.editorPhone}"/>
 
-              <tc:selectOneChoice value="#{controller.currentAddress.country}"
-                  label="#{bundle.editorCountry}">
-                <f:selectItems value="#{countries}" />
-              </tc:selectOneChoice>
-
-              <tx:in value="#{controller.currentAddress.phone}"
-                  label="#{bundle.editorPhone}" />
-
-              <tx:in value="#{controller.currentAddress.mobile}"
-                  label="#{bundle.editorMobile}" />
-
-              <tx:in value="#{controller.currentAddress.fax}"
-                  label="#{bundle.editorFax}" />
+                <tx:in value="#{controller.currentAddress.mobile}"
+                       label="#{bundle.editorMobile}"/>
 
-              <tx:in value="#{controller.currentAddress.email}"
-                  label="#{bundle.editorEmail}" />
+                <tx:in value="#{controller.currentAddress.fax}"
+                       label="#{bundle.editorFax}"/>
 
-              <tx:in value="#{controller.currentAddress.icq}"
-                  label="#{bundle.editorIcq}" />
+                <tx:in value="#{controller.currentAddress.email}"
+                       label="#{bundle.editorEmail}"/>
 
-              <tx:in value="#{controller.currentAddress.homePage}"
-                  label="#{bundle.editorHomepage}" />
+                <tx:in value="#{controller.currentAddress.icq}"
+                       label="#{bundle.editorIcq}"/>
 
-              <tc:date value="#{controller.currentAddress.dayOfBirth}"
-                  label="#{bundle.editorBirthday}">
-                <f:convertDateTime pattern="dd.MM.yyyy" />
-              </tc:date>
+                <tx:in value="#{controller.currentAddress.homePage}"
+                       label="#{bundle.editorHomepage}"/>
 
-              <tc:cell/>
+                <tc:date value="#{controller.currentAddress.dayOfBirth}"
+                         label="#{bundle.editorBirthday}">
+                  <f:convertDateTime pattern="dd.MM.yyyy"/>
+                </tc:date>
 
+                <tc:cell/>
+              </tc:panel>
             </tc:panel>
           </tc:tab>