/** Creates a {@link ZScriptInfo} with the content directly. * * @param zslang the scripting language. If null, it is the same as * {@link Page#getZScriptLanguage}. * @param content the zscript content */ public ZScriptInfo(NodeInfo parent, String zslang, String content, ConditionImpl cond) { super(parent, cond); _zs = new ZScript(zslang, content); }
/** Create a {@link ZScriptInfo} with an URL that is used to load the content. * * @param url the URL to load the content of zscript. */ public ZScriptInfo(NodeInfo parent, String zslang, URL url, ConditionImpl cond) { super(parent, cond); _zs = new ZScript(zslang, url); }
/** Constructs a {@link ZScriptInfo} with an URL, which might contain an EL * expression. * * @param url the URL. It may contain XEL expressions. * @param locator the locator used to locate the zscript file */ public ZScriptInfo(NodeInfo parent, String zslang, String url, Locator locator, ConditionImpl cond) { super(parent, cond); _zs = new ZScript(parent.getEvaluatorRef(), zslang, url, locator); }
public void doInit(Page page, Map args) throws Exception { final String zslang = page.getZScriptLanguage(); final URL url = Jsps.getPageContext( getJspContext()).getServletContext().getResource(_zscript); if (url == null) throw new UiException("File not found: "+_zscript); ZScript zs = new ZScript(null, zslang, url, null); RootTag.processZScript(page, null, zs); } public void doAfterCompose(Page page) throws Exception {}
return new ZScript(zslang, prefix != null && content.length() > 0 ? prefix + content : content);
public void doTag() throws JspException, IOException { if(!super.isEffective())return; String lang = (_lang==null) ? _roottag.getZScriptLanguage() : _lang; ZScript zscript = null; if( _src==null || _src.equals("") ) { // BUG 1997938: getJspBody() could be null! // If both content and _src are nothing, this zscript tag is nothing too. if(getJspBody()==null) return; StringWriter out = new StringWriter(); getJspBody().invoke(out); zscript = new ZScript(null, lang,out.toString() ,null); } else { PageContext pgctx = Jsps.getPageContext(getJspContext()); URL url = pgctx.getServletContext().getResource(_src); zscript = new ZScript(null, lang, url, null); } _roottag.processZScript(_parent, zscript); }
/** Process the init directive. */ private void parseInitDirective(PageDefinition pgdef, ProcessingInstruction pi, Map<String, String> params) throws Exception { final String clsnm = params.remove("class"); final String zsrc = params.remove("zscript"); final Map<String, String> args = new LinkedHashMap<String, String>(params); if (clsnm == null) { if (zsrc == null) throw new UiException(message("Either the class or zscript attribute must be specified", pi)); checkZScriptEnabled(pi.getLocator()); ZScript zs = null; final String zslang = pgdef.getZScriptLanguage(); if (!zsrc.contains("${")) { final URL url = getLocator().getResource(zsrc); if (url != null) zs = new ZScript(zslang, url); //Bug 2929887: defer the error message since it might not be required } if (zs == null) zs = new ZScript(pgdef.getEvaluatorRef(), zslang, zsrc, getLocator()); pgdef.addInitiatorInfo(new InitiatorInfo(new ZScriptInitiator(zs), args)); } else { if (zsrc != null) throw new UiException(message("You cannot specify both class and zscript", pi)); pgdef.addInitiatorInfo(new InitiatorInfo(clsnm, args)); } }