* @param definition
* @param request
* @param subcategory for if the category is split into sub categories.
*/
public AbstractPropertyItem(PropertyDefinition definition, HttpServletRequest request, String subcategory) {
MessageResources messageResources = null;
if (definition.getMessageResourcesKey() != null) {
messageResources = CoreUtil.getMessageResources(request.getSession(), definition.getMessageResourcesKey());
}
this.definition = definition;
categoryLabel = this.definition.getCategoryLabel();
String messageId = subcategory == null ? "attributeCategory." + definition.getCategory() + ".title" : "attributeCategory."
+ definition.getCategory() + "." + subcategory + ".title";
Locale locale = (Locale)request.getSession().getAttribute(Globals.LOCALE_KEY);
// Get an internationalised category label if possible
String s = messageResources == null ? null : messageResources.getMessage(locale, messageId);
if (s != null && !s.equals("")) {
this.categoryLabel = s;
} else {
if (categoryLabel == null || categoryLabel.equals("")) {
this.categoryLabel = "Attributes";
}
}
label = this.definition.getLabel();
// Get an internationalised label if possible, otherwise use default
// label, otherwise use name
s = messageResources == null ? null : messageResources.getMessage(locale, this.definition.getPropertyClass().getName() + "."
+ definition.getName() + ".title");
if (s != null && !s.equals("")) {
label = s;
} else {
if (label != null && label.equals("")) {
label = definition.getName();
}
}
if (getCategoryLabel() != null)
categoryId = Util.makeConstantKey(getCategoryLabel());
// If there are ApplicationResources for the definition then set the
// label and description with these.
String tmpLabel = messageResources == null ? null : messageResources.getMessage(locale, definition.getNameMessageResourceKey());
if (tmpLabel != null) {
this.definition.setLabel(tmpLabel);
label = tmpLabel;
}
String description = messageResources == null ? null : messageResources.getMessage(locale, definition
.getDescriptionMessageResourceKey());
if (description != null) {
this.definition.setDescription(description);
}
}