You are right, the container needs to have been saved for it to have a
corresponding ContentContainer...
To save the container, you have to use the saveContainer method from the
JahiaContainerService instance.
Then, you load back the container using method loadContainer.
I suggest you check out how I implemented the blogs. Look at classes
org.jahia.blogs.actions.AbstractAction and
org.jahia.blogs.actions.NewPostAction. In there, you will find how you can
create a new container, save it, load it and set its categories.
If you still have troubles, don't hesitate to come back to me...
regards
Xavier
Le 14:12 22.07.2005, vous avez écrit:
So I miss something.
Yes you can set automatically your category by this way, but, when you try
to do that with the eventlistener, you can't because you can't create a
contentContainer from "theContainer".
I think this is because "theContainer" ID is 0 (not created at this time)
then the relative contentContainer is null.
Do you have any solution?
Thanks
Nicolas
-----Message d'origine-----
De : Xavier Lawrence [mailto:[EMAIL PROTECTED]
Envoyé : vendredi 22 juillet 2005 09:06
À : [email protected]
Objet : Re: Automatic category selection
Hi Nicolas,
Assuming all your categories have been created through the administration
panel, here is how you progammatically set a category for a container. In
fact, you add the container's ObjectKey to the category object:
final String categoryKey = "myKey";
final Category category = Category.getCategory(categoryKey );
if (category != null) {
cat.addChildObjectKey(theContainer.
getContentContainer().getObjectKey());
}
Regards
Xavier
Le 18:50 21.07.2005, vous avez écrit:
>Hi again
>
>I try to understand how the "document detail" works and how the
>containers have automatically the category.
>In fact I want to set automatically a category to a container but I
>don't know how to do that.
>
>Is anyone has an idea?
>
>Thanks
>
>Nicolas
------------------=[ xlawrence at jahia dot com ]=--------------------
Computer Science Engineer, Master's Degree
Jahia : A collaborative source CMS and Portal Server
www.jahia.org Community and product web site
www.jahia.com Commercial services company
www.collaborativesource.org Jahia's collaborative license
Jahia Solutions
Rue de la gare 45
Ch-1260 Nyon, Switzerland
Phone: +41 22 361 34 24
Fax : +41 22 361 36 40
------------------=[ xlawrence at jahia dot com ]=--------------------
Computer Science Engineer, Master's Degree
Jahia : A collaborative source CMS and Portal Server
www.jahia.org Community and product web site
www.jahia.com Commercial services company
www.collaborativesource.org Jahia's collaborative license
Jahia Solutions
Rue de la gare 45
Ch-1260 Nyon, Switzerland
Phone: +41 22 361 34 24
Fax : +41 22 361 36 40