[opencms-dev] [Fwd: Re: Antwort: Re: Antwort: Re: How to write into Frontend User-Forms?]
Mathias Lin
mail at mathiaslin.com
Tue Jun 16 12:31:56 CEST 2009
Hi Frank,
the UUID of the offline project might differ on your system. You can
find out the Id in the source code of the workplace toolbar or look it
up in the database / project table.
Not sure if there's a constant for the offline project/UUID as there is
for the online project (CmsProject.ONLINE_PROJECT_ID), so I use this
approach with the UUID directly.
> Do you mean by offline-project the directory "/sites" or the
directory "/sites/default" as offline-project?
No, I don't mean the site root/path, I mean the project that you can
select on the left-hand side side of the toolbar while you're in the
workplace.
Frank Pertack wrote:
>
> Hi Mathias,
>
> I tried your proposal, but I am sorry to say that I get an error
> message, rporting it can not find the offline project.
> It says:
>
>
>
> org.opencms.db.CmsDbEntryNotFoundException: Error reading the project
> with the name "1414a86d-32ae-11de-8a4e-00215c43848d".
> Reason: Error reading the project with the name
> "1414a86d-32ae-11de-8a4e-00215c43848d".
> Reason: Project with name "1414a86d-32ae-11de-8a4e-00215c43848d" not
> found.
>
>
> Do you mean by offline-project the directory "/sites" or the directory
> "/sites/default" as offline-project? It doesn't work for either one.
>
> Please help me.
>
> Thank you very much, best regards
>
>
> Frank Pertack
>
>
> Vater Solution GmbH
> Liebigstraße 26
> 24145 Kiel
>
> Telefon: +49 431 20084-210
> Telefax: +49 431 20084-222
> Mobil: +49 151 16353519
> mailto: fpertack at vater-gruppe.de
> http://www.vater-gruppe.de
>
> Amtsgericht Kiel, HRB 6403
> Geschäftsführer:
> Klaus-Hinrich Vater
> Michael Wiese
> -----
> Diese Email enthält ggfs. vertrauliche und/oder rechtlich geschützte
> Informationen. Wenn Sie nicht der richtige Adressat sind oder diese
> Email irrtümlich erhalten haben, informieren Sie bitte sofort den
> Absender und vernichten Sie diese Email. Das unerlaubte Kopieren sowie
> die unbefugte Weitergabe dieser Email sind nicht gestattet.
>
>
> Inactive hide details for Mathias Lin ---15.06.2009 17:20:30---Hi
> Frank, the html form is probably a jsp template and it does nMathias
> Lin ---15.06.2009 17:20:30---Hi Frank, the html form is probably a jsp
> template and it does not contain any
>
>
> Von:
> Mathias Lin <mail at mathiaslin.com>
>
> An:
> The OpenCms mailing list <opencms-dev at opencms.org>
>
> Datum:
> 15.06.2009 17:20
>
> Betreff:
> Re: [opencms-dev] Antwort: Re: How to write into Frontend User-Forms?
>
> Gesendet von:
> opencms-dev-bounces at opencms.org
>
> ------------------------------------------------------------------------
>
>
>
> Hi Frank,
>
> the html form is probably a jsp template and it does not contain any
> data of your phone book entry (maybe your phonebook entry elements are
> just making use of this template to display the data together with the
> input form to allow the user to change the data, but I don't know how
> you configured your xsd/content type here).
> Your phonebook entry elements are files that contain the actual data,
> and it's xml structure is defined by your phoneBookEntry.xsd.
>
>
> Below is a code snippet:
>
>
> Locale locale = Locale.GERMAN;
> String dataDir = "path/to/phonebook/_data/";
> String filename = "/" + dataDir + "entry." +
> Calendar.getInstance().getTimeInMillis() + ".html"; // or use any other
> logic to create the file name
>
> CmsObject cmsObject =
> OpenCms.initCmsObject(OpenCms.getDefaultUsers().getUserGuest());
> cmsObject.loginUser("AdminOrOtherUserWithWorkplacePermission",
> "HisPassword");
> cmsObject.getRequestContext().setSiteRoot(OpenCms.getSiteManager().getDefaultSite().getSiteRoot());
> cmsObject.getRequestContext().setCurrentProject(cmsObject.readProject("942c4f84-e610-11dd-8e8a-85b622eae7ae")
>
> ); // <-- needs to be UUID of the offline project
>
> CmsResource document = cmsObject.createResource(filename , 1011); //
> <--- 1011 just an example, this id the ID of your phonebook-entry.xsd
> (as of opencms-modules.xml)
> CmsXmlContent xmlContent = CmsXmlContentFactory.unmarshal(cmsObject,
> document, request);
> xmlContent.getValue("Title", locale,0).setStringValue(cmsObject,
> request.getParameter("title")) ; // depending on your form
> validation, you might need to check for NULL values here
> xmlContent.getValue("FirstName", locale,0).setStringValue(cmsObject,
> request.getParameter("firstName"));
> xmlContent.getValue("LastName", locale,0).setStringValue(cmsObject,
> request.getParameter("lastName"));
> // ...
>
> xmlContent.getFile().setContents(xmlContent.marshal());
> cmsObject.writeFile(xmlContent.getFile());
> cmsObject.unlockResource("/" + dataDir + document.getName());
>
>
> Regards,
> Mathias
>
>
> Frank Pertack wrote:
> >
> > thank you for your expeditious answer. But I thought, the html form,
> > that is built by the contentload, contains the xml-Data in its
> > controlcode. Is there a seperate xml-file, that stores the data of the
> > controlcode, and if yes, what is the name of that xml-file?
> >
> > And I would like to accept your offer and take the alternative code
> > snippets. Mightbe I get a better understanding of the problem.
> >
> > Meanwhile I try your proposal with a smaller file.
> >
> > Thank you very much
> >
> > Best regards
> >
> >
> >
> > Inactive hide details for Nacho Fernández Orellana ---15.06.2009
> > 13:53:25---Hi Frank and list, Your frontend-form built using cNacho
> > Fernández Orellana ---15.06.2009 13:53:25---Hi Frank and list, Your
> > frontend-form built using contentload and contentshow should build a
> >
> >
> > Von:
> > Nacho Fernández Orellana <nacho.fernandez.orellana at gmail.com>
> >
> > An:
> > The OpenCms mailing list <opencms-dev at opencms.org>
> >
> > Datum:
> > 15.06.2009 13:53
> >
> > Betreff:
> > Re: [opencms-dev] How to write into Frontend User-Forms?
> >
> > Gesendet von:
> > opencms-dev-bounces at opencms.org
> >
> > ------------------------------------------------------------------------
> >
> >
> >
> > 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.
> > _______________________________________________
> > This mail is sent to you from the opencms-dev mailing list
> > To change your list options, or to unsubscribe from the list, please
> visit
> > http://lists.opencms.org/mailman/listinfo/opencms-dev
> >
> >
> > Frank Pertack
> >
> >
> > Vater Solution GmbH
> > Liebigstraße 26
> > 24145 Kiel
> >
> > Telefon: +49 431 20084-210
> > Telefax: +49 431 20084-222
> > Mobil: +49 151 16353519
> > mailto: fpertack at vater-gruppe.de
> > http://www.vater-gruppe.de
> >
> > Amtsgericht Kiel, HRB 6403
> > Geschäftsführer:
> > Klaus-Hinrich Vater
> > Michael Wiese
> > -----
> > Diese Email enthält ggfs. vertrauliche und/oder rechtlich geschützte
> > Informationen. Wenn Sie nicht der richtige Adressat sind oder diese
> > Email irrtümlich erhalten haben, informieren Sie bitte sofort den
> > Absender und vernichten Sie diese Email. Das unerlaubte Kopieren sowie
> > die unbefugte Weitergabe dieser Email sind nicht gestattet.
> > ------------------------------------------------------------------------
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20090616/2c2c1391/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 61305 bytes
Desc: not available
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20090616/2c2c1391/attachment.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 105 bytes
Desc: not available
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20090616/2c2c1391/attachment-0001.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 45 bytes
Desc: not available
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20090616/2c2c1391/attachment-0002.gif>
More information about the opencms-dev
mailing list