List of usage examples for com.liferay.portal.kernel.bean BeanPropertiesUtil getObject
public static Object getObject(Object bean, String param)
From source file:com.liferay.dynamic.data.mapping.validator.internal.DDMFormValidatorImpl.java
License:Open Source License
protected void validateOptionalDDMFormFieldLocalizedProperty(DDMFormField ddmFormField, String propertyName, Set<Locale> ddmFormAvailableLocales, Locale ddmFormDefaultLocale) throws DDMFormValidationException { LocalizedValue propertyValue = (LocalizedValue) BeanPropertiesUtil.getObject(ddmFormField, propertyName); if (MapUtil.isEmpty(propertyValue.getValues())) { return;//w ww . java 2 s . c om } validateDDMFormFieldPropertyValue(ddmFormField.getName(), propertyName, propertyValue, ddmFormAvailableLocales, ddmFormDefaultLocale); }
From source file:com.liferay.filesystemaccess.audit.AttributesBuilder.java
License:Open Source License
public void add(String name) { String newValue = String.valueOf(BeanPropertiesUtil.getObject(_newBean, name)); String oldValue = String.valueOf(BeanPropertiesUtil.getObject(_oldBean, name)); if (!Objects.equals(newValue, oldValue)) { Attribute attribute = new Attribute(name, newValue, oldValue); _attributes.add(attribute);//from w w w. ja va 2 s . c om } }
From source file:com.liferay.opensocial.shindig.util.SerializerUtil.java
License:Open Source License
protected static String getBeanProperty(Object bean, String fieldName) { Object value = BeanPropertiesUtil.getObject(bean, fieldName); if (value == null) { return null; }//from w w w .ja v a2 s. co m if (fieldName.equals("location")) { JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); copyProperties(value, jsonObject, _ADDRESS_FIELDS); return jsonObject.toString(); } else { return (String) value; } }
From source file:com.liferay.portlet.documentlibrary.util.AttributesBuilder.java
License:Open Source License
public void add(String name) { String newValue = String.valueOf(BeanPropertiesUtil.getObject(_newBean, name)); String oldValue = String.valueOf(BeanPropertiesUtil.getObject(_oldBean, name)); if (!Validator.equals(newValue, oldValue)) { Attribute attribute = new Attribute(name, newValue, oldValue); _attributes.add(attribute);//from w w w . j a v a 2 s . c om } }
From source file:com.liferay.taglib.ui.SearchContainerColumnTextTag.java
License:Open Source License
@Override public int doEndTag() { try {// ww w .jav a2 s.c o m SearchContainerRowTag<R> searchContainerRowTag = (SearchContainerRowTag<R>) findAncestorWithClass(this, SearchContainerRowTag.class); ResultRow row = searchContainerRowTag.getRow(); if (Validator.isNotNull(_property)) { _value = String.valueOf(BeanPropertiesUtil.getObject(row.getObject(), _property)); } else if (Validator.isNotNull(_buffer)) { _value = _sb.toString(); } else if (_value == null) { BodyContent bodyContent = getBodyContent(); if (bodyContent != null) { _value = bodyContent.getString(); } else { Object object = BeanPropertiesUtil.getObject(row.getObject(), getName()); _value = String.valueOf(object); } } if (_translate) { _value = LanguageUtil.get(pageContext, _value); } if (index <= -1) { index = row.getEntries().size(); } if (row.isRestricted()) { _href = null; } TextSearchEntry textSearchEntry = new TextSearchEntry(); textSearchEntry.setAlign(getAlign()); textSearchEntry.setColspan(getColspan()); textSearchEntry.setCssClass(getCssClass()); textSearchEntry.setHref((String) getHref()); textSearchEntry.setName(getValue()); textSearchEntry.setTarget(getTarget()); textSearchEntry.setTitle(getTitle()); textSearchEntry.setValign(getValign()); row.addSearchEntry(index, textSearchEntry); return EVAL_PAGE; } finally { index = -1; _value = null; if (!ServerDetector.isResin()) { align = SearchEntry.DEFAULT_ALIGN; _buffer = null; colspan = SearchEntry.DEFAULT_COLSPAN; cssClass = SearchEntry.DEFAULT_CSS_CLASS; _href = null; name = null; _orderable = false; _orderableProperty = null; _property = null; _sb = null; _target = null; _title = null; _translate = false; valign = SearchEntry.DEFAULT_VALIGN; } } }
From source file:com.liferay.taglib.ui.SearchContainerRowTag.java
License:Open Source License
protected void processRow() { Object model = _results.get(_rowIndex); if (isEscapedModel()) { if (model instanceof BaseModel) { BaseModel<?> baseModel = (BaseModel<?>) model; model = baseModel.toEscapedModel(); } else if (model instanceof RepositoryModel) { RepositoryModel<?> repositoryModel = (RepositoryModel<?>) model; model = repositoryModel.toEscapedModel(); }//ww w.j a v a2 s. c om } if (Validator.isNull(_keyProperty)) { String primaryKey = String.valueOf(model); _row = new ResultRow(model, primaryKey, _rowIndex, _bold); } else if (isStringKey()) { String primaryKey = BeanPropertiesUtil.getString(model, _keyProperty); _row = new ResultRow(model, primaryKey, _rowIndex, _bold); } else { Object primaryKey = BeanPropertiesUtil.getObject(model, _keyProperty); _row = new ResultRow(model, String.valueOf(primaryKey), _rowIndex, _bold); } pageContext.setAttribute(_indexVar, _rowIndex); pageContext.setAttribute(_modelVar, model); pageContext.setAttribute(_rowVar, _row); }
From source file:com.liferay.users.admin.web.internal.portlet.action.ExportUsersMVCResourceCommand.java
License:Open Source License
protected String getUserCSV(User user) { StringBundler sb = new StringBundler(PropsValues.USERS_EXPORT_CSV_FIELDS.length * 2); for (int i = 0; i < PropsValues.USERS_EXPORT_CSV_FIELDS.length; i++) { String field = PropsValues.USERS_EXPORT_CSV_FIELDS[i]; if (field.startsWith("expando:")) { String attributeName = field.substring(8); ExpandoBridge expandoBridge = user.getExpandoBridge(); sb.append(CSVUtil.encode(expandoBridge.getAttribute(attributeName))); } else if (field.contains("Date")) { Date date = (Date) BeanPropertiesUtil.getObject(user, field); if (date instanceof Timestamp) { date = new Date(date.getTime()); }// w ww. ja v a 2 s . co m sb.append(CSVUtil.encode(String.valueOf(date))); } else if (field.equals("fullName")) { sb.append(CSVUtil.encode(user.getFullName())); } else { sb.append(CSVUtil.encode(BeanPropertiesUtil.getString(user, field))); } if ((i + 1) < PropsValues.USERS_EXPORT_CSV_FIELDS.length) { sb.append(StringPool.COMMA); } } sb.append(StringPool.NEW_LINE); return sb.toString(); }
From source file:com.liferay.util.Autocomplete.java
License:Open Source License
public static String[][] listToArray(List<?> list, String textParam, String valueParam) { String[][] array = new String[list.size()][2]; for (int i = 0; i < list.size(); i++) { Object bean = list.get(i); Object text = BeanPropertiesUtil.getObject(bean, textParam); if (text == null) { text = StringPool.BLANK;//from ww w . jav a2s. c om } Object value = BeanPropertiesUtil.getObject(bean, valueParam); if (value == null) { value = StringPool.BLANK; } array[i][0] = text.toString(); array[i][1] = value.toString(); } return array; }