From: David ‘Bombe’ Roden Date: Wed, 12 Jan 2011 11:19:51 +0000 (+0100) Subject: Assign a name to the save button, react only to that name. X-Git-Tag: 0.4^2~9^2~42 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=e8ca06ebeb10e411775f3e835c14f8009c767e0d;p=Sone.git Assign a name to the save button, react only to that name. --- 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 @@
- +