The PageField is a lot more complex than other fields, as it contains a
reference to a Page. In Jahia a "JahiaPage" object is either :
- a brand new page (DIRECT type)
- an internal link to a Jahia Page (LINK type)
- a remote URL (URL type)
So you must also copy the JahiaPage, which is more complex to do,
especially in the case of a DIRECT type. See the
org.jahia.services.pages API for more details on the operations offered
there. You might also want to look at the
org.jahia.engines.shared.Page_Field engine (although it is very complex).
Regards,
Serge Huber.
Nicolas Lafaury wrote:
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]>