src/main/java/de/ipb_halle/molecularfaces/component/molplugin/MarvinJSRenderer.java
/**
	 * Encodes the Javascript part of the plugin viewer into the writer.
	 * 
	 * @param context
	 * @param writer
	 * @param plugin
	 * @param divId         DOM id of the &lt;div&gt; element
	 * @param hiddenInputId DOM id of the embedded hidden &lt;input&gt; element
	 */
Encodes the Javascript part of the plugin viewer into the writer.


Encodes the Javascript part of the plugin viewer into the writer .
private void encodeViewerJS(FacesContext context, ResponseWriter writer, MolPluginCore plugin, String divId,
			String hiddenInputId) throws IOException {
		writer.startElement("script", plugin);
		writer.writeAttribute("type", "text/javascript", null);
		String installPath = webXml.getContextParam(MarvinJSComponent.WEBXML_MARVINJS_BASE_URL, context, "");
		StringBuilder sb = new StringBuilder(512 + installPath.length());
		sb.append(plugin.getResourceLoader().encodeLoadExtResources(loaderJSVar));
		Formatter fmt = new Formatter(sb);
		String widgetVar = plugin.getWidgetVar();
		if ((widgetVar != null) && (!widgetVar.isEmpty())) {
			fmt.format("var %s = ", widgetVar);
		}
		/*
		 * Start viewer, set the molecule from the hidden <input> element's value and
		 * return the viewer object embedded in a Promise.
		 */
		fmt.format("%s.status().then(() => {", loaderJSVar);
		fmt.format(
				"return molecularfaces.MarvinJSViewer.newViewer(\"%s\", "
						+ "document.getElementById(\"%s\").getAttribute(\"value\"), \"%s\", %d, %d, \"%s\");",
				divId, hiddenInputId, installPath, plugin.getHeight(), plugin.getWidth(), plugin.getFormat());
		fmt.close();
		sb.append("});");
		writer.writeText(sb, null);
		writer.endElement("script");
	}
private void encodeViewerJS ( FacesContext context , ResponseWriter writer , MolPluginCore plugin , String divId , String hiddenInputId ) throws IOException { writer . startElement ( "script" , plugin ) ; writer . writeAttribute ( "type" , "text/javascript" , null ) ; String installPath = webXml . getContextParam ( MarvinJSComponent . WEBXML_MARVINJS_BASE_URL , context , "" ) ; StringBuilder sb = new StringBuilder ( 512 + installPath . length ( ) ) ; sb . append ( plugin . getResourceLoader ( ) . encodeLoadExtResources ( loaderJSVar ) ) ; Formatter fmt = new Formatter ( sb ) ; String widgetVar = plugin . getWidgetVar ( ) ; if ( ( widgetVar != null ) && ( ! widgetVar . isEmpty ( ) ) ) { fmt . format ( "var %s = " , widgetVar ) ; } /*
		 * Start viewer, set the molecule from the hidden <input> element's value and
		 * return the viewer object embedded in a Promise.
		 */ fmt . format ( "%s.status().then(() => {" , loaderJSVar ) ; fmt . format ( "return molecularfaces.MarvinJSViewer.newViewer(\"%s\", " + "document.getElementById(\"%s\").getAttribute(\"value\"), \"%s\", %d, %d, \"%s\");" , divId , hiddenInputId , installPath , plugin . getHeight ( ) , plugin . getWidth ( ) , plugin . getFormat ( ) ) ; fmt . close ( ) ; sb . append ( "});" ) ; writer . writeText ( sb , null ) ; writer . endElement ( "script" ) ; }
Encodes the Javascript part of the plugin viewer into the writer.
Encodes the Javascript part of the plugin viewer into the writer .
// resource loading // Register a JS variable if required. // end of then()