[opencms-dev] Problem for update one field xmlcontent programmatic

Deiverson Silveira deiverson at solutioncms.com
Thu Jun 24 16:13:38 CEST 2010


Hi List,

I have problem then update information 1 field in my xmlcontent, I lost all
information and I dont cant update 1 field only, and preserve all other.

Anyone know how to do this? Update only one field XmlContent without losing
too much?

Thank you,

Deiverson Silveira


The code:

String sName = "test field update";

try{

CmsXmlContentDefinition cd =  CmsXmlContentDefinition.unmarshal(cmsObject,
"/system/modules/my.project/schemas/city.xsd");
CmsXmlContent xmlcontent =
CmsXmlContentFactory.createDocument(cmsObject,locale,org.opencms.main.OpenCms.getSystemInfo().getDefaultEncoding(),cd);

xmlcontent.getValue("Title", Locale.ENGLISH).setStringValue(cmsObject,
String.valueOf(sName));

// Dont work.......... lost information field past =/
xmlcontent.getValue("SubTitle", Locale.ENGLISH).setStringValue(cmsObject,
String.valueOf(xmlcontent.getStringValue(cmsObject,"SubTitle",
Locale.ENGLISH)));
//  I need redefinition all fields again???

byte[] content = xmlcontent.marshal();

String nameFile = "/test.html";

//   cmsObject.writeFile(nameFile ,
org.opencms.main.OpenCms.getResourceManager().getResourceType("cidade").getTypeId(),content,new
ArrayList());
//   cmsObject.createResource("nameFile",
org.opencms.main.OpenCms.getResourceManager().getResourceType("contato").getTypeId(),content,new
ArrayList());

   cmsObject.lockResource(nameFile);
   cmsObject.replaceResource(nameFile,
org.opencms.main.OpenCms.getResourceManager().getResourceType("cidade").getTypeId(),content,new
ArrayList());

   cmsObject.unlockResource(nameFile);
//   cmsObject.publishResource(nameFile);

 }
catch(Exception exc)
{
out.println("Erro: " + exc.getMessage());

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20100624/5c374f8b/attachment.htm>


More information about the opencms-dev mailing list