List of usage examples for com.google.gwt.xml.client DOMException DOMException
public DOMException(short code, String message)
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/*from w w w .ja v a2 s. com*/ */ 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("<", "<"); uploadedStudy = uploadedStudy.replaceAll(">", ">"); // 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 w w . j av a 2s .co 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"); } }