Example usage for org.apache.commons.jelly JellyContext getVariable

List of usage examples for org.apache.commons.jelly JellyContext getVariable

Introduction

In this page you can find the example usage for org.apache.commons.jelly JellyContext getVariable.

Prototype

public Object getVariable(String name) 

Source Link

Usage

From source file:com.cyclopsgroup.waterview.web.taglib.FormTag.java

/**
 * @param context Jelly context/*from w ww  . ja  v  a2  s .c  o  m*/
 * @return True if control is supposed to be displayed
 */
public static boolean isControlsHidden(JellyContext context) {
    Boolean b = (Boolean) context.getVariable(HIDE_CONTROLS);
    return b == null ? false : b.booleanValue();
}

From source file:com.cyclopsgroup.waterview.utils.TagSupportBase.java

/**
 * Set the resource for script//from w  ww  . j a va2s.  c o  m
 *
 * @param resource Resource of script
 * @param context Context to set
 */
public static final void addScriptResource(URL resource, JellyContext context) {
    synchronized (context) {
        LinkedList scriptResources = (LinkedList) context.getVariable(SCRIPT_RESOURCE_NAME);
        if (scriptResources == null) {
            scriptResources = new LinkedList();
            context.setVariable(SCRIPT_RESOURCE_NAME, scriptResources);
        }
        scriptResources.add(resource);
    }
}

From source file:com.cyclopsgroup.waterview.utils.TagSupportBase.java

/**
 * Remove last script resource/*from   ww  w  .  ja v  a  2 s .com*/
 *
 * @param resource Resource to remove
 * @param context Jelly context
 */
public static final void removeScriptResource(URL resource, JellyContext context) {
    synchronized (context) {
        LinkedList scriptResources = (LinkedList) context.getVariable(SCRIPT_RESOURCE_NAME);
        if (scriptResources == null) {
            return;
        }
        URL last = (URL) scriptResources.getLast();
        if (last.sameFile(resource)) {
            scriptResources.removeLast();
        } else {
            throw new IllegalStateException("The resource to remove is not the last resource");
        }
    }
}

From source file:com.cyclopsgroup.waterview.jelly.valves.DeterminePageValve.java

private Page loadPage(Script script, JellyEngine jellyEngine) throws JellyTagException {
    JellyContext jc = new JellyContext(jellyEngine.getGlobalContext());
    script.run(jc, XMLOutput.createDummyXMLOutput());
    return (Page) jc.getVariable(Page.NAME);
}

From source file:com.cyclopsgroup.waterview.jelly.DeterminePageValve.java

private Page loadPage(Script script) throws JellyTagException {
    JellyContext jc = new JellyContext(jelly.getGlobalContext());
    script.run(jc, XMLOutput.createDummyXMLOutput());
    return (Page) jc.getVariable(Page.NAME);
}

From source file:hudson.widgets.RenderOnDemandClosure.java

public RenderOnDemandClosure(JellyContext context, String attributesToCapture) {
    List<Script> bodyStack = new ArrayList<Script>();
    for (JellyContext c = context; c != null; c = c.getParent()) {
        Script script = (Script) c.getVariables().get("org.apache.commons.jelly.body");
        if (script != null)
            bodyStack.add(script);//from w w  w . j a  v  a 2s .com
    }
    this.bodyStack = bodyStack.toArray(new Script[bodyStack.size()]);
    assert !bodyStack.isEmpty(); // there must be at least one, which is the direct child of <l:renderOnDemand>

    Map<String, Object> variables = new HashMap<String, Object>();
    for (String v : Util.fixNull(attributesToCapture).split(","))
        variables.put(v.intern(), context.getVariable(v));

    // capture the current base of context for descriptors
    currentDescriptorByNameUrl = Descriptor.getCurrentDescriptorByNameUrl();

    this.variables = PackedMap.of(variables);

    Set<String> _adjuncts = AdjunctsInPage.get().getIncluded();
    this.adjuncts = new String[_adjuncts.size()];
    int i = 0;
    for (String adjunct : _adjuncts) {
        this.adjuncts[i++] = adjunct.intern();
    }
}

From source file:org.jenkins.ui.icon.IconType.java

/**
 * Qualify the supplied icon url.//from w  ww  .  java2 s. c o  m
 * <p/>
 * Qualifying the URL involves prefixing it depending on whether the icon is a core or plugin icon.
 *
 * @param url The url to be qualified.
 * @param context The JellyContext.
 * @return The qualified icon url.
 */
public String toQualifiedUrl(String url, JellyContext context) {
    String resURL = context.getVariable("resURL").toString();

    switch (this) {
    case CORE: {
        return resURL + "/images/" + url;
    }
    case PLUGIN: {
        return resURL + "/plugin/" + url;
    }
    }

    return null;
}