private void newInstance() { if (allowNew()) { // initalise the screen for a new record form.getLocalContext().setWheelchairCushionVo(new WheelchairCushionVo()); clearInstanceControls(); form.ctnDetails().setCollapsed(false); //set the form mode form.setMode(FormMode.EDIT); //set any control status specific this form form.ctnDetails().dtimRecording().setEnabled(true); form.ctnDetails().qmbAuthoringHCP().setEnabled(true); form.ctnDetails().cmbCategory().setEnabled(false); form.getContextMenus().hideAllGenericGridMenuItems(); form.getContextMenus().getGenericGridAddItem().setVisible(true); setDefaultValues(); } }
/** * gather screen data into local context vo and save updating the local context vo * returns true for successful save * @return boolean * @throws PresentationLogicException */ private boolean save() { WheelchairCushionVo voWheelchairCushion = populateInstanceData(); //set clinical contact if (!voWheelchairCushion.getClinicalContactIsNotNull()) voWheelchairCushion.setClinicalContact(form.getGlobalContext().Core.getCurrentClinicalContact()); //set Care Context if (!voWheelchairCushion.getCareContextIsNotNull()) voWheelchairCushion.setCareContext(form.getGlobalContext().Core.getCurrentCareContext()); //validate Vo String[] arrErrors = voWheelchairCushion.validate(); String[] arrScreenAndVoErrors = addScreenErrorsToVOErrors(arrErrors); if (arrScreenAndVoErrors.length > 0) { engine.showErrors(arrScreenAndVoErrors); return false; } try { form.getLocalContext().setWheelchairCushionVo(domain.save(voWheelchairCushion)); } catch(StaleObjectException e) { engine.showMessage(ims.configuration.gen.ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue()); open(); return false; } return true; }
public WheelchairCushionVo save(WheelchairCushionVo voWheelchairCushion) throws StaleObjectException { DomainFactory factory = getDomainFactory(); if (!voWheelchairCushion.isValidated()) { throw new DomainRuntimeException("This HomeVisitVo has not been validated"); } WheelchairCushion domWheelchairCushion = WheelchairCushionVoAssembler.extractWheelchairCushion(factory, voWheelchairCushion); factory.save(domWheelchairCushion); return WheelchairCushionVoAssembler.create(domWheelchairCushion); }