Settings for notifications

Change-Id: I9f737750b5d15eab0ddc918016080833e0214f64
This commit is contained in:
joha-asc 2011-07-20 14:23:24 +02:00
parent f4e948f89b
commit f79c13a645
2 changed files with 76 additions and 3 deletions
src/main/java/se/su/dsv/scipro/admin/pages/settings

@ -2,8 +2,44 @@
<html
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
<body>
<wicket:extend>
<h1>General Settings</h1>
</wicket:extend>
<wicket:extend>
<h5 class="peer-title">General Settings</h5>
<form wicket:id="finalSeminarSettingsForm">
<table>
<tr>
<td><label for="1">Sender name for e-mail
notifications:</label>
</td>
<td><input name="1" wicket:id="mailFromName" type="text" />
</td>
</tr>
<tr>
<td><label for="2">Sender address for e-mail
notifications:</label>
</td>
<td><input name="2" wicket:id="systemFromMail" type="text" />
</td>
</tr>
<tr>
<td><label for="3">SMTP server address:</label>
</td>
<td><input name="3" wicket:id="smtpServer" type="text" />
</td>
</tr>
<tr>
<td><label for="7">Enable e-mail notifications:</label>
</td>
<td><input name="7" type="checkbox" wicket:id="mailNotifications" />
</td>
</tr>
</table>
<button type="submit">
<img src="css/blueprint/plugins/buttons/icons/tick.png" alt="" />
Save changes
</button>
</form>
</wicket:extend>
</body>
</html>

@ -1,13 +1,50 @@
package se.su.dsv.scipro.admin.pages.settings;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.form.CheckBox;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.RequiredTextField;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.spring.injection.annot.SpringBean;
import se.su.dsv.scipro.admin.pages.AbstractAdminSettingsPage;
import se.su.dsv.scipro.data.dao.interfaces.GeneralSystemSettingsDao;
import se.su.dsv.scipro.data.dataobjects.GeneralSystemSettings;
public class AdminGeneralSettingsPage extends AbstractAdminSettingsPage {
@SpringBean
private GeneralSystemSettingsDao generalSystemSettingsDao;
public AdminGeneralSettingsPage(final PageParameters pp) {
super(pp);
add(new AdminGeneralSettingsForm(
"finalSeminarSettingsForm",
new CompoundPropertyModel<GeneralSystemSettings>(generalSystemSettingsDao.getGeneralSystemSettingsInstance())));
}
private class AdminGeneralSettingsForm extends Form<GeneralSystemSettings> {
private static final long serialVersionUID = 1L;
public AdminGeneralSettingsForm(String id, IModel<GeneralSystemSettings> model) {
super(id, model );
TextField<String> mailFromName = new RequiredTextField<String>("mailFromName");
TextField<String> systemFromMail = new RequiredTextField<String>("systemFromMail");
TextField<String> smtpServer = new RequiredTextField<String>("smtpServer");
CheckBox mailNotifications = new CheckBox("mailNotifications");
add(mailFromName);
add(systemFromMail);
add(smtpServer);
add(mailNotifications);
}
@Override
protected void onSubmit() {
setModelObject( generalSystemSettingsDao.save(getModelObject()) );
info("General settings saved");
}
}
}