[opencms-dev] How to add a relation
Michael Moossen
m.moossen at alkacon.com
Thu Aug 20 16:26:32 CEST 2009
Hi Paul-Inge!
Yes, this is the intented behaviour.
The keyword here is relation type, which can be weak or strong.
"related resources" are strong relations and xmlcontent relations are by
default weak.
for more details see:
http://opencms.org/export/sites/opencms/en/events/opencms_days_2008/slides/T2_MichaelMoossen.pdf
-------------------
Michael Moossen
Alkacon Software GmbH - The OpenCms Experts
http://www.alkacon.com - http://www.opencms.org
Paul-Inge Flakstad schrieb:
> I've gotten no answers on this question, so I'm just posting an update.
>
> I don't get how the CRE is supposed to work. Seems to me that
> it actually doesn't work like it's supposed to(?). I've got a structured
> content type, which is a just a type of general page. It nests
> paragraphs which in turn nests image containers (where you
> can VfsFile-link to the image). Pretty straightforward, nothing special.
>
> If I add a picture to the page, save, and then look at the relations
> using the context menu's "Link relations to/from", I can see the
> relation between the page and the image just fine. So a relation
> has definitively been established.
>
> But when I try to publish the page "with related resources", the system
> apparently fails to recognize the relation, as no image file appears in
> the publish list, only the page itself... WHY? The relation clearly exists!
>
>
> I've tried other approaches to try to force the behaviour I want:
>
> Tried to manually add a relation using a simple .jsp that calls
> addRelationToResource. However, I was only able to add the types
> CATEGORY and OU_RESOURCE. All the other types caused
> IllegalArgumentExceptions. And still, "publish with related resources"
> did not include the image when trying to publish the general page.
>
> Tried to Add the relation in the XSD, but that didn't work either (some
> elements are optional, which caused this approach to produce mostly
> errors when trying to create new general pages).
>
>
> Can anybody shed some light on why the "publish with related resources"
> behaves like this? Is it a configuration issue?
> Also, I would still like to see an example on how to programatically add
> a new relation between two resources (and how to define a new type of
> relation).
>
> Anyone? (Michael Moossen..? :) )
>
>
> All the best,
> Paul
>
> ------------------------------------------------------------------------
> *From:* opencms-dev-bounces at opencms.org
> [mailto:opencms-dev-bounces at opencms.org] *On Behalf Of *Paul-Inge
> Flakstad
> *Sent:* 13. august 2009 20:40
> *To:* opencms-dev at opencms.org
> *Subject:* [opencms-dev] How to add a relation
>
> Hi everyone
>
> I'm trying to programatically add a relation between two resources,
> and things are not going so well.
>
> What I want to do is establish a relation between an xmlcontents
> type resource (structured content) and an image resource, so
> that the image gets published when the xmlcontents file is published
> with related resources. This is actually quite important, because
> many editors forget to publish images, resulting in an error message
> for any user who's not logged in...
>
> I'm putting my code inside a Java class method that creates the
> image (thumbnail) resource. When using the call like this (tried
> other CmsRelationTypes as well, same result):
> cmso.addRelationToResource("/en/index.html",
> "/images/thumbs/image.jpg", CmsRelationType.JSP_WEAK.getName());
>
> I get the following error:
> Error while adding a relation from resource "/en/index.html" to
> resource "/images/thumbs/image.jpg" with type "JSP_WEAK".
>
> Can anyone tell me what I'm doing wrong - and/or show me how it's done?
>
> Cheers,
> Paul
>
>
> ------------------------------------------------------------------------
>
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
More information about the opencms-dev
mailing list