There are two methods with which content can be retrieved from an instance of the EditLive! for XML applet:
POSTed as a form field with a form submit via the JavaScript onsubmit function (automatic submission); or
Through the JavaScript API functions at runtime.
By default, EditLive! for XML will bind to the form onsubmit function.
By default the content of the EditLive! for XML applet is retrieved when a form is submitted. Because of the lack of LiveConnect support on various operating systems and browsers, EditLive! for XML populates a hidden field with its contents automatically rather than the developer calling for the contents explicitly.
The name of the hidden field is contained within the same form as the EditLive! for XML instance and is given the name that was specified by the developer when the EditLive! for XML instance was created. For example, if ELApplet1 was specified as the name for the instance of the EditLive! for XML applet then the applet would store its contents in the hidden field named ELApplet1. This hidden field is then posted with the rest of the form data when the submit button is pressed.
The Visual Designer also submits content via the JavaScript onsubmit function. The data model for an instance of the Visual Designer will be submitted in the form field name designer_xsd where designer is the name of the instance of the Visual Designer.
Also submitted by the Visual Designer is a collection of views. Each view is submitted within a separate form field. All the form fields containing views are given the same name, forming a collection in the request object in your application server. The form fields in which the views are submitted are named designer_xslt where designer is the name of the instance of the Visual Designer. The names corresponding to these views are contained within the collection of form fields named designer_viewName. The order of the collection of view names matches that of the views.
EditLive! for XML automatically updates the hidden field by attaching itself to the form's onsubmit() handler. If there is already a function specified in the onsubmit() handler then this function will run after the hidden field has been updated. This means that you can still use the onsubmit() handler to run your own JavaScript functions. If you use another button/image/event to submit the form by calling form.submit() the browser will not call the onsubmit() handler and EditLive! for XML will not populate the hidden field with data. For this reason, please ensure you use form.onsubmit() to avoid this problem.
Through the use of this method the content of the EditLive! for XML applet can only be retrieved when the form in which the applet is embedded and submitted to the server. This does not facilitate the retrieval of data from the applet at runtime. To retreive the content at runtime the EditLive! for XML JavaScript API functions must be used.
In order to retrieve or manipulate the contents of the EditLive! for XML at runtime the GetDocument function from the JavaScript runtime API can be used. For more information on the JavaScript API please see the EditLive! for XML JavaScript API Reference. The GetDocument function retrieves the XML document from EditLive! for XML. This function takes a string representing the name of the JavaScript function, which receives the retrieved XML document, as a parameter. A second, optional parameter which is a boolean can also be used with this function. This second parameter can be used to indicate whether the GetDocument function uploads any images within the source to the Web server and adjusts their URLs accordingly.
This example demonstrates how the GetDocument function may be used to retrieve the content of an instance of the EditLive! for XML applet called editlive. Note that this code is in JavaScript and it assumes that an instance of the EditLive! for XML applet called editlive has already been instantiated within the relevant Web page. Also shown is a JavaScript function called JSFunctionName which is used to set a form field with the content retrieved from the applet.
When the GetDocument function is called then it passes a string corresponding to the contents of the applet back to the function that is named in the parameter of the GetDocument function.
Note that the optional parameter forcing image upload is set to true to ensure any necessary images are uploaded. This ensures that the location of images correctly point to the relevant Web server within the EditLive! for XML source.
...
<script language="JavaScript">
<!--
function JSFunctionName(appletContentString){
document.form.formField.value = appletContentString;
}
-->
</script>
...
editlive.GetDocument('JSFunctionName',true);
...In order to ensure that the output of content in EditLive! for XML XHTML sections is XHTML or XML compliant attributes in the htmlFilter configuration element:
For XHTML compliant output the following filter settings are required:
set outputXHTML to true - this ensures that XHTML tags are used (i.e. <br /> instead of <br>).
set allowUnknownTags to false - this ensures that no tags outside of the XHTML standard are used, i.e. custom tags. Instead, custom tags are HTML encoded.
It is also recommended that encloseText is set to true to ensure that content is correctly nested insides the relevant parent tags.
For XML compliant output the following filter settings are required:
set outputXML to true - this ensures that special characters are encoded as numeric entities and that XML style tags are used (i.e. <br /> instead of <br>).
It is also recommended that encloseText is set to true to ensure that content is correctly nested insides the relevant parent tags.
The content from both the EditLive! for XML and Visual Designer applets can be retrieved upon submission of the form in which the applet is embedded. The XML document content of EditLive! for XML can also be retrieved via the GetDocument function of the JavaScript API.
Copyright 2001-2005 Ephox Corporation. All Rights Reserved.