From e8ca06ebeb10e411775f3e835c14f8009c767e0d Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 12 Jan 2011 12:19:51 +0100 Subject: [PATCH] Assign a name to the save button, react only to that name. --- .../pterodactylus/sone/web/EditProfilePage.java | 26 ++++++++++++---------- src/main/resources/templates/editProfile.html | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/web/EditProfilePage.java b/src/main/java/net/pterodactylus/sone/web/EditProfilePage.java index 87f7aef..1183100 100644 --- a/src/main/java/net/pterodactylus/sone/web/EditProfilePage.java +++ b/src/main/java/net/pterodactylus/sone/web/EditProfilePage.java @@ -63,18 +63,20 @@ public class EditProfilePage extends SoneTemplatePage { Integer birthMonth = profile.getBirthMonth(); Integer birthYear = profile.getBirthYear(); if (request.getMethod() == Method.POST) { - firstName = request.getHttpRequest().getPartAsStringFailsafe("first-name", 256).trim(); - middleName = request.getHttpRequest().getPartAsStringFailsafe("middle-name", 256).trim(); - lastName = request.getHttpRequest().getPartAsStringFailsafe("last-name", 256).trim(); - birthDay = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("birth-day", 256).trim()); - birthMonth = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("birth-month", 256).trim()); - birthYear = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("birth-year", 256).trim()); - profile.setFirstName(firstName.length() > 0 ? firstName : null); - profile.setMiddleName(middleName.length() > 0 ? middleName : null); - profile.setLastName(lastName.length() > 0 ? lastName : null); - profile.setBirthDay(birthDay).setBirthMonth(birthMonth).setBirthYear(birthYear); - currentSone.setProfile(profile); - throw new RedirectException("index.html"); + if (request.getHttpRequest().getPartAsStringFailsafe("saveProfile", 4).equals("true")) { + firstName = request.getHttpRequest().getPartAsStringFailsafe("first-name", 256).trim(); + middleName = request.getHttpRequest().getPartAsStringFailsafe("middle-name", 256).trim(); + lastName = request.getHttpRequest().getPartAsStringFailsafe("last-name", 256).trim(); + birthDay = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("birth-day", 256).trim()); + birthMonth = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("birth-month", 256).trim()); + birthYear = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("birth-year", 256).trim()); + profile.setFirstName(firstName.length() > 0 ? firstName : null); + profile.setMiddleName(middleName.length() > 0 ? middleName : null); + profile.setLastName(lastName.length() > 0 ? lastName : null); + profile.setBirthDay(birthDay).setBirthMonth(birthMonth).setBirthYear(birthYear); + currentSone.setProfile(profile); + throw new RedirectException("index.html"); + } } template.set("firstName", firstName); template.set("middleName", middleName); diff --git a/src/main/resources/templates/editProfile.html b/src/main/resources/templates/editProfile.html index d1d5943..d2dc61a 100644 --- a/src/main/resources/templates/editProfile.html +++ b/src/main/resources/templates/editProfile.html @@ -71,7 +71,7 @@
- +
-- 2.7.4