X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FDeleteProfileFieldAjaxPage.java;h=7d937b59aa17d32890e32011c0f2af98e211448a;hp=4625c13099539e9f57af89aea657002b354ed348;hb=7b55e0be6a3283e43a9bbab98f82aebdd948eb33;hpb=1bc78b582ac59f2438002997f5780db4dcee0a2a diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/DeleteProfileFieldAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/DeleteProfileFieldAjaxPage.java index 4625c13..7d937b5 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/DeleteProfileFieldAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/DeleteProfileFieldAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - DeleteProfileFieldAjaxPage.java - Copyright © 2011 David Roden + * Sone - DeleteProfileFieldAjaxPage.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 @@ -17,11 +17,16 @@ package net.pterodactylus.sone.web.ajax; +import static com.fasterxml.jackson.databind.node.JsonNodeFactory.instance; + import net.pterodactylus.sone.data.Profile; import net.pterodactylus.sone.data.Profile.Field; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.web.WebInterface; -import net.pterodactylus.util.json.JsonObject; +import net.pterodactylus.sone.web.page.FreenetRequest; + +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.fasterxml.jackson.databind.node.TextNode; /** * AJAX page that lets the user delete a profile field. @@ -44,7 +49,7 @@ public class DeleteProfileFieldAjaxPage extends JsonPage { * {@inheritDoc} */ @Override - protected JsonObject createJsonObject(Request request) { + protected JsonReturnObject createJsonObject(FreenetRequest request) { String fieldId = request.getHttpRequest().getParam("field"); Sone currentSone = getCurrentSone(request.getToadletContext()); Profile profile = currentSone.getProfile(); @@ -55,7 +60,7 @@ public class DeleteProfileFieldAjaxPage extends JsonPage { profile.removeField(field); currentSone.setProfile(profile); webInterface.getCore().touchConfiguration(); - return createSuccessJsonObject().put("field", new JsonObject().put("id", field.getId())); + return createSuccessJsonObject().put("field", new ObjectNode(instance).put("id", new TextNode(field.getId()))); } }