Search in sources :

Example 1 with ObjectAddForm

use of com.xpn.xwiki.web.ObjectAddForm in project xwiki-platform by xwiki.

the class XWikiDocument method addXObjectFromRequest.

/**
 * Adds an object from an new object creation form.
 *
 * @since 2.2M2
 */
public BaseObject addXObjectFromRequest(XWikiContext context) throws XWikiException {
    // Read info in object
    ObjectAddForm form = new ObjectAddForm();
    form.setRequest(context.getRequest());
    form.readRequest();
    EntityReference classReference = getXClassEntityReferenceResolver().resolve(form.getClassName(), EntityType.DOCUMENT, getDocumentReference());
    BaseObject object = newXObject(classReference, context);
    BaseClass baseclass = object.getXClass(context);
    baseclass.fromMap(form.getObject(LOCAL_REFERENCE_SERIALIZER.serialize(resolveClassReference(classReference))), object);
    return object;
}
Also used : ObjectAddForm(com.xpn.xwiki.web.ObjectAddForm) EntityReference(org.xwiki.model.reference.EntityReference) BaseClass(com.xpn.xwiki.objects.classes.BaseClass) BaseObject(com.xpn.xwiki.objects.BaseObject)

Aggregations

BaseObject (com.xpn.xwiki.objects.BaseObject)1 BaseClass (com.xpn.xwiki.objects.classes.BaseClass)1 ObjectAddForm (com.xpn.xwiki.web.ObjectAddForm)1 EntityReference (org.xwiki.model.reference.EntityReference)1