/** * Get the name of the {@link com.xpn.xwiki.api.Class XClass} (Object Definition) this property definition belongs * to. For example, {@code XWiki.XWikiUsers} or {@code Blog.BlogPostClass}. * * @return the name of the owner XClass */ public String getClassName() { return getBasePropertyClass().getObject().getName(); }
public boolean validateProperty(BaseProperty property, XWikiContext context) { String regexp = getValidationRegExp(); if ((regexp == null) || (regexp.trim().equals(""))) { return true; } String value = ((property == null) || (property.getValue() == null)) ? "" : property.getValue().toString(); try { if (context.getUtil().match(regexp, value)) { return true; } XWikiValidationStatus.addErrorToContext((getObject() == null) ? "" : getObject().getName(), getName(), getTranslatedPrettyName(context), getValidationMessage(), context); return false; } catch (Exception e) { XWikiValidationStatus.addExceptionToContext((getObject() == null) ? "" : getObject().getName(), getName(), e, context); return false; } }
@Override public Object clone() { PropertyClass pclass = (PropertyClass) super.clone(); pclass.setObject(getObject()); pclass.setClassType(getClassType()); return pclass; }
rowColumns.add((value == null) ? " " : value); } else { BaseObject bobj = doc.getObject(pclass.getObject().getName()); rowColumns.add(doc.display(pclass.getName(), "view", bobj, context));
public void displayCustom(StringBuffer buffer, String fieldName, String prefix, String type, BaseObject object, XWikiContext context) throws XWikiException { String content = getCustomDisplay(); try { VelocityContext vcontext = Utils.getComponent(VelocityManager.class).getVelocityContext(); vcontext.put("name", fieldName); vcontext.put("prefix", prefix); vcontext.put("object", new com.xpn.xwiki.api.Object(object, context)); vcontext.put("type", type); vcontext.put("context", new com.xpn.xwiki.api.Context(context)); BaseProperty prop = (BaseProperty) object.safeget(fieldName); if (prop != null) { vcontext.put("value", prop.getValue()); } String classSyntax = context.getWiki().getDocument(getObject().getDocumentReference(), context).getSyntax().toIdString(); content = context.getDoc().getRenderedContent(content, classSyntax, context); } catch (Exception e) { throw new XWikiException(XWikiException.MODULE_XWIKI_CLASSES, XWikiException.ERROR_XWIKI_CLASSES_CANNOT_PREPARE_CUSTOM_DISPLAY, "Exception while preparing the custom display of " + fieldName, e, null); } buffer.append(content); }