Corrections on PlayerSettingsController and SearchController.

master
Rémi Cocula 8 years ago
parent 4561e38807
commit ddea3f47ff
  1. 11
      libresonic-main/src/main/java/org/libresonic/player/controller/PlayerSettingsController.java
  2. 12
      libresonic-main/src/main/java/org/libresonic/player/controller/SearchController.java

@ -60,7 +60,12 @@ public class PlayerSettingsController {
private TranscodingService transcodingService; private TranscodingService transcodingService;
@RequestMapping(method = RequestMethod.GET) @RequestMapping(method = RequestMethod.GET)
protected String formBackingObject(HttpServletRequest request, Model model) throws Exception { protected String displayForm() throws Exception {
return "playerSettings";
}
@ModelAttribute
protected void formBackingObject(HttpServletRequest request, Model model) throws Exception {
handleRequestParameters(request); handleRequestParameters(request);
List<Player> players = getPlayers(request); List<Player> players = getPlayers(request);
@ -103,11 +108,10 @@ public class PlayerSettingsController {
command.setAdmin(user.isAdminRole()); command.setAdmin(user.isAdminRole());
model.addAttribute("command",command); model.addAttribute("command",command);
return "playerSettings";
} }
@RequestMapping(method = RequestMethod.POST) @RequestMapping(method = RequestMethod.POST)
protected String doSubmitAction(@ModelAttribute PlayerSettingsCommand command, Model model) throws Exception { protected String doSubmitAction(@ModelAttribute("command") PlayerSettingsCommand command, Model model) throws Exception {
Player player = playerService.getPlayerById(command.getPlayerId()); Player player = playerService.getPlayerById(command.getPlayerId());
player.setAutoControlEnabled(command.isAutoControlEnabled()); player.setAutoControlEnabled(command.isAutoControlEnabled());
@ -121,7 +125,6 @@ public class PlayerSettingsController {
transcodingService.setTranscodingsForPlayer(player, command.getActiveTranscodingIds()); transcodingService.setTranscodingsForPlayer(player, command.getActiveTranscodingIds());
command.setReloadNeeded(true); command.setReloadNeeded(true);
model.addAttribute("command",command);
return "redirect:playerSettings.view"; return "redirect:playerSettings.view";
} }

@ -29,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.validation.BindException; import org.springframework.validation.BindException;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
@ -66,13 +67,17 @@ public class SearchController {
private SearchService searchService; private SearchService searchService;
@RequestMapping(method = RequestMethod.GET) @RequestMapping(method = RequestMethod.GET)
protected String formBackingObject(HttpServletRequest request, Model model) throws Exception { protected String displayForm() throws Exception {
model.addAttribute("command",new SearchCommand());
return "search"; return "search";
} }
@ModelAttribute
protected void formBackingObject(HttpServletRequest request, Model model) throws Exception {
model.addAttribute("command",new SearchCommand());
}
@RequestMapping(method = RequestMethod.POST) @RequestMapping(method = RequestMethod.POST)
protected String onSubmit(HttpServletRequest request, HttpServletResponse response, SearchCommand command, Model model) protected String onSubmit(HttpServletRequest request, HttpServletResponse response,@ModelAttribute("command") SearchCommand command, Model model)
throws Exception { throws Exception {
User user = securityService.getCurrentUser(request); User user = securityService.getCurrentUser(request);
@ -101,7 +106,6 @@ public class SearchController {
command.setPlayer(playerService.getPlayer(request, response)); command.setPlayer(playerService.getPlayer(request, response));
} }
model.addAttribute("command",command);
return "search"; return "search";
} }

Loading…
Cancel
Save