ItEr30S06CUAltaMaquina: Edit Machine
This commit is contained in:
parent
ad8390432c
commit
114f09799f
4 changed files with 29 additions and 7 deletions
|
|
@ -38,4 +38,6 @@ public interface IMachineModel {
|
|||
|
||||
void confirmSave() throws ValidationException;
|
||||
|
||||
void initEdit(Machine machine);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ public class MachineCRUDController extends GenericForwardComposer {
|
|||
}
|
||||
|
||||
public void goToEditForm(Machine machine) {
|
||||
// model.initEdit(machine);
|
||||
machineModel.initEdit(machine);
|
||||
editWindow.setTitle(_("Edit machine"));
|
||||
showEditWindow();
|
||||
Util.reloadBindings(editWindow);
|
||||
|
|
|
|||
|
|
@ -22,8 +22,10 @@ package org.navalplanner.web.resources.machine;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.hibernate.validator.ClassValidator;
|
||||
import org.hibernate.validator.InvalidValue;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.resources.daos.IMachineDAO;
|
||||
import org.navalplanner.business.resources.daos.IResourceDAO;
|
||||
|
|
@ -77,4 +79,22 @@ public class MachineModel implements IMachineModel {
|
|||
resourceDAO.save(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public void initEdit(Machine machine) {
|
||||
Validate.notNull(machine);
|
||||
this.machine = getFromDB(machine);
|
||||
}
|
||||
|
||||
private Machine getFromDB(Machine machine) {
|
||||
return getFromDB(machine.getId());
|
||||
}
|
||||
|
||||
private Machine getFromDB(Long id) {
|
||||
try {
|
||||
return (Machine) resourceDAO.find(id);
|
||||
} catch (InstanceNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,18 +36,18 @@
|
|||
<rows>
|
||||
<row>
|
||||
<label value="${i18n:_('Code')}" />
|
||||
<textbox
|
||||
value="@{controller.machine.code}" constraint="no empty" width="500px"/>
|
||||
<textbox value="@{controller.machine.code}" width="500px"
|
||||
constraint="no empty:${i18n:_('cannot be null or empty')}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Name')}" />
|
||||
<textbox
|
||||
value="@{controller.machine.name}" constraint="no empty" width="500px"/>
|
||||
<textbox value="@{controller.machine.name}" width="500px"
|
||||
constraint="no empty:${i18n:_('cannot be null or empty')}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Description')}" />
|
||||
<textbox
|
||||
value="@{controller.machine.description}" constraint="no empty" width="500px"/>
|
||||
<textbox value="@{controller.machine.description}" width="500px"
|
||||
constraint="no empty:${i18n:_('cannot be null or empty')}" />
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue