There are two methods with which content can be retrieved from an instance of Ephox EditLive! for Java. Retrieval of content may be performed through the JavaScript API GetBody and GetDocument functions at run time or POSTed with a form submit via the JavaScript onsubmit function. EditLive! for Java defaults to that latter of these two behaviors.
By default the content of the EditLive! for Java applet is retrieved when a form is submitted via the JavaScript onsubmit function. Because of the lack of LiveConnect support on various operating systems and browsers, EditLive! for Java 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 Java instance and is given the name that was specified by the developer when the EditLive! for Java instance was created. For example, if ELJApplet1 was specified as the name for the instance of the EditLive! for Java applet then the applet would store its contents in the hidden field named ELJApplet1. This hidden field is then posted with the rest of the form data when the submit button is pressed.
EditLive! for Java 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 Java will not populate the hidden field with data. For this reason, please ensure you use form.onsubmit() to avoid this problem.
By default the content that is retrieved from the EditLive! for Java applet will match the form of the content placed into the applet. Thus, if the applet content is initially set with an entire document then, by default, the entire contents of the applet will be retrieved when the form is submitted. If the applet content is initially set with a HTML fragment then, by default, the contents of the applet between the <BODY> tags will be retrieved. This behavior can be modified through setting the ReturnBodyOnly property for JSP and ASP or the setReturnBodyOnly property for JavaScript.
Through the use of this method the content of the EditLive! for Java applet can only be retrieved when the form, in which the applet is embedded, is submitted to the server. This does not facilitate the retrieval of data from the applet at run time. To perform such tasks the EditLive! for Java JavaScript API functions must be used.
The automatic submission of the content of the EditLive! for Java applet can be disabled through the use of an API setting. By setting either the AutoSubmit property, for ASP and JSP, or the setAutoSubmit property, for JavaScript, to false the automatic content submission can be disabled. It should be noted that by default the automatic submission of content by the applet is enabled.
In order to retrieve or manipulate the contents of the EditLive! for Java applet the EditLive! for Java JavaScript API functions can be used. This discussion will focus on the functions on this API which apply to the retrieval of the applet's contents; GetDocument and GetBody, and also UploadImages. For more information please see the EditLive! for Java JavaScript API Reference.
The GetDocument and GetBody JavaScript functions can be used to retrieve the contents of the EditLive! for Java applet at run time. The GetDocument and GetBody retrieve the entire document or the content between the <BODY> tags respectively. Thus, the content of the applet can be retrieved and stored at anytime using these JavaScript functions.
Both the GetDocument and GetBody JavaScript functions take a string representing the name of the JavaScript function, which receives the retrieved applet contents, as a parameter. The content of the applet is then passed back to the function with the name that was supplied as a parameter.
The UploadImages function uploads any locally stored images within an instance of EditLive! for Java to the relevant Web server. This function uses the image upload script defined in the <httpUploadData> XML element of the EditLive! for Java XML configuration. The UploadImages function should be called before any call to either the GetDocument or GetBody functions. This ensures that all locally stored images are uploaded to the relevant Web server and their URLs are adjusted in the EditLive! for Java HTML source to reflect their location on the Web server.
This example demonstrates how the GetDocument function may be used to retrieve the content of an instance of the EditLive! for Java applet called editlivejava1. Note that this code is in JavaScript and it assumes that an instance of the EditLive! for Java applet called editlivejava1 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 UploadImages function is called prior to calling the GetDocument function. This ensures that the location of images correctly point to the relevant Web server within the EditLive! for Java source.
...
<script language="JavaScript">
<!--
function JSFunctionName(appletContentString){
document.form.formField.value =
appletContentString;
}
-->
</script>
...
editlivejava1.UploadImages();
editlivejava1.GetDocument('JSFunctionName');
...
For a more detailed example of working with this functionality please see the Preview Contents Example in the EditLive! for Java JavaScript API Reference.
The content from the EditLive! for Java applet can be retrieved either upon the submission of the form in which the instance of EditLive! for Java is embedded or through the use of the GetDocument and GetBody JavaScript functions from the EditLive! for Java JavaScript API. To upload locally stored images to the relevant Web server when using either the GetDocument or GetBody JavaScript functions the UploadImages function should be used before calling either the GetDocument or GetBody function. The GetDocument and GetBody JavaScript functions can be used to retrieve the applet contents at run time. Likewise the UploadImages JavaScript function can be used at any time to upload any locally stored images within EditLive! for Java to the relevant Web server.
Copyright © 2001-2004 Ephox Corporation. All Rights Reserved.