[opencms-dev] How to write into Frontend User-Forms?
Nacho Fernández Orellana
nacho.fernandez.orellana at gmail.com
Mon Jun 15 13:53:11 CEST 2009
Hi Frank and list,
Your frontend-form built using contentload and contentshow should build a
html form whose data will be sent to a certain target page (of course this
page can be the same jsp page that built the form). In any case, the
destination jsp should get the sent parameters and then use them to build
the xml of the phonebook entry.
I recommend programming a simple java bean that has all the elements your
phonebook entry has as fields and that provides a simple "toXml" method that
builds the right xml of a phonebook entry according to your xsd. That way
you could create a java method called something like "writePhonebookEntry"
that does something like:
PhonebookEntryBean bean = getBeanFromRequestParameters( request
); <-- method to write
CmsFile file = cms.readFile( PATH_OF_XML_YOU_ARE_EDITING );
file.setContents( YOUR_BEAN.toXml().getBytes() );
cms.writeFile( file );
Where "cms" is a CmsObject and you have to be in the offline project and
lock the xml file accordingly.
I've always found this to be the simpler way, other method is editing the
xml contents for the modified fields in your form instead of rewriting the
complete well-formed xml. If you need code snippets for that alternative
approach, ask again. Hope this helps. Greetings,
Nacho Fernandez.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20090615/de7f7ace/attachment.htm>
More information about the opencms-dev
mailing list