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

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

Introduction

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

Prototype

public void setCurrentURL(URL currentURL) 

Source Link

Document

Sets the current URL context of the current script that is executing.

Usage

From source file:org.sapia.soto.state.cocoon.view.JellyView.java

protected void execute(Object model, Map viewParams, ContentHandler handler) throws Throwable {
    if (_jelly == null) {
        throw new IllegalStateException("Jelly script not set on Jelly view");
    }/*from  ww w.  j a v  a 2  s.c  o m*/

    if (_lastModified != _res.lastModified()) {
        reload();
    }

    JellyContext jelly = new JellyContext();
    JellyUtils.copyParamsTo(jelly, viewParams);
    jelly.setCurrentURL(new URL(_res.getURI()));
    jelly.setVariable(CocoonContext.MODEL_KEY, model);

    Param p;
    for (int i = 0; i < _params.size(); i++) {
        p = (Param) _params.get(i);
        if (p.getName() != null && p.getValue() != null) {
            jelly.setVariable(p.getName(), p.getValue());
        }
    }

    XMLOutput output = new XMLOutput(handler);
    output.startDocument();
    _jelly.run(jelly, output);
    output.endDocument();
}