duplicate a container

"Nicolas Lafaury" <[email protected]>
Newsgroups gmane.comp.cms.jahia.devel
Message-ID <[email protected]>
Hi all
 
I want to copy a container from a containerList to an Archive ContainerList.
 
Here is my code
 
 
              destContainerList.setIsContainersLoaded(false);
              JahiaContainer copiedContainer = new JahiaContainer(0,jParams.getJahiaID(),pageDestinationId,destContainerList.getID(),0,destContainerList.getAclID(),destContainerList.getctndefid(),0,2);
              ServicesRegistry.getInstance().getJahiaContainersService().saveContainerInfo(copiedContainer,destContainerList.getID(), destContainerList.getAclID(),jParams);
 
              copiedContainer.setLanguageCode("fr");
              copiedContainer.fieldsStructureCheck(jParams);
 
              Enumeration monEnum = sourceContainer.getFields();
              FieldsChangeEventListener listener = new FieldsChangeEventListener();
              while(monEnum.hasMoreElements()){
                JahiaField currentField = (JahiaField)monEnum.nextElement();
      if (currentField!=null) {
                String fieldName = currentField.getDefinition().getName();
                Object fieldObject = currentField.getObject();
        if(fieldObject!=null){
                  copiedContainer.getField(fieldName).setObject(sourceContainer.getFieldObject(fieldName));
                }
                }else{
                    copiedContainer.getField(fieldName).setValue(sourceContainer.getField(fieldName).getValue());
                }
                listener.notifyChange(copiedContainer.getField(fieldName).getID());
              }
    }
    destContainerList.addContainer(copiedContainer);
    ServicesRegistry.getInstance().getJahiaContainersService().saveContainer(copiedContainer, destContainerList.getID(),jParams);
 
As you can see, I create a new container in the destination, and I fill every fields.
 
Everything works and I have no exceptions but there is one problem. This is for Field type PageField. No data have been save.
 
Do you have an idea?
 
Thanks
 
Nicolas
 
Nicolas LAFAURY
Ingénieur étude et dévelopement.
Smile- Motoriste Internet
01-41-40-11-05
[email protected] <mailto:[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.