Re: "Official" API to create programatically a field ?
Serge Huber <[email protected]>
| Newsgroups | gmane.comp.cms.jahia.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Sébastien,
These APIs haven't been completed so they probably have bugs (as you
have noticed).
The real problem is that you have to know how the Jahia object model
works before attempting to manipulation the content creation APIs,
otherwise you risk severly corrupting the database. I suggest you start
by reading the introduction to the content model in the template
developer guide draft.
Then you need to decide whether you want to import into fields directly
attached to a page or into containers. The most common case is inputting
into containers. So this means you need to create a container dynamically.
We are working on implementing Blogging APIs that could also help import
content, but will also serve as examples as to how to insert content
through the API.
Regards,
Serge Huber.
Sébastien Landeau wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
>
>
> i am writing a tool to import some content in an empty site and i have
> to create fields of various types dynamically from jahia API.
>
> Some research on the mailing list point me out the static methods of the
> subclass of class 'org.jahia.services.fields.ContentField'.
> Everithing works fine with :
> ~ - ContentPageField.createNewPage(...) for creating direct page fields
> ~ - ContentSmallTextField.createSmallText(..) for creating smalltext
> fields
>
> but methods for some other types failed due to the field type miscoded
> inside the static method.
> The exemple below stands for Float field and is ripped from class
> 'org.jahia.services.fields.ContentFloatField' ::
>
>
> //--------------------------------------------------------------------------
>
> public static synchronized ContentFloatField
> ~ createFloat (int siteID, int pageID, int containerID,
> ~ int fieldDefID, int parentAclID, int aclID,
> ~ float value, ParamBean jParams)
> ~ throws JahiaException
> {
> ~ ContentFloatField result = (ContentFloatField)
> ~ ContentField.createField (
> ~ siteID, pageID, containerID,fieldDefID,
> ~ ContentFieldTypes.BOOLEAN, <------- IS THIS NORMAL ??????
> ~ ConnectionTypes.LOCAL, parentAclID,aclID);
>
> ~ EntrySaveRequest saveRequest = new EntrySaveRequest(
> ~ jParams.getUser (),ContentField.SHARED_LANGUAGE);
>
> ~ result.setFloat (value, saveRequest);
> ~ return result;
> ~ }
>
>
> The same problem show up at least for :
> ~ - ContentPageField.createPageLink(...)
> ~ - ContentPageField.createRemoteURL(...)
> ~ - ContentDateField.createDate(...)
>
>
> Am i using the right API ? If not (this one should be deprecated) which
> API can i use ?
>
> thanks in advance
>
> Emmanuel
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (MingW32)
> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
>
> iD8DBQFCQobgPYMbxu29ktsRAtn0AKCFfJEOLitWevlAk0A4gp+VuZB3kwCff4i+
> +06qGL5x2BnCM2vpn7LheJQ=
> =mSUK
> -----END PGP SIGNATURE-----
>