List of usage examples for org.apache.commons.beanutils PropertyUtils isReadable
public static boolean isReadable(Object bean, String name)
Return true
if the specified property name identifies a readable property on the specified bean; otherwise, return false
.
For more details see PropertyUtilsBean
.
From source file:org.andromda.timetracker.web.timecarddetails.TimecardPopulator.java
/** * @param facesContext/*from ww w. j a v a2 s.c om*/ * @param form * @throws ServletException */ public static void populateFormAndViewVariables(final FacesContext facesContext, Object form) throws ServletException { final HttpServletRequest request = (HttpServletRequest) facesContext.getExternalContext().getRequest(); final HttpSession session = (HttpSession) facesContext.getExternalContext().getSession(true); RequestContext adfContext = RequestContext.getCurrentInstance(); final VariableResolver variableResolver = facesContext.getApplication().getVariableResolver(); if (form == null) { // - first try getting the form from the ADF PageFlowScope form = adfContext.getPageFlowScope().get("form"); // - if the form is null, try getting the current adfContext from the session (and then remove it from the session) if (form == null) { final AdfFacesContextWrapper contextWrapper = (AdfFacesContextWrapper) session .getAttribute("AndroMDAADFContext"); adfContext = contextWrapper != null ? contextWrapper.getCurrentInstance() : null; form = adfContext != null ? adfContext.getPageFlowScope().get("form") : null; if (form == null) { form = session.getAttribute("form"); session.removeAttribute("form"); } // - if the form is still null, see if we can get it from a serialized state if (form == null) { form = JsfUtils.getSerializedForm(facesContext); } if (form != null) { // - add the form to the current process scope since it wasn't in the current one to begin with RequestContext.getCurrentInstance().getPageFlowScope().put("form", form); } } else { // - remove the ADF context in the event that its present session.removeAttribute("AndroMDAADFContext"); } } else { // - since the form argument is not null, set it as the "form" in the PageFlowScope // (to replace the existing "form" attribute) adfContext.getPageFlowScope().put("form", form); } try { // - serialize the form if (form != null) { JsfUtils.serializeForm(facesContext, form); } // - populate the view variables if (form != null) { final boolean timecardIdReadable = PropertyUtils.isReadable(form, "timecardId"); if (timecardIdReadable) { Boolean propertySet = null; final String isSetPropertyName = "timecardIdSet"; if (PropertyUtils.isReadable(form, isSetPropertyName)) { propertySet = (Boolean) PropertyUtils.getProperty(form, isSetPropertyName); } // - only set the property if its been set, or we can't tell if it has if (propertySet == null || propertySet.booleanValue()) { request.setAttribute("timecardId", PropertyUtils.getProperty(form, "timecardId")); } } } } catch (final Throwable throwable) { throw new ServletException(throwable); } }
From source file:org.andromda.timetracker.web.timecardsearch.SearchTimecardsDetailsFormImpl.java
/** * @param items// w w w . j a v a 2 s.c om * @param valueProperty * @param labelProperty */ public void setIdBackingList(Collection<? extends Object> items, String valueProperty, String labelProperty) { this.idValueList = null; this.idLabelList = null; if (items != null) { this.idValueList = new Object[items.size()]; this.idLabelList = new Object[items.size()]; try { final List<String> labelProperties = labelProperty == null ? null : new ArrayList<String>(Arrays.asList(labelProperty.split("[\\W&&[^\\.]]+"))); final List<String> labelDelimiters = labelProperty == null ? null : new ArrayList<String>(Arrays.asList(labelProperty.split("[\\w\\.]+"))); int ctr = 0; for (final Iterator<? extends Object> iterator = items.iterator(); iterator.hasNext(); ctr++) { final Object item = iterator.next(); if (item != null) { this.idValueList[ctr] = valueProperty == null ? item : PropertyUtils.getProperty(item, valueProperty.trim()); if (labelProperties == null) { this.idLabelList[ctr] = item; } else { final StringBuilder labelText = new StringBuilder(); int ctr2 = 0; do { if (!labelDelimiters.isEmpty()) { labelText.append(labelDelimiters.get(ctr2)); } String property = null; if (ctr2 < labelProperties.size()) { property = labelProperties.get(ctr2); } if (property != null && property.length() > 0) { if (PropertyUtils.isReadable(item, property)) { Object value = PropertyUtils.getProperty(item, property); if (value != null) { if (value instanceof String) { if (((String) value).trim().length() == 0) { value = null; } } if (value != null) { labelText.append(value); } } } else { labelText.append(property); } } ctr2++; } while (ctr2 < labelDelimiters.size()); this.idLabelList[ctr] = labelText.toString().replaceAll("\\s+", " ").trim(); } } } } catch (final Throwable throwable) { throw new RuntimeException(throwable); } } }
From source file:org.andromda.timetracker.web.timecardsearch.SearchTimecardsFormImpl.java
/** * @param items/*from w w w. j a v a 2 s .c om*/ * @param valueProperty * @param labelProperty */ public void setTimecardSummariesBackingList(Collection<? extends Object> items, String valueProperty, String labelProperty) { this.timecardSummariesValueList = null; this.timecardSummariesLabelList = null; if (items != null) { this.timecardSummariesValueList = new Object[items.size()]; this.timecardSummariesLabelList = new Object[items.size()]; try { final List<String> labelProperties = labelProperty == null ? null : new ArrayList<String>(Arrays.asList(labelProperty.split("[\\W&&[^\\.]]+"))); final List<String> labelDelimiters = labelProperty == null ? null : new ArrayList<String>(Arrays.asList(labelProperty.split("[\\w\\.]+"))); int ctr = 0; for (final Iterator<? extends Object> iterator = items.iterator(); iterator.hasNext(); ctr++) { final Object item = iterator.next(); if (item != null) { this.timecardSummariesValueList[ctr] = valueProperty == null ? item : PropertyUtils.getProperty(item, valueProperty.trim()); if (labelProperties == null) { this.timecardSummariesLabelList[ctr] = item; } else { final StringBuilder labelText = new StringBuilder(); int ctr2 = 0; do { if (!labelDelimiters.isEmpty()) { labelText.append(labelDelimiters.get(ctr2)); } String property = null; if (ctr2 < labelProperties.size()) { property = labelProperties.get(ctr2); } if (property != null && property.length() > 0) { if (PropertyUtils.isReadable(item, property)) { Object value = PropertyUtils.getProperty(item, property); if (value != null) { if (value instanceof String) { if (((String) value).trim().length() == 0) { value = null; } } if (value != null) { labelText.append(value); } } } else { labelText.append(property); } } ctr2++; } while (ctr2 < labelDelimiters.size()); this.timecardSummariesLabelList[ctr] = labelText.toString().replaceAll("\\s+", " ") .trim(); } } } } catch (final Throwable throwable) { throw new RuntimeException(throwable); } } }
From source file:org.andromda.timetracker.web.timecardsearch.SearchTimecardsFormImpl.java
/** * @param items/*from www. ja va2 s. c o m*/ * @param valueProperty * @param labelProperty */ public void setTimecardSummariesIdBackingList(Collection<? extends Object> items, String valueProperty, String labelProperty) { this.timecardSummariesIdValueList = null; this.timecardSummariesIdLabelList = null; if (items != null) { this.timecardSummariesIdValueList = new Object[items.size()]; this.timecardSummariesIdLabelList = new Object[items.size()]; try { final List<String> labelProperties = labelProperty == null ? null : new ArrayList<String>(Arrays.asList(labelProperty.split("[\\W&&[^\\.]]+"))); final List<String> labelDelimiters = labelProperty == null ? null : new ArrayList<String>(Arrays.asList(labelProperty.split("[\\w\\.]+"))); int ctr = 0; for (final Iterator<? extends Object> iterator = items.iterator(); iterator.hasNext(); ctr++) { final Object item = iterator.next(); if (item != null) { this.timecardSummariesIdValueList[ctr] = valueProperty == null ? item : PropertyUtils.getProperty(item, valueProperty.trim()); if (labelProperties == null) { this.timecardSummariesIdLabelList[ctr] = item; } else { final StringBuilder labelText = new StringBuilder(); int ctr2 = 0; do { if (!labelDelimiters.isEmpty()) { labelText.append(labelDelimiters.get(ctr2)); } String property = null; if (ctr2 < labelProperties.size()) { property = labelProperties.get(ctr2); } if (property != null && property.length() > 0) { if (PropertyUtils.isReadable(item, property)) { Object value = PropertyUtils.getProperty(item, property); if (value != null) { if (value instanceof String) { if (((String) value).trim().length() == 0) { value = null; } } if (value != null) { labelText.append(value); } } } else { labelText.append(property); } } ctr2++; } while (ctr2 < labelDelimiters.size()); this.timecardSummariesIdLabelList[ctr] = labelText.toString().replaceAll("\\s+", " ") .trim(); } } } } catch (final Throwable throwable) { throw new RuntimeException(throwable); } } }
From source file:org.andromda.timetracker.web.timecardsearch.SearchTimecardsFormImpl.java
/** * @param items/*from ww w . java 2s. c o m*/ * @param valueProperty * @param labelProperty */ public void setTimecardSummariesStatusBackingList(Collection<? extends Object> items, String valueProperty, String labelProperty) { this.timecardSummariesStatusValueList = null; this.timecardSummariesStatusLabelList = null; if (items != null) { this.timecardSummariesStatusValueList = new Object[items.size()]; this.timecardSummariesStatusLabelList = new Object[items.size()]; try { final List<String> labelProperties = labelProperty == null ? null : new ArrayList<String>(Arrays.asList(labelProperty.split("[\\W&&[^\\.]]+"))); final List<String> labelDelimiters = labelProperty == null ? null : new ArrayList<String>(Arrays.asList(labelProperty.split("[\\w\\.]+"))); int ctr = 0; for (final Iterator<? extends Object> iterator = items.iterator(); iterator.hasNext(); ctr++) { final Object item = iterator.next(); if (item != null) { this.timecardSummariesStatusValueList[ctr] = valueProperty == null ? item : PropertyUtils.getProperty(item, valueProperty.trim()); if (labelProperties == null) { this.timecardSummariesStatusLabelList[ctr] = item; } else { final StringBuilder labelText = new StringBuilder(); int ctr2 = 0; do { if (!labelDelimiters.isEmpty()) { labelText.append(labelDelimiters.get(ctr2)); } String property = null; if (ctr2 < labelProperties.size()) { property = labelProperties.get(ctr2); } if (property != null && property.length() > 0) { if (PropertyUtils.isReadable(item, property)) { Object value = PropertyUtils.getProperty(item, property); if (value != null) { if (value instanceof String) { if (((String) value).trim().length() == 0) { value = null; } } if (value != null) { labelText.append(value); } } } else { labelText.append(property); } } ctr2++; } while (ctr2 < labelDelimiters.size()); this.timecardSummariesStatusLabelList[ctr] = labelText.toString() .replaceAll("\\s+", " ").trim(); } } } } catch (final Throwable throwable) { throw new RuntimeException(throwable); } } }
From source file:org.andromda.timetracker.web.timecardsearch.SearchTimecardsFormImpl.java
/** * @param items//from w ww.j a va 2s. c o m * @param valueProperty * @param labelProperty */ public void setTimecardSummariesStartDateBackingList(Collection<? extends Object> items, String valueProperty, String labelProperty) { this.timecardSummariesStartDateValueList = null; this.timecardSummariesStartDateLabelList = null; if (items != null) { this.timecardSummariesStartDateValueList = new Object[items.size()]; this.timecardSummariesStartDateLabelList = new Object[items.size()]; try { final List<String> labelProperties = labelProperty == null ? null : new ArrayList<String>(Arrays.asList(labelProperty.split("[\\W&&[^\\.]]+"))); final List<String> labelDelimiters = labelProperty == null ? null : new ArrayList<String>(Arrays.asList(labelProperty.split("[\\w\\.]+"))); int ctr = 0; for (final Iterator<? extends Object> iterator = items.iterator(); iterator.hasNext(); ctr++) { final Object item = iterator.next(); if (item != null) { this.timecardSummariesStartDateValueList[ctr] = valueProperty == null ? item : PropertyUtils.getProperty(item, valueProperty.trim()); if (labelProperties == null) { this.timecardSummariesStartDateLabelList[ctr] = item; } else { final StringBuilder labelText = new StringBuilder(); int ctr2 = 0; do { if (!labelDelimiters.isEmpty()) { labelText.append(labelDelimiters.get(ctr2)); } String property = null; if (ctr2 < labelProperties.size()) { property = labelProperties.get(ctr2); } if (property != null && property.length() > 0) { if (PropertyUtils.isReadable(item, property)) { Object value = PropertyUtils.getProperty(item, property); if (value != null) { if (value instanceof String) { if (((String) value).trim().length() == 0) { value = null; } } if (value != null) { labelText.append(value); } } } else { labelText.append(property); } } ctr2++; } while (ctr2 < labelDelimiters.size()); this.timecardSummariesStartDateLabelList[ctr] = labelText.toString() .replaceAll("\\s+", " ").trim(); } } } } catch (final Throwable throwable) { throw new RuntimeException(throwable); } } }
From source file:org.andromda.timetracker.web.timecardsearch.SearchTimecardsFormImpl.java
/** * @param items/* w w w . j a va 2 s . co m*/ * @param valueProperty * @param labelProperty */ public void setTimecardSummariesCommentsBackingList(Collection<? extends Object> items, String valueProperty, String labelProperty) { this.timecardSummariesCommentsValueList = null; this.timecardSummariesCommentsLabelList = null; if (items != null) { this.timecardSummariesCommentsValueList = new Object[items.size()]; this.timecardSummariesCommentsLabelList = new Object[items.size()]; try { final List<String> labelProperties = labelProperty == null ? null : new ArrayList<String>(Arrays.asList(labelProperty.split("[\\W&&[^\\.]]+"))); final List<String> labelDelimiters = labelProperty == null ? null : new ArrayList<String>(Arrays.asList(labelProperty.split("[\\w\\.]+"))); int ctr = 0; for (final Iterator<? extends Object> iterator = items.iterator(); iterator.hasNext(); ctr++) { final Object item = iterator.next(); if (item != null) { this.timecardSummariesCommentsValueList[ctr] = valueProperty == null ? item : PropertyUtils.getProperty(item, valueProperty.trim()); if (labelProperties == null) { this.timecardSummariesCommentsLabelList[ctr] = item; } else { final StringBuilder labelText = new StringBuilder(); int ctr2 = 0; do { if (!labelDelimiters.isEmpty()) { labelText.append(labelDelimiters.get(ctr2)); } String property = null; if (ctr2 < labelProperties.size()) { property = labelProperties.get(ctr2); } if (property != null && property.length() > 0) { if (PropertyUtils.isReadable(item, property)) { Object value = PropertyUtils.getProperty(item, property); if (value != null) { if (value instanceof String) { if (((String) value).trim().length() == 0) { value = null; } } if (value != null) { labelText.append(value); } } } else { labelText.append(property); } } ctr2++; } while (ctr2 < labelDelimiters.size()); this.timecardSummariesCommentsLabelList[ctr] = labelText.toString() .replaceAll("\\s+", " ").trim(); } } } } catch (final Throwable throwable) { throw new RuntimeException(throwable); } } }
From source file:org.andromda.timetracker.web.timecardsearch.SearchTimecardsFormImpl.java
/** * @param items//from w w w . j av a 2 s . co m * @param valueProperty * @param labelProperty */ public void setTimecardSummariesSubmitterNameBackingList(Collection<? extends Object> items, String valueProperty, String labelProperty) { this.timecardSummariesSubmitterNameValueList = null; this.timecardSummariesSubmitterNameLabelList = null; if (items != null) { this.timecardSummariesSubmitterNameValueList = new Object[items.size()]; this.timecardSummariesSubmitterNameLabelList = new Object[items.size()]; try { final List<String> labelProperties = labelProperty == null ? null : new ArrayList<String>(Arrays.asList(labelProperty.split("[\\W&&[^\\.]]+"))); final List<String> labelDelimiters = labelProperty == null ? null : new ArrayList<String>(Arrays.asList(labelProperty.split("[\\w\\.]+"))); int ctr = 0; for (final Iterator<? extends Object> iterator = items.iterator(); iterator.hasNext(); ctr++) { final Object item = iterator.next(); if (item != null) { this.timecardSummariesSubmitterNameValueList[ctr] = valueProperty == null ? item : PropertyUtils.getProperty(item, valueProperty.trim()); if (labelProperties == null) { this.timecardSummariesSubmitterNameLabelList[ctr] = item; } else { final StringBuilder labelText = new StringBuilder(); int ctr2 = 0; do { if (!labelDelimiters.isEmpty()) { labelText.append(labelDelimiters.get(ctr2)); } String property = null; if (ctr2 < labelProperties.size()) { property = labelProperties.get(ctr2); } if (property != null && property.length() > 0) { if (PropertyUtils.isReadable(item, property)) { Object value = PropertyUtils.getProperty(item, property); if (value != null) { if (value instanceof String) { if (((String) value).trim().length() == 0) { value = null; } } if (value != null) { labelText.append(value); } } } else { labelText.append(property); } } ctr2++; } while (ctr2 < labelDelimiters.size()); this.timecardSummariesSubmitterNameLabelList[ctr] = labelText.toString() .replaceAll("\\s+", " ").trim(); } } } } catch (final Throwable throwable) { throw new RuntimeException(throwable); } } }
From source file:org.andromda.timetracker.web.timecardsearch.SearchTimecardsFormImpl.java
/** * @param items//from ww w.j a v a2 s . c o m * @param valueProperty * @param labelProperty */ public void setTimecardSummariesApproverNameBackingList(Collection<? extends Object> items, String valueProperty, String labelProperty) { this.timecardSummariesApproverNameValueList = null; this.timecardSummariesApproverNameLabelList = null; if (items != null) { this.timecardSummariesApproverNameValueList = new Object[items.size()]; this.timecardSummariesApproverNameLabelList = new Object[items.size()]; try { final List<String> labelProperties = labelProperty == null ? null : new ArrayList<String>(Arrays.asList(labelProperty.split("[\\W&&[^\\.]]+"))); final List<String> labelDelimiters = labelProperty == null ? null : new ArrayList<String>(Arrays.asList(labelProperty.split("[\\w\\.]+"))); int ctr = 0; for (final Iterator<? extends Object> iterator = items.iterator(); iterator.hasNext(); ctr++) { final Object item = iterator.next(); if (item != null) { this.timecardSummariesApproverNameValueList[ctr] = valueProperty == null ? item : PropertyUtils.getProperty(item, valueProperty.trim()); if (labelProperties == null) { this.timecardSummariesApproverNameLabelList[ctr] = item; } else { final StringBuilder labelText = new StringBuilder(); int ctr2 = 0; do { if (!labelDelimiters.isEmpty()) { labelText.append(labelDelimiters.get(ctr2)); } String property = null; if (ctr2 < labelProperties.size()) { property = labelProperties.get(ctr2); } if (property != null && property.length() > 0) { if (PropertyUtils.isReadable(item, property)) { Object value = PropertyUtils.getProperty(item, property); if (value != null) { if (value instanceof String) { if (((String) value).trim().length() == 0) { value = null; } } if (value != null) { labelText.append(value); } } } else { labelText.append(property); } } ctr2++; } while (ctr2 < labelDelimiters.size()); this.timecardSummariesApproverNameLabelList[ctr] = labelText.toString() .replaceAll("\\s+", " ").trim(); } } } } catch (final Throwable throwable) { throw new RuntimeException(throwable); } } }
From source file:org.andromda.timetracker.web.timecardsearch.SearchTimecardsFormImpl.java
/** * @param items// w w w . j ava 2s . c o m * @param valueProperty * @param labelProperty */ public void setSubmitterBackingList(Collection<? extends Object> items, String valueProperty, String labelProperty) { this.submitterValueList = null; this.submitterLabelList = null; if (items != null) { this.submitterValueList = new Object[items.size()]; this.submitterLabelList = new Object[items.size()]; try { final List<String> labelProperties = labelProperty == null ? null : new ArrayList<String>(Arrays.asList(labelProperty.split("[\\W&&[^\\.]]+"))); final List<String> labelDelimiters = labelProperty == null ? null : new ArrayList<String>(Arrays.asList(labelProperty.split("[\\w\\.]+"))); int ctr = 0; for (final Iterator<? extends Object> iterator = items.iterator(); iterator.hasNext(); ctr++) { final Object item = iterator.next(); if (item != null) { this.submitterValueList[ctr] = valueProperty == null ? item : PropertyUtils.getProperty(item, valueProperty.trim()); if (labelProperties == null) { this.submitterLabelList[ctr] = item; } else { final StringBuilder labelText = new StringBuilder(); int ctr2 = 0; do { if (!labelDelimiters.isEmpty()) { labelText.append(labelDelimiters.get(ctr2)); } String property = null; if (ctr2 < labelProperties.size()) { property = labelProperties.get(ctr2); } if (property != null && property.length() > 0) { if (PropertyUtils.isReadable(item, property)) { Object value = PropertyUtils.getProperty(item, property); if (value != null) { if (value instanceof String) { if (((String) value).trim().length() == 0) { value = null; } } if (value != null) { labelText.append(value); } } } else { labelText.append(property); } } ctr2++; } while (ctr2 < labelDelimiters.size()); this.submitterLabelList[ctr] = labelText.toString().replaceAll("\\s+", " ").trim(); } } } } catch (final Throwable throwable) { throw new RuntimeException(throwable); } } }