* {@inheritDoc}
*/
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
Sone currentSone = getCurrentSone(request.getToadletContext());
Profile profile = currentSone.getProfile();
/* get parameters from request. */
String fieldId = request.getHttpRequest().getParam("field");
Field field = profile.getFieldById(fieldId);
if (field == null) {
throw new RedirectException("invalid.html");
}
/* process the POST request. */
if (request.getMethod() == Method.POST) {
if (request.getHttpRequest().getPartAsStringFailsafe("cancel", 4).equals("true")) {
throw new RedirectException("editProfile.html#profile-fields");
}
fieldId = request.getHttpRequest().getPartAsStringFailsafe("field", 36);
field = profile.getFieldById(fieldId);
if (field == null) {
throw new RedirectException("invalid.html");
}
String name = request.getHttpRequest().getPartAsStringFailsafe("name", 256);
Field existingField = profile.getFieldByName(name);
if ((existingField == null) || (existingField.equals(field))) {
field.setName(name);
currentSone.setProfile(profile);
throw new RedirectException("editProfile.html#profile-fields");
}
templateContext.set("duplicateFieldName", true);
}