diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/PlayerSettingsController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/PlayerSettingsController.java index 2a6d5d28..50baca35 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/PlayerSettingsController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/PlayerSettingsController.java @@ -25,6 +25,12 @@ import java.util.List; import javax.servlet.http.HttpServletRequest; import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.mvc.SimpleFormController; import org.libresonic.player.command.PlayerSettingsCommand; @@ -42,14 +48,19 @@ import org.libresonic.player.service.TranscodingService; * * @author Sindre Mehus */ -public class PlayerSettingsController extends SimpleFormController { +@Controller +@RequestMapping("/playerSettings") +public class PlayerSettingsController { + @Autowired private PlayerService playerService; + @Autowired private SecurityService securityService; + @Autowired private TranscodingService transcodingService; - @Override - protected Object formBackingObject(HttpServletRequest request) throws Exception { + @RequestMapping(method = RequestMethod.GET) + protected Object formBackingObject(HttpServletRequest request, Model model) throws Exception { handleRequestParameters(request); List players = getPlayers(request); @@ -91,12 +102,12 @@ public class PlayerSettingsController extends SimpleFormController { command.setPlayers(players.toArray(new Player[players.size()])); command.setAdmin(user.isAdminRole()); - return command; + model.addAttribute("command",command); + return "playerSettings"; } - @Override - protected void doSubmitAction(Object comm) throws Exception { - PlayerSettingsCommand command = (PlayerSettingsCommand) comm; + @RequestMapping(method = RequestMethod.POST) + protected String doSubmitAction(@ModelAttribute PlayerSettingsCommand command, Model model) throws Exception { Player player = playerService.getPlayerById(command.getPlayerId()); player.setAutoControlEnabled(command.isAutoControlEnabled()); @@ -110,6 +121,8 @@ public class PlayerSettingsController extends SimpleFormController { transcodingService.setTranscodingsForPlayer(player, command.getActiveTranscodingIds()); command.setReloadNeeded(true); + model.addAttribute("command",command); + return "redirect:playerSettings.view"; } private List getPlayers(HttpServletRequest request) { @@ -135,15 +148,4 @@ public class PlayerSettingsController extends SimpleFormController { } } - public void setSecurityService(SecurityService securityService) { - this.securityService = securityService; - } - - public void setPlayerService(PlayerService playerService) { - this.playerService = playerService; - } - - public void setTranscodingService(TranscodingService transcodingService) { - this.transcodingService = transcodingService; - } } diff --git a/libresonic-main/src/main/webapp/WEB-INF/libresonic-servlet.xml b/libresonic-main/src/main/webapp/WEB-INF/libresonic-servlet.xml index 690befd5..7c7d01c7 100644 --- a/libresonic-main/src/main/webapp/WEB-INF/libresonic-servlet.xml +++ b/libresonic-main/src/main/webapp/WEB-INF/libresonic-servlet.xml @@ -173,14 +173,6 @@ - - - - - - - - @@ -423,7 +415,6 @@ starredController searchController settingsController - playerSettingsController dlnaSettingsController sonosSettingsController shareSettingsController