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.dataexchange.aggregatereporting.action.TestUsageConfigurationAction.java
@Override protected ActionForward performAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { request.setAttribute(ALLOW_EDITS_KEY, "true"); request.setAttribute(PREVIOUS_DISABLED, "true"); request.setAttribute(NEXT_DISABLED, "true"); request.getSession().setAttribute(SAVE_DISABLED, "false"); DynaActionForm dynaForm = (DynaActionForm) (form); dynaForm.initialize(mapping);//from ww w. j a v a2s .c om PropertyUtils.setProperty(dynaForm, "hourList", DisplayListService.getList(ListType.HOURS)); PropertyUtils.setProperty(dynaForm, "minList", DisplayListService.getList(ListType.MINS)); setSchedulerProperties(dynaForm, "sendSiteIndicators", "enableSending", "sendMin", "sendHour"); setSiteProperties(dynaForm, "testUsageAggregationUrl", "url"); setSiteProperties(dynaForm, "testUsageAggregationUserName", "serviceUserName"); setSiteProperties(dynaForm, "testUsageAggregationPassword", "servicePassword"); PropertyUtils.setProperty(dynaForm, "lastAttemptToSend", getLastEvent("sendSiteIndicators")); PropertyUtils.setProperty(dynaForm, "lastSent", getLastSent()); PropertyUtils.setProperty(dynaForm, "sendStatus", getSendStatus()); return mapping.findForward(FWD_SUCCESS); }
From source file:us.mn.state.health.lims.dataexchange.aggregatereporting.action.TestUsageConfigurationAction.java
private void setSiteProperties(DynaActionForm dynaForm, String siteName, String bean) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { SiteInformation site = siteInfoDAO.getSiteInformationByName(siteName); if (site != null) { PropertyUtils.setProperty(dynaForm, bean, site.getValue()); }/*from ww w . java 2s. c o m*/ }
From source file:us.mn.state.health.lims.dataexchange.aggregatereporting.action.TestUsageConfigurationAction.java
private void setSchedulerProperties(DynaActionForm dynaForm, String indicatorName, String enable, String min, String hour) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { CronScheduler sendScheduler = cronSchedulerDAO.getCronScheduleByJobName(indicatorName); if (sendScheduler == null) { PropertyUtils.setProperty(dynaForm, enable, "enable"); } else {//from ww w . jav a 2s . c o m PropertyUtils.setProperty(dynaForm, enable, sendScheduler.getActive() ? "enable" : "disable"); String cronString = sendScheduler.getCronStatement(); if (!"never".equals(cronString)) { String[] cronParts = cronString.split(" "); int minutes = Integer.parseInt(cronParts[1]); PropertyUtils.setProperty(dynaForm, min, String.valueOf((int) (minutes / 10) * 10)); PropertyUtils.setProperty(dynaForm, hour, cronParts[2]); } } }
From source file:us.mn.state.health.lims.dataexchange.resultreporting.action.ResultReportingConfigurationAction.java
@Override protected ActionForward performAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { request.setAttribute(ALLOW_EDITS_KEY, "true"); request.setAttribute(PREVIOUS_DISABLED, "true"); request.setAttribute(NEXT_DISABLED, "true"); request.getSession().setAttribute(SAVE_DISABLED, "false"); DynaActionForm dynaForm = (DynaActionForm) (form); dynaForm.initialize(mapping);/* w ww . ja v a 2s . co m*/ ExchangeConfigurationService configService = new ExchangeConfigurationService(ConfigurationDomain.REPORT); PropertyUtils.setProperty(dynaForm, "reports", configService.getConfigurations()); PropertyUtils.setProperty(dynaForm, "hourList", DisplayListService.getList(ListType.HOURS)); PropertyUtils.setProperty(dynaForm, "minList", DisplayListService.getList(ListType.MINS)); return mapping.findForward(FWD_SUCCESS); }
From source file:us.mn.state.health.lims.dictionary.action.DictionaryAction.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 Dictionary. // If there is a parameter present, we should bring up an existing // Dictionary to edit. String id = request.getParameter(ID); String forward = FWD_SUCCESS; request.setAttribute(ALLOW_EDITS_KEY, "true"); //bugzilla 2062 request.setAttribute(RECORD_FROZEN_EDIT_DISABLED_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 .j a v a 2 s .co m*/ Dictionary dictionary = new Dictionary(); if ((id != null) && (!"0".equals(id))) { // this is an existing // dictionary dictionary.setId(id); DictionaryDAO dictionaryDAO = new DictionaryDAOImpl(); dictionaryDAO.getData(dictionary); isNew = false; // this is to set correct page title // do we need to enable next or previous? List dictionarys = dictionaryDAO.getNextDictionaryRecord(dictionary.getId()); if (dictionarys.size() > 0) { // enable next button request.setAttribute(NEXT_DISABLED, "false"); } dictionarys = dictionaryDAO.getPreviousDictionaryRecord(dictionary.getId()); if (dictionarys.size() > 0) { // enable next button request.setAttribute(PREVIOUS_DISABLED, "false"); } // end of logic to enable next or previous button } else { // this is a new dictionary // default isActive to 'Y' dictionary.setIsActive(YES); isNew = true; // this is to set correct page title } if (dictionary.getId() != null && !dictionary.getId().equals("0")) { request.setAttribute(ID, dictionary.getId()); // bugzilla 2062 initialize selectedDictionaryCategoryId if (dictionary.getDictionaryCategory() != null) { dictionary.setSelectedDictionaryCategoryId(dictionary.getDictionaryCategory().getId()); } } // populate form from valueholder PropertyUtils.copyProperties(form, dictionary); DictionaryCategoryDAO dictCategorygDAO = new DictionaryCategoryDAOImpl(); List dictCats = dictCategorygDAO.getAllDictionaryCategorys(); PropertyUtils.setProperty(form, "categories", dictCats); return mapping.findForward(forward); }
From source file:us.mn.state.health.lims.healthcenter.action.HealthCenterMenuAction.java
@Override protected ActionForward performAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { HealthCenterDAOImpl healthCenterDAO = new HealthCenterDAOImpl(); DynaActionForm dynaForm = (DynaActionForm) form; request.setAttribute("currentAction", "list"); PropertyUtils.setProperty(dynaForm, "healthCenters", healthCenterDAO.getAll()); return mapping.findForward("success"); //To change body of implemented methods use File | Settings | File Templates. }
From source file:us.mn.state.health.lims.inventory.action.FindInventoryAction.java
@Override 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, "true"); request.setAttribute(NEXT_DISABLED, "true"); request.getSession().setAttribute(SAVE_DISABLED, FALSE); DynaActionForm dynaForm = (DynaActionForm) form; InventoryUtility utility = new InventoryUtility(); List<InventoryKitItem> list = utility.getExistingInventory(); PropertyUtils.setProperty(dynaForm, "inventoryItems", list); List<String> kitTypes = getTestKitTypes(); PropertyUtils.setProperty(dynaForm, "kitTypes", kitTypes); List<IdValuePair> sources = getSources(); PropertyUtils.setProperty(dynaForm, "sources", sources); return mapping.findForward(forward); }
From source file:us.mn.state.health.lims.label.action.LabelAction.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 Label. // If there is a parameter present, we should bring up an existing // Label 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; //AIS - bugzilla 1562 List scriptlets = new ArrayList(); ScriptletDAO scriptletDAO = new ScriptletDAOImpl(); scriptlets = scriptletDAO.getAllScriptlets(); // initialize the form dynaForm.initialize(mapping);//from ww w. j ava 2s . c om Label label = new Label(); if ((id != null) && (!"0".equals(id))) { // this is an existing // label label.setId(id); LabelDAO labelDAO = new LabelDAOImpl(); labelDAO.getData(label); // initialize selectedLabelId if (label.getScriptlet() != null) { label.setScriptletName(label.getScriptlet().getScriptletName()); } 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 labels = labelDAO.getNextLabelRecord(label.getLabelName()); if (labels.size() > 0) { // enable next button request.setAttribute(NEXT_DISABLED, "false"); } //bugzilla 1427 pass in name not id labels = labelDAO.getPreviousLabelRecord(label.getLabelName()); if (labels.size() > 0) { // enable next button request.setAttribute(PREVIOUS_DISABLED, "false"); } // end of logic to enable next or previous button } else { // this is a new label isNew = true; // this is to set correct page title } if (label.getId() != null && !label.getId().equals("0")) { request.setAttribute(ID, label.getId()); } // populate form from valueholder //AIS - bugzilla 1562 PropertyUtils.setProperty(form, "scriptlets", scriptlets); PropertyUtils.copyProperties(form, label); return mapping.findForward(forward); }
From source file:us.mn.state.health.lims.login.action.LoginChangePasswordAction.java
protected ActionForward performAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String forward = FWD_SUCCESS; DynaActionForm dynaForm = (DynaActionForm) form; PropertyUtils.setProperty(dynaForm, "password", ""); PropertyUtils.setProperty(dynaForm, "newPassword", ""); PropertyUtils.setProperty(dynaForm, "confirmPassword", ""); return mapping.findForward(forward); }
From source file:us.mn.state.health.lims.login.action.LoginUserAction.java
protected ActionForward performAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { 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 ava2 s .c o m*/ //bugzilla 2314 Date today = Calendar.getInstance().getTime(); Locale locale = (Locale) request.getSession().getAttribute("org.apache.struts.action.LOCALE"); String dateAsText = DateUtil.formatDateAsText(today, locale); PropertyUtils.setProperty(form, "currentDate", dateAsText); Login login = new Login(); if ((id != null) && (!"0".equals(id))) { login.setId(id); LoginDAO loginDAO = new LoginDAOImpl(); loginDAO.getData(login); isNew = false; List logins = loginDAO.getNextLoginUserRecord(login.getId()); if (logins.size() > 0) { // enable next button request.setAttribute(NEXT_DISABLED, "false"); } logins = loginDAO.getPreviousLoginUserRecord(login.getId()); if (logins.size() > 0) { // enable next button request.setAttribute(PREVIOUS_DISABLED, "false"); } // end of logic to enable next or previous button } else { //java.util.Date today = java.util.Calendar.getInstance().getTime(); login.setPasswordExpiredDateForDisplay(dateAsText); isNew = true; // this is to set correct page title } if (login.getId() != null && !login.getId().equals("0")) { request.setAttribute(ID, login.getId()); } // populate form from valueholder PropertyUtils.copyProperties(form, login); return mapping.findForward(forward); }