]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/pages/account/MyDetailsForm.java
UPD: packed date formatting in Outputable (now you cann pass dates
[gigi.git] / src / org / cacert / gigi / pages / account / MyDetailsForm.java
index c79bcea5f0063f02ee519e22344e9e471296241e..0339326a024451de7475fa284e17e0acb51b2b0b 100644 (file)
@@ -6,10 +6,11 @@ import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 
 import org.cacert.gigi.GigiApiException;
+import org.cacert.gigi.dbObjects.Name;
 import org.cacert.gigi.dbObjects.User;
 import org.cacert.gigi.localisation.Language;
 import org.cacert.gigi.output.DateSelector;
-import org.cacert.gigi.output.Form;
+import org.cacert.gigi.output.template.Form;
 import org.cacert.gigi.output.template.Template;
 import org.cacert.gigi.pages.Page;
 import org.cacert.gigi.util.HTMLEncoder;
@@ -30,7 +31,7 @@ public class MyDetailsForm extends Form {
     public MyDetailsForm(HttpServletRequest hsr, User target) {
         super(hsr);
         this.target = target;
-        this.ds = new DateSelector("day", "month", "year", target.getDob());
+        this.ds = new DateSelector("day", "month", "year", target.getDoB());
     }
 
     @Override
@@ -44,12 +45,9 @@ public class MyDetailsForm extends Form {
                 if (newLname.isEmpty()) {
                     throw new GigiApiException("Last name cannot be empty.");
                 }
-                target.setFname(newFname);
-                target.setLname(newLname);
-                target.setMname(newMname);
-                target.setSuffix(newSuffix);
+                target.setName(new Name(newFname, newLname, newMname, newSuffix));
                 ds.update(req);
-                target.setDob(ds.getDate());
+                target.setDoB(ds.getDate());
                 target.updateUserData();
             } else {
                 throw new GigiApiException("No change after assurance allowed.");
@@ -66,16 +64,17 @@ public class MyDetailsForm extends Form {
 
     @Override
     protected void outputContent(PrintWriter out, Language l, Map<String, Object> vars) {
-        vars.put("fname", HTMLEncoder.encodeHTML(target.getFname()));
-        vars.put("mname", target.getMname() == null ? "" : HTMLEncoder.encodeHTML(target.getMname()));
-        vars.put("lname", HTMLEncoder.encodeHTML(target.getLname()));
-        vars.put("suffix", target.getSuffix() == null ? "" : HTMLEncoder.encodeHTML(target.getSuffix()));
+        Name name = target.getName();
+        vars.put("fname", HTMLEncoder.encodeHTML(name.getFname()));
+        vars.put("mname", name.getMname() == null ? "" : HTMLEncoder.encodeHTML(name.getMname()));
+        vars.put("lname", HTMLEncoder.encodeHTML(name.getLname()));
+        vars.put("suffix", name.getSuffix() == null ? "" : HTMLEncoder.encodeHTML(name.getSuffix()));
         vars.put("details", "");
         if (target.getAssurancePoints() == 0) {
             vars.put("DoB", ds);
             templ.output(out, l, vars);
         } else {
-            vars.put("DoB", DateSelector.getDateFormat().format(target.getDob()));
+            vars.put("DoB", target.getDoB());
             assured.output(out, l, vars);
         }
     }