Storing the container after a page move would be dirty, as it is not said that the user will really save the new container. He still may cancel.
But meanwhile I could solve the whole issue as I found out how to get access to the JahiaContentContainerFacade out of the event-listener. Don't know, why I haven't seen that earlier.
Map engineMap =
(HashMap)jParams.getSession().getAttribute(
"jahia_session_engineMap");
JahiaContentContainerFacade jahiaContentContainerFacade =
(JahiaContentContainerFacade)engineMap.get(
"UpdateContainer_Engine.JahiaContentContainerFacade");
Now I am moving the fields from the source-container to the target-container, which is behind the JahiaContentContainerFacade. For now, the testing works fine. I hope there will be no unforseen side-effects.
Thanks and greetings,
Benjamin Papez
Serge Huber <[EMAIL PROTECTED]> wrote on 18.10.2004 14:51:19:
>
> Try saving the container twice, once just after the creation of the
> JahiaContainer, and then set the field values, and save it again. The
> first save usually creates the fields.
>
> Regards,
> Serge Huber.
>
> [EMAIL PROTECTED] wrote:
>
> >
> > That way I unfortunately get an exception:
> > org.jahia.exceptions.JahiaException: Field -2 not found in database!
> >
> > I believe it's because the target container is new and has not been
> > saved yet. It exists only in memory, which is accessed via the
> > JahiaContentContainerFacade. Is there another trick?
> >
> > Thanks,
> > Benjamin Papez
> >
> > Serge Huber <[EMAIL PROTECTED]> wrote on 12.10.2004 14:48:23:
> >
> > >
> > > Hi Benjamin,
> > >
> > > Well you could try to retrieve the ContentField this way :
> > >
> > > ContentField contentField = ContentField.getField(jField.getID());
> > >
> > > Regards,
> > > Serge Huber.
> > >
> > > [EMAIL PROTECTED] wrote:
> > >
> > > >
> > > > Hello Serge,
> > > >
> > > > It indeed is complicated. At least I am able to get the values for
> > all
> > > > languages in the source (to be moved) container. The problem is
> > how to
> > > > place them into the current target container (which is in the process
> > > > of being created).
> > > >
> > > > My code, which moves all container fields along with the moved page,
> > > > is in an event listener in the addContainerEngineAfterInit event
> > > > (similar to the eventlistener.jsp in the corporate_portal_templates).
> > > >
> > > > If I call
> > > > jField = targetContainer.getField(fieldName)
> > > > I can get the field of the current container and can set the value
> > > > just for the current language.
> > > >
> > > > If I call
> > > > jField.getContentField()
> > > > on that variable I get null, so I cannot access the content objects
> > > > for all the different languages. How else could I save a field in all
> > > > the different languages within my event-listener? Do I have access to
> > > > the JahiaContentContainerFacade? The values of course should not be
> > > > persisted right ahead, but only when the user presses OK or "Save and
> > > > new".
> > > >
> > > > Greetings,
> > > > Benjamin Papez
> > > >
> > > > Serge Huber <[EMAIL PROTECTED]> wrote on 23.09.2004 15:24:44:
> > > >
> > > > >
> > > > > Hi Benjamin,
> > > > >
> > > > > That is more complex, because in the context of a page you only have
> > > > > access to the current requested language data. You might try
> > something
> > > > > with the ContentObject hierarchy but again this is not trivial to
> > > > > achieve. As for copying file field data it depends if you really
> > > > want to
> > > > > copy the content of the file or just the field. If it's just the
> > > > field a
> > > > > simple get/setValue should work.
> > > > >
> > > > > Regards,
> > > > > Serge Huber.
> > > > >
> > > > > [EMAIL PROTECTED] wrote:
> > > > >
> > > > > > Thank you very much. I have looked, what you have done in the
> > > > > > eventlistener.jsp and it works for us. Still we have a problem to
> > > > copy
> > > > > > not only the current value of a field like in your example, but we
> > > > > > would like to move the text for ALL languages of a field and I we
> > > > > > would also like to move complex fields like file-fields. How can
> > > > we do
> > > > > > that?
> > > > > >
> > > > > > Regards,
> > > > > > Benjamin Papez
> > > > > >
> > > > > >
> > > > > > -----St�phane Croisier <[EMAIL PROTECTED]> wrote: -----
> > > > > >
> > > > > > >To:
> > > > > > >From: St�phane Croisier
> > > > > > >Date: 09/15/2004 04:39PM
> > > > > > >Subject: Re: Moving container, when page is moved
> > > > > > >
> > > > > > >
> > > > > > >Hello,
> > > > > > >
> > > > > > >When you move a page, you move the page field alone not the full
> > > > > > >parent container (because the destination container may be
> > different
> > > > > > >from the original source container). But if you know the
> > destination,
> > > > > > >you may create an event listenrer to copy the values of the
> > parent
> > > > > > >container into the new destination container. Please take a
> > look a
> > > > > > >the the "document_listing" template which includes such a
> > mechanism.
> > > > > > >
> > > > > > >
> > > > > > >Cheers,
> > > > > > >St�phane
> > > > > > >
> > > > > > >At 12:40 15/09/2004, you wrote:
> > > > > > >
> > > > > > >
> > > > > > >We have container lists holding category containers and service
> > > > > > >containers. Both containers hold a page and some additional
> > fields
> > > > > > >belonging to categories or services. Now the page_field would
> > allow
> > > > > > >for linking to pages and moving pages around. Unfortunately
> > only the
> > > > > > >page is moved and not the additional fields of the container.
> > > > > > >
> > > > > > >Do you have a suggestion or idea how we could also move the other
> > > > > > >fields of the container, when the page is moved?
> > > > > > >
> > > > > > >Regards,
> > > > > > >Benjamin Papez
> > > > >
> > > > >
> > >
> > >
>
>
- Moving container, when page is moved Benjamin . Papez
- Re: Moving container, when page is moved St�phane Croisier
- Re: Moving container, when page is moved Benjamin . Papez
- Re: Moving container, when page is moved Serge Huber
- Re: Moving container, when page is moved Benjamin . Papez
- Re: Moving container, when page is move... Serge Huber
- Re: Moving container, when page is... Benjamin . Papez
- Re: Moving container, when pag... Serge Huber
- Benjamin . Papez
