Example usage for com.google.gwt.xml.client DOMException SYNTAX_ERR

List of usage examples for com.google.gwt.xml.client DOMException SYNTAX_ERR

Introduction

In this page you can find the example usage for com.google.gwt.xml.client DOMException SYNTAX_ERR.

Prototype

short SYNTAX_ERR

To view the source code for com.google.gwt.xml.client DOMException SYNTAX_ERR.

Click Source Link

Usage

From source file:edu.cudenver.bios.glimmpse.client.panels.GlimmpsePanel.java

License:Open Source License

/**
 * Parse the uploaded file to determine whether the user was
 * using matrix or guided mode, then load the appropriate 
 * wizard from the XML document// ww  w . j  a  v a 2  s .  c  om
 */
public void onStudyUpload(String uploadedStudy) {
    if (uploadedStudy != null) {
        try {
            //              // for debug only - removes crap GWT wraps on ajax requests
            //              Window.alert("before ["+uploadedStudy+"]");
            uploadedStudy = uploadedStudy.replaceFirst("<pre>", "");
            uploadedStudy = uploadedStudy.replaceFirst("</pre>", "");
            uploadedStudy = uploadedStudy.replaceAll("&lt;", "<");
            uploadedStudy = uploadedStudy.replaceAll("&gt;", ">");
            //              Window.alert("after ["+uploadedStudy+"]");

            Document doc = XMLParser.parse(uploadedStudy);
            Node studyNode = doc.getElementsByTagName(GlimmpseConstants.TAG_STUDY).item(0);
            if (studyNode == null)
                throw new DOMException(DOMException.SYNTAX_ERR, "no study tag specified");
            Node mode = studyNode.getAttributes().getNamedItem(GlimmpseConstants.ATTR_MODE);
            if (mode != null && GlimmpseConstants.MODE_MATRIX.equals(mode.getNodeValue())) {
                matrixWizardPanel.reset();
                matrixWizardPanel.loadFromXML(doc);
                onMatrixMode();
            } else {
                guidedWizardPanel.reset();
                guidedWizardPanel.loadFromXML(doc);
                onGuidedMode();
            }
        } catch (DOMException e) {
            Window.alert(Glimmpse.constants.errorUploadInvalidStudyFile() + " [" + e.getMessage() + "]");
        }
    } else {
        Window.alert(Glimmpse.constants.errorUploadFailed());
    }
}

From source file:edu.cudenver.bios.powercalculator.client.panels.StartPanel.java

License:Open Source License

public void onSubmitComplete(SubmitCompleteEvent event) {
    String results = event.getResults();
    if (results != null) {
        try {// w  ww  .j a v  a 2 s .  c  o  m
            // make sure we at least have a study tag and model name specified
            Document doc = XMLParser.parse(results);
            Node studyNode = doc.getElementsByTagName("study").item(0);
            if (studyNode == null)
                throw new DOMException(DOMException.SYNTAX_ERR, "no study tag specified");
            Node mode = studyNode.getAttributes().getNamedItem("mode");
            if (mode == null)
                throw new DOMException(DOMException.SYNTAX_ERR, "no model name specified");
            // notify listeners of the file upload
            for (StartListener listener : startListeners)
                listener.onStudyUpload(doc, mode.getNodeValue());
        } catch (DOMException e) {
            Window.alert("Uploaded file does not contain a valid study description [error: " + e.getMessage()
                    + "].  Please try another file.");
        }
    } else {
        Window.alert("Failed to upload file.  Please try again");
    }

}