fixed some saves
This commit is contained in:
parent
480dcced77
commit
e2063cf24f
@ -5,16 +5,14 @@ import org.apache.wicket.ajax.markup.html.form.AjaxButton;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.form.TextField;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.Model;
|
||||
import org.apache.wicket.model.PropertyModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import org.odlabs.wiquery.ui.dialog.Dialog;
|
||||
|
||||
import se.su.dsv.scipro.admin.pages.AdminCheckListPage;
|
||||
import se.su.dsv.scipro.admin.panels.AdminViewCheckListTemplatePanel;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.CheckListTemplateDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ChecklistCategoryDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.CheckListTemplate;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectScheduleEvent;
|
||||
|
||||
public abstract class FunctionalEditChecklistTemplatePanel extends Panel{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -32,7 +30,7 @@ public abstract class FunctionalEditChecklistTemplatePanel extends Panel{
|
||||
if (clt.getId()!=null)
|
||||
clt = checklistTemplateDao.reLoad(clt);
|
||||
|
||||
form = new ChecklistTemplateForm("checklistTemplateForm", clt);
|
||||
form = new ChecklistTemplateForm("checklistTemplateForm", new Model<CheckListTemplate>(clt));
|
||||
add(form);
|
||||
}
|
||||
|
||||
@ -45,24 +43,18 @@ public abstract class FunctionalEditChecklistTemplatePanel extends Panel{
|
||||
public class ChecklistTemplateForm extends Form{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private transient String name; //no need to serialize this
|
||||
private CheckListTemplate clt;
|
||||
|
||||
public ChecklistTemplateForm(String id, final CheckListTemplate clt) {
|
||||
public ChecklistTemplateForm(String id, final Model<CheckListTemplate> cltModel) {
|
||||
super(id);
|
||||
|
||||
this.clt = clt;
|
||||
name = clt.getName();
|
||||
add(new TextField<String>("nameTextField", new PropertyModel<String>(this, "name")));
|
||||
add(new ChecklistCategoryPanel("categoryPanel", clt.getCategories()));
|
||||
add(new AdminViewCheckListTemplatePanel("avcltp", clt));
|
||||
add(new TextField<String>("nameTextField", new PropertyModel<String>(cltModel.getObject(), "name")));
|
||||
add(new ChecklistCategoryPanel("categoryPanel", cltModel.getObject().getCategories()));
|
||||
add(new AdminViewCheckListTemplatePanel("avcltp", cltModel.getObject()));
|
||||
|
||||
add(new AjaxButton("saveButton") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override
|
||||
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
|
||||
clt.setName(name);
|
||||
checklistTemplateDao.save(clt);
|
||||
cltModel.setObject(checklistTemplateDao.save(cltModel.getObject()));
|
||||
onUpdate(target);
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user