[daisy] Saving Hook for a Part Editor
Michael Hänni
michael.haenni at ergon.ch
Wed Apr 30 17:40:03 CEST 2008
Hello
I have implemented a part editor for the Part Type "SvgData" of the
document type "SVG document". This editor is an applet running inside a
browser.
For the ease of use it should be possible for the user to click on the
"Save" or "Cancle editing (clears lock)" buttons to save or discharge
the edited part of the document. This is how it is done with the
document type "Simple Document".
To meet this requirement I currently take the data from the applet and
write it to a hidden field of the document. This hidden field then gets
stored on the server side.
What could be a good presave hook for writing the changes of the applet
in the "SVG document"?
Currently I'm doing this at the end of the function preSubmitChecks() of
the file DaisyHome\daisywiki\webapp\daisy\resources\xml\documenteditor.xml.
This works fine, but is more a hack than a solution, as the code is
executed for every document type, not just for a document containing a
"SvgData" part.
Has anyone an idea?
Thanks
Here are some code fragments
this is the hidden field which gets saved by pressing the "save" button:
<ft:widget id="plaintext">
<fi:styling type="textarea" style="display:none"/>
</ft:widget>
(File:
\DaisyHome\daisywiki\webapp\daisy\resources\form\parteditor_test_template.xml)
here the document gets the edited data:
<script type="text/javascript">
function preSubmitChecks() {
<jx:if test="${document.isNew()}">
if (document.forms["editdoc"].name.value == "<i18n:text
key="editdoc.new-document-name"/>") {
return confirm("<i18n:text key="editdoc.name-warning"/>");
}
</jx:if>
if (document.getElementById("plaintext:input") !=
null){ //my code
document.getElementById("plaintext:input").value =
editorApplet.getData(); //my code
}
//my code
return true;
}
</script>
(File: DaisyHome\daisywiki\webapp\daisy\resources\xml\documenteditor.xml)
More information about the daisy
mailing list