<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
Hi Frank,<br>
<br>
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.<br>
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.<br>
<br>
> Do you mean by offline-project the directory "/sites" or the
directory "/sites/default" as offline-project? <br>
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.<br>
<br>
<img src="cid:part1.06070703.06080203@mathiaslin.com" alt=""><br>
<br>
Frank Pertack wrote:
<blockquote
 cite="mid:OFFA4EF083.1C73528E-ONC12575D7.003734CA-C12575D7.0037BD2C@vater-gruppe.de"
 type="cite">
  <p>Hi Mathias,<br>
  <br>
I tried your proposal, but I am sorry to say that I get an error
message, rporting it can not find the offline project.<br>
It says:<br>
  <br>
  <table border="1">
    <tbody>
      <tr valign="top">
        <td valign="middle" width="789"><font size="1"><br>
        </font>
        <table border="1">
          <tbody>
            <tr valign="top">
              <td valign="middle" width="785"><font size="1"><br>
              </font>
              <table border="0" cellpadding="0" cellspacing="0">
                <tbody>
                  <tr valign="top">
                    <td valign="middle" width="770"><font face="Verdana"
 size="2">org.opencms.db.CmsDbEntryNotFoundException: Error reading the
project with the name "1414a86d-32ae-11de-8a4e-00215c43848d".<br>
Reason: Error reading the project with the name
"1414a86d-32ae-11de-8a4e-00215c43848d".<br>
Reason: Project with name "1414a86d-32ae-11de-8a4e-00215c43848d" not
found. </font></td>
                  </tr>
                </tbody>
              </table>
              </td>
            </tr>
          </tbody>
        </table>
        </td>
      </tr>
    </tbody>
  </table>
  <br>
Do you mean by offline-project the directory "/sites" or the directory
"/sites/default" as offline-project? It doesn't work for either one.<br>
  <br>
Please help me.<br>
  <br>
Thank you very much, best regards<br>
  <br>
  <br>
Frank Pertack<br>
  <br>
  <br>
Vater Solution GmbH<br>
Liebigstraße 26<br>
24145 Kiel<br>
  <br>
Telefon: +49 431 20084-210<br>
Telefax: +49 431 20084-222<br>
Mobil: +49 151 16353519<br>
mailto: <a moz-do-not-send="true" class="moz-txt-link-abbreviated"
 href="mailto:fpertack@vater-gruppe.de">fpertack@vater-gruppe.de</a><br>
  <a moz-do-not-send="true" href="http://www.vater-gruppe.de">http://www.vater-gruppe.de</a><br>
  <br>
Amtsgericht Kiel, HRB 6403 <br>
Geschäftsführer:<br>
Klaus-Hinrich Vater<br>
Michael Wiese<br>
-----<br>
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.<br>
  <br>
  <br>
  <img src="cid:part2.05010406.03000507@mathiaslin.com"
 alt="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 n"
 border="0" height="16" width="16"><font color="#424282">Mathias Lin
---15.06.2009 17:20:30---Hi Frank, the html form is probably a jsp
template and it does not contain any</font><br>
  <br>
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tbody>
      <tr valign="top">
        <td width="1%"><img
 src="cid:part3.01040000.04040803@mathiaslin.com" alt="" border="0"
 height="1" width="96"><br>
        <font color="#5f5f5f" size="2">Von:</font></td>
        <td width="100%"><img
 src="cid:part3.01040000.04040803@mathiaslin.com" alt="" border="0"
 height="1" width="1"><br>
        <font size="2">Mathias Lin <a moz-do-not-send="true"
 class="moz-txt-link-rfc2396E" href="mailto:mail@mathiaslin.com"><mail@mathiaslin.com></a></font></td>
      </tr>
      <tr valign="top">
        <td width="1%"><img
 src="cid:part3.01040000.04040803@mathiaslin.com" alt="" border="0"
 height="1" width="96"><br>
        <font color="#5f5f5f" size="2">An:</font></td>
        <td width="100%"><img
 src="cid:part3.01040000.04040803@mathiaslin.com" alt="" border="0"
 height="1" width="1"><br>
        <font size="2">The OpenCms mailing list
        <a moz-do-not-send="true" class="moz-txt-link-rfc2396E"
 href="mailto:opencms-dev@opencms.org"><opencms-dev@opencms.org></a></font></td>
      </tr>
      <tr valign="top">
        <td width="1%"><img
 src="cid:part3.01040000.04040803@mathiaslin.com" alt="" border="0"
 height="1" width="96"><br>
        <font color="#5f5f5f" size="2">Datum:</font></td>
        <td width="100%"><img
 src="cid:part3.01040000.04040803@mathiaslin.com" alt="" border="0"
 height="1" width="1"><br>
        <font size="2">15.06.2009 17:20</font></td>
      </tr>
      <tr valign="top">
        <td width="1%"><img
 src="cid:part3.01040000.04040803@mathiaslin.com" alt="" border="0"
 height="1" width="96"><br>
        <font color="#5f5f5f" size="2">Betreff:</font></td>
        <td width="100%"><img
 src="cid:part3.01040000.04040803@mathiaslin.com" alt="" border="0"
 height="1" width="1"><br>
        <font size="2">Re: [opencms-dev] Antwort: Re: How to write into
