/*
- * Sone - EditProfileFieldPage.java - Copyright © 2011–2012 David Roden
+ * Sone - EditProfileFieldPage.java - Copyright © 2011–2016 David Roden
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* {@inheritDoc}
*/
@Override
- protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
- super.processTemplate(request, templateContext);
+ protected void handleRequest(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
Sone currentSone = getCurrentSone(request.getToadletContext());
Profile profile = currentSone.getProfile();
}
String name = request.getHttpRequest().getPartAsStringFailsafe("name", 256);
Field existingField = profile.getFieldByName(name);
- if ((existingField == null) || (existingField.equals(field))) {
- field.setName(name);
- currentSone.setProfile(profile);
+ if ((existingField != null) && (!field.equals(existingField))) {
+ templateContext.set("duplicateFieldName", true);
+ } else {
+ if (!name.equals(field.getName())) {
+ field.setName(name);
+ currentSone.setProfile(profile);
+ }
throw new RedirectException("editProfile.html#profile-fields");
}
- templateContext.set("duplicateFieldName", true);
}
/* store current values in template. */