WebApp webapp = WebApp.getCurrent(); MetaClass meta = webapp.getMetaClass(this); Script s = meta.loadTearOff(JellyClassTearOff.class).findScript("newInstanceDetail"); if (s == null) { return "";
public boolean handleIndexRequest(RequestImpl req, ResponseImpl rsp, Object node, MetaClass nodeMetaClass) throws IOException, ServletException { return nodeMetaClass.loadTearOff(JellyClassTearOff.class).serveIndexJelly(req,rsp,node); }
private RequestDispatcher createDispatcher(Object it, String viewName, MetaClass mc) throws IOException { RequestDispatcher d = mc.loadTearOff(GroovyClassTearOff.class).createDispatcher(it, viewName); if (d==null) d = mc.loadTearOff(GroovyServerPageTearOff.class).createDispatcher(it, viewName); return d; }
public boolean handleIndexRequest(RequestImpl req, ResponseImpl rsp, Object node, MetaClass nodeMetaClass) throws IOException, ServletException { return nodeMetaClass.loadTearOff(JellyClassTearOff.class).serveIndexJelly(req,rsp,node); }
protected final S loadScript(String name) throws E { S s = resolveScript(name); if (s!=null) return s; // not found on this class, delegate to the parent if(owner.baseClass!=null) return ((AbstractTearOff<CLT,S,E>)owner.baseClass.loadTearOff(getClass())).findScript(name); return null; }
protected final S loadScript(String name) throws E { S s = resolveScript(name); if (s!=null) return s; // not found on this class, delegate to the parent if(owner.baseClass!=null) return ((AbstractTearOff<CLT,S,E>)owner.baseClass.loadTearOff(getClass())).findScript(name); return null; }
@Override public void buildIndexDispatchers(MetaClass owner, List<Dispatcher> dispatchers) { try { if (owner.loadTearOff(JellyClassTearOff.class).findScript("index")!=null) { super.buildIndexDispatchers(owner, dispatchers); } } catch (JellyException e) { LOGGER.log(Level.WARNING, "Failed to parse index.groovy for "+owner, e); } }
@Override public void buildIndexDispatchers(MetaClass owner, List<Dispatcher> dispatchers) { try { if (owner.loadTearOff(JellyClassTearOff.class).findScript("index.jelly")!=null) { super.buildIndexDispatchers(owner, dispatchers); } } catch (JellyException e) { LOGGER.log(Level.WARNING, "Failed to parse index.jelly for "+owner, e); } }
protected final S loadScript(String name) throws E { S s = resolveScript(name); if (s!=null) return s; // not found on this class, delegate to the parent if(owner.baseClass!=null) return ((AbstractTearOff<CLT,S,E>)owner.baseClass.loadTearOff(getClass())).findScript(name); return null; }
/** * Returns true if this descriptor has <tt>config.jelly</tt>. */ public final boolean hasConfigScreen() { MetaClass c = WebApp.getCurrent().getMetaClass(getClass()); try { JellyClassTearOff tearOff = c.loadTearOff(JellyClassTearOff.class); return tearOff.findScript(getConfigPage())!=null; } catch(JellyException e) { return false; } }
/** * Returns true if this descriptor has <tt>config.jelly</tt>. */ public final boolean hasConfigScreen() { MetaClass c = WebApp.getCurrent().getMetaClass(getClass()); try { JellyClassTearOff tearOff = c.loadTearOff(JellyClassTearOff.class); return tearOff.findScript(getConfigPage())!=null; } catch(JellyException e) { return false; } }
/** * Returns true if this descriptor has <tt>config.jelly</tt>. */ public final boolean hasConfigScreen() { MetaClass c = WebApp.getCurrent().getMetaClass(getClass()); try { JellyClassTearOff tearOff = c.loadTearOff(JellyClassTearOff.class); return tearOff.findScript(getConfigPage())!=null; } catch(JellyException e) { return false; } }
/** * Returns true if this descriptor has <tt>config.jelly</tt>. */ public final boolean hasConfigScreen() { MetaClass c = WebApp.getCurrent().getMetaClass(getClass()); try { JellyClassTearOff tearOff = c.loadTearOff(JellyClassTearOff.class); return tearOff.findScript(getConfigPage())!=null; } catch(JellyException e) { return false; } }
private ScriptDispatcher makeIndexDispatcher(MetaClass mc) throws IOException { for (Class<? extends AbstractRubyTearOff> t : getClassTearOffTypes()) { final AbstractRubyTearOff rt = mc.loadTearOff(t); final Script script = rt.findScript("index"); if(script!=null) return new ScriptDispatcher(rt, script); } return null; }
private void _include(Object it, Klass clazz, String view) throws IOException, JellyException { JellyClassTearOff t = request.getWebApp().getMetaClass(clazz).loadTearOff(JellyClassTearOff.class); Script s = t.findScript(view); if(s==null) throw new IllegalArgumentException("No such view: "+view+" for "+clazz); JellyContext context = new JellyContext(getContext()); if(it!=null) context.setVariable("it",it); context.setVariable("from", it); ClassLoader old = Thread.currentThread().getContextClassLoader(); if (clazz.clazz instanceof Class) Thread.currentThread().setContextClassLoader(((Class)clazz.clazz).getClassLoader()); try { s.run(context,output); } finally { Thread.currentThread().setContextClassLoader(old); } }
/** * Returns true if this descriptor has <tt>config.jelly</tt>. */ public final boolean hasConfigScreen() { MetaClass c = WebApp.getCurrent().getMetaClass(getClass()); try { JellyClassTearOff tearOff = c.loadTearOff(JellyClassTearOff.class); return tearOff.findScript(getConfigPage())!=null; } catch(JellyException e) { return false; } }
/** * Aside from looking into our own, consult other facets that can handle Jelly-compatible scripts. */ @Override public Script resolveScript(String name) throws JellyException { // cut off the extension so that we can search all the extensions String shortName; int dot = name.lastIndexOf('.'); if (dot>name.lastIndexOf('/')) shortName = name.substring(0, dot); else shortName = name; for (Facet f : owner.webApp.facets) { if (f instanceof JellyCompatibleFacet && !(f instanceof JellyFacet)) { JellyCompatibleFacet jcf = (JellyCompatibleFacet) f; for (Class<? extends AbstractTearOff<?,? extends Script,?>> ct : jcf.getClassTearOffTypes()) { try { Script s = owner.loadTearOff(ct).resolveScript(shortName); if (s!=null) return s; } catch (Exception e) { throw new JellyException("Failed to load "+shortName+" from "+jcf,e); } } } } return super.resolveScript(name); }
@Override protected Script resolveDefinition(JellyContext context) throws JellyTagException { Object it = context.getVariable("it"); if (it==null) throw new JellyTagException("'it' was not defined"); try { MetaClass c = WebApp.getCurrent().getMetaClass(it.getClass()); // prefer 'foo.jellytag' to avoid tags from showing up as views, // but for backward compatibility, support the plain .jelly extention as well. Script tag = c.loadTearOff(JellyClassTearOff.class).findScript(tagName+".jellytag"); if (tag==null) tag = c.loadTearOff(JellyClassTearOff.class).findScript(tagName+".jelly"); return tag; } catch (JellyException e) { throw new JellyTagException("Failed to load "+tagName+".jelly from "+it,e); } } };
public String getDescription() { Stapler stapler = Stapler.getCurrent(); if (stapler != null) { try { WebApp webapp = WebApp.getCurrent(); MetaClass meta = webapp.getMetaClass(this); Script s = meta.loadTearOff(JellyClassTearOff.class).findScript("newInstanceDetail"); if (s == null) { return ""; } DefaultScriptInvoker dsi = new DefaultScriptInvoker(); StringWriter sw = new StringWriter(); XMLOutput xml = dsi.createXMLOutput(sw, true); dsi.invokeScript(Stapler.getCurrentRequest(), Stapler.getCurrentResponse(), s, this, xml); return sw.toString(); } catch (Exception e) { Logger.getLogger(clazz.getName()).log(Level.WARNING, e.getMessage(), e); return ""; } } else { return ""; } }
@Override protected Script resolveDefinition(JellyContext context) throws JellyTagException { Object it = expr.evaluate(context); if (it==null) throw new JellyTagException("'"+ expr.getExpressionText() +"' evaluated to null"); try { WebApp webApp = WebApp.getCurrent(); MetaClass c = webApp.getMetaClass(it instanceof Class ? Klass.java((Class)it): webApp.getKlass(it)); // prefer 'foo.jellytag' to avoid tags from showing up as views, // but for backward compatibility, support the plain .jelly extension as well. Script tag = c.loadTearOff(JellyClassTearOff.class).findScript(tagName+".jellytag"); if (tag==null) tag = c.loadTearOff(JellyClassTearOff.class).findScript(tagName+".jelly"); if (tag ==null) throw new JellyTagException("No such tag file "+tagName+".jellytag in "+c); return tag; } catch (JellyException e) { throw new JellyTagException("Failed to load "+tagName+".jellytag from "+it,e); } } };