Frontend User-Forms?</font></td>
      </tr>
      <tr valign="top">
        <td width="1%"><img
 src="cid:part3.01040000.04040803@mathiaslin.com" alt="" border="0"
 height="1" width="96"><br>
        <font color="#5f5f5f" size="2">Gesendet von:</font></td>
        <td width="100%"><img
 src="cid:part3.01040000.04040803@mathiaslin.com" alt="" border="0"
 height="1" width="1"><br>
        <font size="2"><a moz-do-not-send="true"
 class="moz-txt-link-abbreviated"
 href="mailto:opencms-dev-bounces@opencms.org">opencms-dev-bounces@opencms.org</a></font></td>
      </tr>
    </tbody>
  </table>
  </p>
  <hr style="color: rgb(128, 145, 165);" align="left" noshade="noshade"
 size="2" width="100%"><br>
  <br>
  <br>
  <tt>Hi Frank,<br>
  <br>
the html form is probably a jsp template and it does not contain any <br>
data of your phone book entry (maybe your phonebook entry elements are <br>
just making use of this template to display the data together with the <br>
input form to allow the user to change the data, but I don't know how <br>
you configured your xsd/content type here).<br>
Your phonebook entry elements are files that contain the actual data, <br>
and it's xml structure is defined by your phoneBookEntry.xsd.<br>
  <br>
  <br>
Below is a code snippet:<br>
  <br>
  <br>
Locale locale = Locale.GERMAN;<br>
String dataDir = "path/to/phonebook/_data/";<br>
String filename = "/" + dataDir + "entry." + <br>
Calendar.getInstance().getTimeInMillis() + ".html"; // or use any other
  <br>
logic to create the file name<br>
  <br>
CmsObject cmsObject = <br>
OpenCms.initCmsObject(OpenCms.getDefaultUsers().getUserGuest());<br>
cmsObject.loginUser("AdminOrOtherUserWithWorkplacePermission", <br>
"HisPassword");<br>
cmsObject.getRequestContext().setSiteRoot(OpenCms.getSiteManager().getDefaultSite().getSiteRoot());<br>
cmsObject.getRequestContext().setCurrentProject(cmsObject.readProject("942c4f84-e610-11dd-8e8a-85b622eae7ae")
  <br>
);  // <-- needs to be UUID of the offline project<br>
  <br>
CmsResource document = cmsObject.createResource(filename , 1011);   // <br>
<--- 1011 just an example, this id the ID of your
phonebook-entry.xsd <br>
(as of opencms-modules.xml)<br>
CmsXmlContent xmlContent = CmsXmlContentFactory.unmarshal(cmsObject, <br>
document, request);      <br>
xmlContent.getValue("Title", locale,0).setStringValue(cmsObject, <br>
request.getParameter("title")) ;     // depending on your form <br>
validation, you might need to check for NULL values here<br>
xmlContent.getValue("FirstName", locale,0).setStringValue(cmsObject, <br>
request.getParameter("firstName"));<br>
xmlContent.getValue("LastName", locale,0).setStringValue(cmsObject, <br>
request.getParameter("lastName"));<br>
// ...<br>
  <br>
xmlContent.getFile().setContents(xmlContent.marshal());<br>
cmsObject.writeFile(xmlContent.getFile());<br>
cmsObject.unlockResource("/" + dataDir + document.getName());<br>
  <br>
  <br>
Regards,<br>
Mathias<br>
  <br>
  <br>
