Corrections on MusicFolderSettingsController.

master
Rémi Cocula 8 years ago
parent a0ab86a6ac
commit b2b4384387
  1. 14
      libresonic-main/src/main/java/org/libresonic/player/controller/MusicFolderSettingsController.java
  2. 1
      libresonic-main/src/main/webapp/WEB-INF/jsp/musicFolderSettings.jsp

@ -64,7 +64,12 @@ public class MusicFolderSettingsController {
private MediaFileDao mediaFileDao; private MediaFileDao mediaFileDao;
@RequestMapping(method = RequestMethod.GET) @RequestMapping(method = RequestMethod.GET)
protected String formBackingObject(@RequestParam(value = "scanNow",required = false) String scanNow, protected String displayForm() throws Exception {
return "musicFolderSettings";
}
@ModelAttribute
protected void formBackingObject(@RequestParam(value = "scanNow",required = false) String scanNow,
@RequestParam(value = "expunge",required = false) String expunge, @RequestParam(value = "expunge",required = false) String expunge,
@RequestParam(value = "reload",required = false) String reload, @RequestParam(value = "reload",required = false) String reload,
Model model) throws Exception { Model model) throws Exception {
@ -88,9 +93,9 @@ public class MusicFolderSettingsController {
command.setReload(reload != null || scanNow != null); command.setReload(reload != null || scanNow != null);
model.addAttribute("command",command); model.addAttribute("command",command);
return "musicFolderSettings";
} }
private void expunge() { private void expunge() {
artistDao.expunge(); artistDao.expunge();
albumDao.expunge(); albumDao.expunge();
@ -106,9 +111,8 @@ public class MusicFolderSettingsController {
} }
@RequestMapping(method = RequestMethod.POST) @RequestMapping(method = RequestMethod.POST)
protected String onSubmit(@ModelAttribute MusicFolderSettingsCommand command, Model model) throws Exception { protected String onSubmit(@ModelAttribute("command") MusicFolderSettingsCommand command, Model model) throws Exception {
if (command.getMusicFolders() != null) {
for (MusicFolderSettingsCommand.MusicFolderInfo musicFolderInfo : command.getMusicFolders()) { for (MusicFolderSettingsCommand.MusicFolderInfo musicFolderInfo : command.getMusicFolders()) {
if (musicFolderInfo.isDelete()) { if (musicFolderInfo.isDelete()) {
settingsService.deleteMusicFolder(musicFolderInfo.getId()); settingsService.deleteMusicFolder(musicFolderInfo.getId());
@ -119,7 +123,6 @@ public class MusicFolderSettingsController {
} }
} }
} }
}
MusicFolder newMusicFolder = command.getNewMusicFolder().toMusicFolder(); MusicFolder newMusicFolder = command.getNewMusicFolder().toMusicFolder();
if (newMusicFolder != null) { if (newMusicFolder != null) {
@ -133,7 +136,6 @@ public class MusicFolderSettingsController {
settingsService.save(); settingsService.save();
mediaScannerService.schedule(); mediaScannerService.schedule();
model.addAttribute("command",command);
return "redirect:musicFolderSettings.view"; return "redirect:musicFolderSettings.view";
} }

@ -38,7 +38,6 @@
<c:forEach items="${command.musicFolders}" var="folder" varStatus="loopStatus"> <c:forEach items="${command.musicFolders}" var="folder" varStatus="loopStatus">
<tr> <tr>
<form:hidden path="musicFolders[${loopStatus.count-1}].id"/>
<td><form:input path="musicFolders[${loopStatus.count-1}].name" size="20"/></td> <td><form:input path="musicFolders[${loopStatus.count-1}].name" size="20"/></td>
<td><form:input path="musicFolders[${loopStatus.count-1}].path" size="40"/></td> <td><form:input path="musicFolders[${loopStatus.count-1}].path" size="40"/></td>
<td align="center" style="padding-left:1em"><form:checkbox path="musicFolders[${loopStatus.count-1}].enabled" cssClass="checkbox"/></td> <td align="center" style="padding-left:1em"><form:checkbox path="musicFolders[${loopStatus.count-1}].enabled" cssClass="checkbox"/></td>

Loading…
Cancel
Save