List of usage examples for org.apache.commons.beanutils PropertyUtils setProperty
public static void setProperty(Object bean, String name, Object value) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
Set the value of the specified property of the specified bean, no matter which property reference format is used, with no type conversions.
For more details see PropertyUtilsBean
.
From source file:us.mn.state.health.lims.menu.action.SampleTrackingPageAction.java
protected ActionForward performAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String forward = FWD_SUCCESS; BaseActionForm searchForm = (BaseActionForm) form; searchForm.initialize(mapping);//from w w w. j a v a 2s. c o m //System.out.println("I am in SampleTrackingPageAction "); List submitters = new ArrayList(); OrganizationDAO organizationDAO = new OrganizationDAOImpl(); submitters = organizationDAO.getAllOrganizations(); List types = new ArrayList(); TypeOfSampleDAO typeofsampleDAO = new TypeOfSampleDAOImpl(); types = typeofsampleDAO.getAllTypeOfSamples(); List sources = new ArrayList(); SourceOfSampleDAO sourceOfSampleDAO = new SourceOfSampleDAOImpl(); sources = sourceOfSampleDAO.getAllSourceOfSamples(); List projectdetails = new ArrayList(); ProjectDAO projectDAO = new ProjectDAOImpl(); projectdetails = projectDAO.getAllProjects(); List sortby = new ArrayList(); SampleTrackingDAO sampletrackingDAO = new SampleTrackingDAOImpl(); sortby = getAllSortByList(); Collections.sort(submitters, OrganizationComparator.NAME_COMPARATOR); Collections.sort(types, TypeOfSampleComparator.NAME_COMPARATOR); Collections.sort(sources, SourceOfSampleComparator.NAME_COMPARATOR); PropertyUtils.setProperty(form, "submitters", submitters); PropertyUtils.setProperty(form, "types", types); PropertyUtils.setProperty(form, "sources", sources); PropertyUtils.setProperty(form, "projectdetails", projectdetails); PropertyUtils.setProperty(form, "sortby", sortby); return mapping.findForward(forward); }
From source file:us.mn.state.health.lims.messageorganization.action.MessageOrganizationAction.java
protected ActionForward performAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // The first job is to determine if we are coming to this action with an // ID parameter in the request. If there is no parameter, we are // creating a new MessageOrganization. // If there is a parameter present, we should bring up an existing // MessageOrganization to edit. String id = request.getParameter(ID); String forward = FWD_SUCCESS; request.setAttribute(ALLOW_EDITS_KEY, "true"); request.setAttribute(PREVIOUS_DISABLED, "true"); request.setAttribute(NEXT_DISABLED, "true"); DynaActionForm dynaForm = (DynaActionForm) form; // initialize the form dynaForm.initialize(mapping);//from w ww . j a va 2s . c o m MessageOrganization messageOrganization = new MessageOrganization(); if ((id != null) && (!"0".equals(id))) { // this is an existing // messageOrganization messageOrganization.setId(id); MessageOrganizationDAO messageOrganizationDAO = new MessageOrganizationDAOImpl(); messageOrganizationDAO.getData(messageOrganization); // initialize selectedPanelItemId if (messageOrganization.getOrganization() != null) { messageOrganization.setSelectedOrganizationId(messageOrganization.getOrganization().getId()); } isNew = false; // this is to set correct page title // do we need to enable next or previous? // bugzilla 1427 pass in name not id List messageOrganizations = messageOrganizationDAO .getNextMessageOrganizationRecord(messageOrganization.getId()); if (messageOrganizations.size() > 0) { // enable next button request.setAttribute(NEXT_DISABLED, "false"); } // bugzilla 1427 pass in name not id messageOrganizations = messageOrganizationDAO .getPreviousMessageOrganizationRecord(messageOrganization.getId()); if (messageOrganizations.size() > 0) { // enable next button request.setAttribute(PREVIOUS_DISABLED, "false"); } // end of logic to enable next or previous button } else { // this is a new messageOrganization // default started date to today's date Date today = Calendar.getInstance().getTime(); Locale locale = (Locale) request.getSession().getAttribute("org.apache.struts.action.LOCALE"); String dateAsText = DateUtil.formatDateAsText(today, locale); messageOrganization.setActiveBeginDateForDisplay(dateAsText); // default isActive to 'Y' messageOrganization.setIsActive(YES); isNew = true; // this is to set correct page title } if (messageOrganization.getId() != null && !messageOrganization.getId().equals("0")) { request.setAttribute(ID, messageOrganization.getId()); } // populate form from valueholder PropertyUtils.copyProperties(form, messageOrganization); OrganizationDAO organizationDAO = new OrganizationDAOImpl(); // org.setId(messageOrganization.getSelectedOrganizationId()); // organizationDAO.getData(org); String organizationName = null; if (!StringUtil.isNullorNill(messageOrganization.getSelectedOrganizationId())) { Organization organization = new Organization(); organization.setId(messageOrganization.getSelectedOrganizationId()); organizationDAO.getData(organization); organizationName = organization.getOrganizationName(); } PropertyUtils.setProperty(form, "organizationName", organizationName); return mapping.findForward(forward); }
From source file:us.mn.state.health.lims.note.action.NoteAction.java
protected ActionForward performAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // The first job is to determine if we are coming to this action with an // ID parameter in the request. If there is no parameter, we are // creating a new Note. // If there is a parameter present, we should bring up an existing // Note to edit. String id = request.getParameter(ID); String forward = FWD_SUCCESS; //bugzilla 1922 don't allow notes to be edited through master lists request.setAttribute(ALLOW_EDITS_KEY, "false"); request.setAttribute(PREVIOUS_DISABLED, "true"); request.setAttribute(NEXT_DISABLED, "true"); DynaActionForm dynaForm = (DynaActionForm) form; // initialize the form dynaForm.initialize(mapping);//from ww w. java2 s .c om Note note = new Note(); //System.out.println("I am in NoteAction and this is id " + id); if ((id != null) && (!"0".equals(id))) { // this is an existing // note note.setId(id); NoteDAO noteDAO = new NoteDAOImpl(); noteDAO.getData(note); isNew = false; // this is to set correct page title // do we need to enable next or previous? //bugzilla 1427 pass in name not id List notes = noteDAO.getNextNoteRecord(note.getId()); if (notes.size() > 0) { // enable next button request.setAttribute(NEXT_DISABLED, "false"); } //bugzilla 1427 pass in name not id notes = noteDAO.getPreviousNoteRecord(note.getId()); if (notes.size() > 0) { // enable next button request.setAttribute(PREVIOUS_DISABLED, "false"); } // end of logic to enable next or previous button } else { // this is a new note isNew = true; // this is to set correct page title } if (note.getId() != null && !note.getId().equals("0")) { request.setAttribute(ID, note.getId()); } // populate form from valueholder PropertyUtils.copyProperties(form, note); //initialize id if (note.getSystemUser() != null) { PropertyUtils.setProperty(form, "systemUserId", note.getSystemUser().getId()); } //bugzilla 1922 dropdown of system users SystemUserDAO sysUserDAO = new SystemUserDAOImpl(); List sysUsers = sysUserDAO.getAllSystemUsers(); PropertyUtils.setProperty(form, "sysUsers", sysUsers); //System.out.println("I am in NoteAction this is forward " + forward); return mapping.findForward(forward); }
From source file:us.mn.state.health.lims.note.action.NotesPopupAction.java
protected ActionForward performAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String forward = FWD_SUCCESS; request.setAttribute(ALLOW_EDITS_KEY, "true"); String refId = request.getParameter(NOTES_REFID); String referenceTableId = request.getParameter(NOTES_REFTABLE); //bugzilla 1942 String disableExternalNotes = request.getParameter(NOTES_EXTERNAL_NOTES_DISABLED); BaseActionForm dynaForm = (BaseActionForm) form; // initialize the form dynaForm.initialize(mapping);/*from w w w .j a va 2s . c om*/ NoteDAO noteDAO = new NoteDAOImpl(); // now get the Notes for this result if exist Note note = new Note(); List notes = new ArrayList(); note.setReferenceId(refId); // bugzilla 1922 //bugzilla 2571 go through ReferenceTablesDAO to get reference tables info ReferenceTables referenceTables = new ReferenceTables(); referenceTables.setId(referenceTableId); note.setReferenceTables(referenceTables); notes = noteDAO.getAllNotesByRefIdRefTable(note); if (notes != null && notes.size() > 0) { PropertyUtils.setProperty(dynaForm, "notes", notes); } else { PropertyUtils.setProperty(dynaForm, "notes", new ArrayList()); } if (!StringUtil.isNullorNill(disableExternalNotes)) { PropertyUtils.setProperty(dynaForm, "disableExternalNotes", disableExternalNotes); } else { PropertyUtils.setProperty(dynaForm, "disableExternalNotes", "false"); } request.setAttribute("id", refId); request.setAttribute("tableId", referenceTableId); return mapping.findForward(forward); }
From source file:us.mn.state.health.lims.organization.action.OrganizationAction.java
protected ActionForward performAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // The first job is to determine if we are coming to this action with an // ID parameter in the request. If there is no parameter, we are // creating a new Organization. // If there is a parameter present, we should bring up an existing // Organization to edit. String id = request.getParameter(ID); String forward = FWD_SUCCESS; request.setAttribute(ALLOW_EDITS_KEY, "true"); request.setAttribute(PREVIOUS_DISABLED, "true"); request.setAttribute(NEXT_DISABLED, "true"); BaseActionForm dynaForm = (BaseActionForm) form; // initialize the form dynaForm.initialize(mapping);// w w w .ja va2 s . c o m List<Dictionary> departmentList = getDepartmentList(); PropertyUtils.setProperty(dynaForm, "departmentList", departmentList); Organization organization = new Organization(); isNew = (id == null) || "0".equals(id); OrganizationDAO organizationDAO = new OrganizationDAOImpl(); if (!isNew) { organization.setId(id); organizationDAO.getData(organization); if (organization.getOrganization() != null) { organization.setSelectedOrgId(organization.getOrganization().getId()); } List organizations = organizationDAO.getNextOrganizationRecord(organization.getOrganizationName()); if (organizations.size() > 0) { request.setAttribute(NEXT_DISABLED, "false"); } organizations = organizationDAO.getPreviousOrganizationRecord(organization.getOrganizationName()); if (organizations.size() > 0) { request.setAttribute(PREVIOUS_DISABLED, "false"); } if (useCommune || useDepartment || useVillage) { List<OrganizationAddress> orgAddressList = orgAddressDAO.getAddressPartsByOrganizationId(id); for (OrganizationAddress orgAddress : orgAddressList) { if (useCommune && COMMUNE_ID.equals(orgAddress.getAddressPartId())) { PropertyUtils.setProperty(dynaForm, "commune", orgAddress.getValue()); } else if (useVillage && VILLAGE_ID.equals(orgAddress.getAddressPartId())) { PropertyUtils.setProperty(dynaForm, "village", orgAddress.getValue()); } else if (useDepartment && DEPARTMENT_ID.equals(orgAddress.getAddressPartId())) { PropertyUtils.setProperty(dynaForm, "department", orgAddress.getValue()); } } } } else { // this is a new organization // default isActive to 'Y' organization.setIsActive(YES); organization.setMlsSentinelLabFlag(NO); organization.setMlsLabFlag("N"); } // initialize state to MN if (organization.getState() == null) { organization.setState("MN"); } if (organization.getId() != null && !organization.getId().equals("0")) { request.setAttribute(ID, organization.getId()); } PropertyUtils.copyProperties(form, organization); if (useParentOrganization) { setParentOrganiztionName(form, organization, organizationDAO); } if (useOrganizationState) { setCityStateZipList(form); } if (useOrganizationTypeList) { List<OrganizationType> orgTypeList = getOrganizationTypeList(); String[] selectedList = new String[orgTypeList.size()]; PropertyUtils.setProperty(form, "orgTypes", orgTypeList); if (organization.getId() != null && orgTypeList != null) { if (orgTypeList.size() > 0) { OrganizationOrganizationTypeDAO ootDAO = new OrganizationOrganizationTypeDAOImpl(); List<String> selectedOrgTypeList = ootDAO.getTypeIdsForOrganizationId(organization.getId()); int index = 0; for (String orgTypeId : selectedOrgTypeList) { selectedList[index] = orgTypeId; index++; } } } PropertyUtils.setProperty(form, "selectedTypes", selectedList); } return mapping.findForward(forward); }
From source file:us.mn.state.health.lims.organization.action.OrganizationAction.java
private void setParentOrganiztionName(ActionForm form, Organization organization, OrganizationDAO organizationDAO) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { Organization parentOrg = new Organization(); String parentOrgName = null;/*from w w w. j av a 2 s.c om*/ if (!StringUtil.isNullorNill(organization.getSelectedOrgId())) { parentOrg.setId(organization.getSelectedOrgId()); organizationDAO.getData(parentOrg); parentOrgName = parentOrg.getOrganizationName(); } PropertyUtils.setProperty(form, "parentOrgName", parentOrgName); }
From source file:us.mn.state.health.lims.organization.action.OrganizationAction.java
private void setCityStateZipList(ActionForm form) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { if (FormFields.getInstance().useField(FormFields.Field.OrgState)) { // bugzilla 1545 CityStateZipDAO cityStateZipDAO = new CityStateZipDAOImpl(); List states = cityStateZipDAO.getAllStateCodes(); PropertyUtils.setProperty(form, "states", states); }//from w w w . j a va2s.c o m }
From source file:us.mn.state.health.lims.organization.action.OrganizationUpdateAction.java
protected ActionForward performAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String forward = FWD_SUCCESS; request.setAttribute(ALLOW_EDITS_KEY, "true"); request.setAttribute(PREVIOUS_DISABLED, "false"); request.setAttribute(NEXT_DISABLED, "false"); String id = request.getParameter(ID); isNew = (StringUtil.isNullorNill(id) || "0".equals(id)); BaseActionForm dynaForm = (BaseActionForm) form; selectedOrgTypes = dynaForm.getStrings("selectedTypes"); ActionMessages errors = dynaForm.validate(mapping, request); try {/*from w w w.j av a2s . c om*/ errors = validateAll(request, errors, dynaForm); } catch (Exception e) { LogEvent.logError("OrganizationUpdateAction", "performAction()", e.toString()); ActionError error = new ActionError("errors.ValidationException", null, null); errors.add(ActionMessages.GLOBAL_MESSAGE, error); } if (errors != null && errors.size() > 0) { saveErrors(request, errors); return mapping.findForward(FWD_FAIL); } String start = (String) request.getParameter("startingRecNo"); String direction = (String) request.getParameter("direction"); Organization organization = new Organization(); organization.setSysUserId(currentUserId); List states = null; states = getPossibleStates(dynaForm, states); PropertyUtils.copyProperties(organization, dynaForm); if (FormFields.getInstance().useField(FormFields.Field.OrganizationParent)) { String parentOrgName = (String) dynaForm.get("parentOrgName"); Organization o = new Organization(); o.setOrganizationName(parentOrgName); Organization parentOrg = organizationDAO.getOrganizationByName(o, false); organization.setOrganization(parentOrg); } createAddressParts(id, dynaForm); org.hibernate.Transaction tx = HibernateUtil.getSession().beginTransaction(); try { if (!isNew) { organizationDAO.updateData(organization); } else { organizationDAO.insertData(organization); } persistAddressParts(organization); linkOrgWithOrgType(organization); tx.commit(); } catch (LIMSRuntimeException lre) { // bugzilla 2154 LogEvent.logError("OrganizationUpdateAction", "performAction()", lre.toString()); tx.rollback(); errors = new ActionMessages(); ActionError error = null; if (lre.getException() instanceof org.hibernate.StaleObjectStateException) { // how can I get popup instead of struts error at the top of // page? // ActionMessages errors = dynaForm.validate(mapping, request); error = new ActionError("errors.OptimisticLockException", null, null); } else { // bugzilla 1482 if (lre.getException() instanceof LIMSDuplicateRecordException) { java.util.Locale locale = (java.util.Locale) request.getSession() .getAttribute("org.apache.struts.action.LOCALE"); String messageKey = "organization.organization"; String msg = ResourceLocator.getInstance().getMessageResources().getMessage(locale, messageKey); error = new ActionError("errors.DuplicateRecord.activeonly", msg, null); } else { error = new ActionError("errors.UpdateException", null, null); } } errors.add(ActionMessages.GLOBAL_MESSAGE, error); saveErrors(request, errors); request.setAttribute(Globals.ERROR_KEY, errors); request.setAttribute(PREVIOUS_DISABLED, "true"); request.setAttribute(NEXT_DISABLED, "true"); forward = FWD_FAIL; } finally { HibernateUtil.closeSession(); } if (forward.equals(FWD_FAIL)) return mapping.findForward(forward); dynaForm.initialize(mapping); PropertyUtils.copyProperties(dynaForm, organization); if (states != null) { PropertyUtils.setProperty(form, "states", states); } if ("true".equalsIgnoreCase(request.getParameter("close"))) { forward = FWD_CLOSE; } if (organization.getId() != null && !organization.getId().equals("0")) { request.setAttribute(ID, organization.getId()); } if (isNew) { forward = FWD_SUCCESS_INSERT; } return getForward(mapping.findForward(forward), id, start, direction); }
From source file:us.mn.state.health.lims.panelitem.action.PanelItemAction.java
protected ActionForward performAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // The first job is to determine if we are coming to this action with an // ID parameter in the request. If there is no parameter, we are // creating a new PanelItem. // If there is a parameter present, we should bring up an existing // PanelItem to edit. String id = request.getParameter(ID); String forward = FWD_SUCCESS; request.setAttribute(ALLOW_EDITS_KEY, "true"); request.setAttribute(PREVIOUS_DISABLED, "true"); request.setAttribute(NEXT_DISABLED, "true"); DynaActionForm dynaForm = (DynaActionForm) form; // initialize the form dynaForm.initialize(mapping);// w w w. jav a 2s . com PanelItem panelItem = new PanelItem(); if ((id != null) && (!"0".equals(id))) { // this is an existing // panelItem panelItem.setId(id); PanelItemDAO panelItemDAO = new PanelItemDAOImpl(); panelItemDAO.getData(panelItem); // initialize selectedPanelItemId if (panelItem.getPanel() != null) { panelItem.setSelectedPanelId(panelItem.getPanel().getId()); } isNew = false; // this is to set correct page title // do we need to enable next or previous? List panelItems = panelItemDAO.getNextPanelItemRecord(panelItem.getId()); if (panelItems.size() > 0) { // enable next button request.setAttribute(NEXT_DISABLED, "false"); } panelItems = panelItemDAO.getPreviousPanelItemRecord(panelItem.getId()); if (panelItems.size() > 0) { // enable next button request.setAttribute(PREVIOUS_DISABLED, "false"); } // end of logic to enable next or previous button } else { // this is a new panelItem isNew = true; // this is to set correct page title } if (panelItem.getId() != null && !panelItem.getId().equals("0")) { request.setAttribute(ID, panelItem.getId()); } // populate form from valueholder PropertyUtils.copyProperties(form, panelItem); PanelDAO panelDAO = new PanelDAOImpl(); MethodDAO methodDAO = new MethodDAOImpl(); TestDAO testDAO = new TestDAOImpl(); List parentPanels = panelDAO.getAllActivePanels(); List methods = methodDAO.getAllMethods(); //Get tests by user system id //bugzilla 2160 UserTestSectionDAO userTestSectionDAO = new UserTestSectionDAOImpl(); //bugzilla 2291 List tests = userTestSectionDAO.getAllUserTests(request, true); // set parentPanelName String parentPanelName = null; for (int i = 0; i < parentPanels.size(); i++) { Panel parentPanel = (Panel) parentPanels.get(i); if (parentPanel.getId().equals(panelItem.getSelectedPanelId())) { parentPanelName = parentPanel.getPanelName(); } } PropertyUtils.setProperty(form, "parentPanels", parentPanels); PropertyUtils.setProperty(form, "parentPanelName", parentPanelName); PropertyUtils.setProperty(form, "methods", methods); PropertyUtils.setProperty(form, "tests", tests); return mapping.findForward(forward); }
From source file:us.mn.state.health.lims.panelitem.action.PanelItemUpdateAction.java
protected ActionForward performAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // The first job is to determine if we are coming to this action with an // ID parameter in the request. If there is no parameter, we are // creating a new PanelItem. // If there is a parameter present, we should bring up an existing // PanelItem to edit. String forward = FWD_SUCCESS; request.setAttribute(ALLOW_EDITS_KEY, "true"); request.setAttribute(PREVIOUS_DISABLED, "false"); request.setAttribute(NEXT_DISABLED, "false"); String id = request.getParameter(ID); if (StringUtil.isNullorNill(id) || "0".equals(id)) { isNew = true;//from w w w.j a va2s.c o m } else { isNew = false; } BaseActionForm dynaForm = (BaseActionForm) form; // server-side validation (validation.xml) ActionMessages errors = dynaForm.validate(mapping, request); try { errors = validateAll(request, errors, dynaForm); } catch (Exception e) { //bugzilla 2154 LogEvent.logError("PanelItemUpdateAction", "performAction()", e.toString()); ActionError error = new ActionError("errors.ValidationException", null, null); errors.add(ActionMessages.GLOBAL_MESSAGE, error); } if (errors != null && errors.size() > 0) { // System.out.println("Server side validation errors " // + errors.toString()); saveErrors(request, errors); // since we forward to jsp - not Action we don't need to repopulate // the lists here return mapping.findForward(FWD_FAIL); } String start = (String) request.getParameter("startingRecNo"); String direction = (String) request.getParameter("direction"); // System.out.println("This is ID from request " + id); PanelItem panelItem = new PanelItem(); //get sysUserId from login module UserSessionData usd = (UserSessionData) request.getSession().getAttribute(USER_SESSION_DATA); String sysUserId = String.valueOf(usd.getSystemUserId()); panelItem.setSysUserId(sysUserId); org.hibernate.Transaction tx = HibernateUtil.getSession().beginTransaction(); // String selectedPanelItemId = (String) // dynaForm.get("selectedPanelItemId"); String parentPanelName = (String) dynaForm.get("parentPanelName"); List methods = new ArrayList(); List tests = new ArrayList(); if (dynaForm.get("methods") != null) { methods = (List) dynaForm.get("methods"); } else { MethodDAO methodDAO = new MethodDAOImpl(); methods = methodDAO.getAllMethods(); } if (dynaForm.get("tests") != null) { tests = (List) dynaForm.get("tests"); } else { //Get tests by user system id //bugzilla 2160 UserTestSectionDAO userTestSectionDAO = new UserTestSectionDAOImpl(); //bugzilla 2291 tests = userTestSectionDAO.getAllUserTests(request, true); } // System.out.println("This is selectedPanelItemId " // + dynaForm.get("selectedPanelItemId")); List pans = new ArrayList(); if (dynaForm.get("parentPanels") != null) { pans = (List) dynaForm.get("parentPanels"); } else { PanelDAO panDAO = new PanelDAOImpl(); pans = panDAO.getAllActivePanels(); } Panel parentPanel = null; //System.out.println("Try to find parentPanelName " + parentPanelName // + " in this list "); // get the right parentPanel to update panelItem with for (int i = 0; i < pans.size(); i++) { Panel o = (Panel) pans.get(i); // if (o.getId().equals(selectedPanelItemId)) { //System.out.println("This " + o.getPanelName()); if (o.getPanelName().equals(parentPanelName)) { parentPanel = o; break; } } // populate valueholder from form PropertyUtils.copyProperties(panelItem, dynaForm); //System.out.println("Setting parent panel teo " + parentPanel); if (parentPanel != null) { //System.out.println("This is id " + parentPanel.getId()); } panelItem.setPanel(parentPanel); try { PanelItemDAO panelItemDAO = new PanelItemDAOImpl(); if (!isNew) { // UPDATE panelItemDAO.updateData(panelItem); } else { // INSERT panelItemDAO.insertData(panelItem); } tx.commit(); } catch (LIMSRuntimeException lre) { //bugzilla 2154 LogEvent.logError("PanelItemUpdateAction", "performAction()", lre.toString()); tx.rollback(); errors = new ActionMessages(); java.util.Locale locale = (java.util.Locale) request.getSession() .getAttribute("org.apache.struts.action.LOCALE"); ActionError error = null; if (lre.getException() instanceof org.hibernate.StaleObjectStateException) { // how can I get popup instead of struts error at the top of // page? // ActionMessages errors = dynaForm.validate(mapping, request); error = new ActionError("errors.OptimisticLockException", null, null); } else { // bugzilla 1482 if (lre.getException() instanceof LIMSDuplicateRecordException) { String messageKey = "panelitem.panelitem"; String msg = ResourceLocator.getInstance().getMessageResources().getMessage(locale, messageKey); error = new ActionError("errors.DuplicateRecord", msg, null); } else { error = new ActionError("errors.UpdateException", null, null); } } errors.add(ActionMessages.GLOBAL_MESSAGE, error); saveErrors(request, errors); request.setAttribute(Globals.ERROR_KEY, errors); //bugzilla 1485: allow change and try updating again (enable save button) //request.setAttribute(IActionConstants.ALLOW_EDITS_KEY, "false"); // disable previous and next request.setAttribute(PREVIOUS_DISABLED, "true"); request.setAttribute(NEXT_DISABLED, "true"); forward = FWD_FAIL; } finally { HibernateUtil.closeSession(); } if (forward.equals(FWD_FAIL)) return mapping.findForward(forward); // initialize the form dynaForm.initialize(mapping); // repopulate the form from valueholder PropertyUtils.copyProperties(dynaForm, panelItem); // need to repopulate in case of FWD_FAIL? PropertyUtils.setProperty(form, "parentPanels", pans); if ("true".equalsIgnoreCase(request.getParameter("close"))) { forward = FWD_CLOSE; } if (panelItem.getId() != null && !panelItem.getId().equals("0")) { request.setAttribute(ID, panelItem.getId()); } //bugzilla 1400 if (isNew) forward = FWD_SUCCESS_INSERT; //bugzilla 1467 added direction for redirect to NextPreviousAction return getForward(mapping.findForward(forward), id, start, direction); }