Frank Pertack wrote:<br>
><br>
> thank you for your expeditious answer. But I thought, the html
form, <br>
> that is built by the contentload, contains the xml-Data in its <br>
> controlcode. Is there a seperate xml-file, that stores the data of
the <br>
> controlcode, and if yes, what is the name of that xml-file?<br>
><br>
> And I would like to accept your offer and take the alternative
code <br>
> snippets. Mightbe I get a better understanding of the problem.<br>
><br>
> Meanwhile I try your proposal with a smaller file.<br>
><br>
> Thank you very much<br>
><br>
> Best regards<br>
><br>
><br>
><br>
> Inactive hide details for Nacho Fernández Orellana ---15.06.2009 <br>
> 13:53:25---Hi Frank and list, Your frontend-form built using
cNacho <br>
> Fernández Orellana ---15.06.2009 13:53:25---Hi Frank and list,
Your <br>
> frontend-form built using contentload and contentshow should build
a<br>
><br>
><br>
> Von: <br>
> Nacho Fernández Orellana <a moz-do-not-send="true"
 class="moz-txt-link-rfc2396E"
 href="mailto:nacho.fernandez.orellana@gmail.com"><nacho.fernandez.orellana@gmail.com></a><br>
><br>
> An: <br>
> The OpenCms mailing list <a moz-do-not-send="true"
 class="moz-txt-link-rfc2396E" href="mailto:opencms-dev@opencms.org"><opencms-dev@opencms.org></a><br>
><br>
> Datum: <br>
> 15.06.2009 13:53<br>
><br>
> Betreff: <br>
> Re: [opencms-dev] How to write into Frontend User-Forms?<br>
><br>
> Gesendet von: <br>
> <a moz-do-not-send="true" class="moz-txt-link-abbreviated"
 href="mailto:opencms-dev-bounces@opencms.org">opencms-dev-bounces@opencms.org</a><br>
><br>
>
------------------------------------------------------------------------<br>
><br>
><br>
><br>
> Hi Frank and list,<br>
><br>
> Your frontend-form built using contentload and contentshow should <br>
> build a html form whose data will be sent to a certain target page
(of <br>
> course this page can be the same jsp page that built the form). In
any <br>
> case, the destination jsp should get the sent parameters and then
use <br>
> them to build the xml of the phonebook entry.<br>
><br>
> I recommend programming a simple java bean that has all the
elements <br>
> your phonebook entry has as fields and that provides a simple
"toXml" <br>
> method that builds the right xml of a phonebook entry according to
  <br>
> your xsd. That way you could create a java method called something
  <br>
> like "writePhonebookEntry" that does something like:<br>
><br>
>             PhonebookEntryBean bean =
getBeanFromRequestParameters( <br>
> request ); <-- method to write<br>
>             CmsFile file = cms.readFile(
PATH_OF_XML_YOU_ARE_EDITING );<br>
>             file.setContents( YOUR_BEAN.toXml().getBytes() );<br>
>             cms.writeFile( file );<br>
><br>
> Where "cms" is a CmsObject and you have to be in the offline
project <br>
> and lock the xml file accordingly.<br>
> I've always found this to be the simpler way, other method is
editing <br>
> the xml contents for the modified fields in your form instead of <br>
> rewriting the complete well-formed xml. If you need code snippets
for <br>
> that alternative approach, ask again. Hope this helps. Greetings,<br>
><br>
> Nacho Fernandez.<br>
> _______________________________________________<br>
> This mail is sent to you from the opencms-dev mailing list<br>
> To change your list options, or to unsubscribe from the list,
please visit<br>
> </tt><tt><a moz-do-not-send="true"
 href="http://lists.opencms.org/mailman/listinfo/opencms-dev">http://lists.opencms.org/mailman/listinfo/opencms-dev</a></tt><tt><br>
><br>
><br>
> Frank Pertack<br>
><br>
><br>
> Vater Solution GmbH<br>
> Liebigstraße 26<br>
> 24145 Kiel<br>
><br>
> Telefon: +49 431 20084-210<br>
> Telefax: +49 431 20084-222<br>
> Mobil: +49 151 16353519<br>
> mailto: <a moz-do-not-send="true" class="moz-txt-link-abbreviated"
 href="mailto:fpertack@vater-gruppe.de">fpertack@vater-gruppe.de</a><br>
> </tt><tt><a moz-do-not-send="true"
 href="http://www.vater-gruppe.de">http://www.vater-gruppe.de</a></tt><tt><br>
><br>
> Amtsgericht Kiel, HRB 6403<br>
> Geschäftsführer:<br>
> Klaus-Hinrich Vater<br>
> Michael Wiese<br>
> -----<br>
> Diese Email enthält ggfs. vertrauliche und/oder rechtlich
geschützte <br>
> Informationen. Wenn Sie nicht der richtige Adressat sind oder
diese <br>
> Email irrtümlich erhalten haben, informieren Sie bitte sofort den <br>
> Absender und vernichten Sie diese Email. Das unerlaubte Kopieren
sowie <br>
> die unbefugte Weitergabe dieser Email sind nicht gestattet.<br>
>
------------------------------------------------------------------------<br>
><br>
>   <br>
  <br>
  </tt></blockquote>
<br>
<br>
</body>
</html>