Example usage for javax.servlet.jsp.tagext SimpleTagSupport findAncestorWithClass

List of usage examples for javax.servlet.jsp.tagext SimpleTagSupport findAncestorWithClass

Introduction

In this page you can find the example usage for javax.servlet.jsp.tagext SimpleTagSupport findAncestorWithClass.

Prototype

public static final JspTag findAncestorWithClass(JspTag from, Class<?> klass) 

Source Link

Document

Find the instance of a given class type that is closest to a given instance.

Usage

From source file:edu.cornell.mannlib.vitro.webapp.web.jsptags.ListSparqlTag.java

/**
 * //from  w w  w. java 2 s .  co  m
 * The query get executed, the result set copied into a Collection and
 * the queryExecution gets closed.
 */
public void doTag() throws JspException {
    log.debug("CollectionSparqlTag.doTag()");

    SparqlTag container = ((SparqlTag) SimpleTagSupport.findAncestorWithClass(this, SparqlTag.class));
    if (container == null) {
        throw new RuntimeException("Ancestor must be sparql container");
    }
    //we copy the resultset into a collection so dispose can be called immediately
    //container.addInnerTag((SelectTag)this);

    Query query = parseQuery();
    QueryExecution qex = QueryExecutionFactory.create(query, model, qparams);
    log.debug("query executed");

    ResultSet results;
    model.enterCriticalSection(Lock.READ);
    try {
        results = qex.execSelect();
        List<Map<String, RDFNode>> resultList = new LinkedList<Map<String, RDFNode>>();

        for (QuerySolution qs : IterableAdaptor.adapt((Iterator<QuerySolution>) results)) {
            log.debug("found solution");
            HashMap<String, RDFNode> map1 = new HashMap<String, RDFNode>();
            for (String name : IterableAdaptor.adapt((Iterator<String>) qs.varNames())) {
                RDFNode value = qs.get(name);
                if (log.isDebugEnabled()) {
                    log.debug(name + ": " + value.toString());
                }
                map1.put(name, value);
            }
            resultList.add(map1);
        }
        log.debug("setting " + var + " to a list of size " + resultList.size());
        getJspContext().setAttribute(var, resultList);
    } finally {
        model.leaveCriticalSection();
        synchronized (this) {
            if (qex != null) {
                qex.close();
            }
            model = null;
            var = null;
            qparams = null;
            qex = null;
        }
    }
}

From source file:com.safetys.framework.jmesa.model.tag.TagUtils.java

/**
 * @return Is true is the validation passes
 *//*from  ww  w  .  j  a va  2 s .  c om*/
static boolean validateColumn(SimpleTagSupport simpleTagSupport, String property) {
    if (property == null) {
        return true; // no coflicts
    }

    HtmlRowTag rowTag = (HtmlRowTag) SimpleTagSupport.findAncestorWithClass(simpleTagSupport, HtmlRowTag.class);
    Map<String, ?> pageItem = rowTag.getPageItem();
    if (pageItem.get(property) != null) {
        String msg = "The column property [" + property
                + "] is not unique. One column value will overwrite another.";
        logger.error(msg);
        throw new IllegalStateException(msg);
    }

    TableModelTag facadeTag = (TableModelTag) SimpleTagSupport.findAncestorWithClass(simpleTagSupport,
            TableModelTag.class);
    String var = facadeTag.getVar();
    if (var.equals(property)) {
        String msg = "The column property [" + property + "] is the same as the TableFacadeTag var attribute ["
                + var + "].";
        logger.error(msg);
        throw new IllegalStateException(msg);
    }

    return true;
}

From source file:com.safetys.framework.jmesa.facade.tag.TagUtils.java

/**
 * @return Is true is the validation passes
 *//*from w  w  w.  ja  v  a 2  s. c  o m*/
static boolean validateColumn(SimpleTagSupport simpleTagSupport, String property) {
    if (property == null) {
        return true; // no coflicts
    }

    HtmlRowTag rowTag = (HtmlRowTag) SimpleTagSupport.findAncestorWithClass(simpleTagSupport, HtmlRowTag.class);
    Map<String, ?> pageItem = rowTag.getPageItem();
    if (pageItem.get(property) != null) {
        String msg = "The column property [" + property
                + "] is not unique. One column value will overwrite another.";
        logger.error(msg);
        throw new IllegalStateException(msg);
    }

    TableFacadeTag facadeTag = (TableFacadeTag) SimpleTagSupport.findAncestorWithClass(simpleTagSupport,
            TableFacadeTag.class);
    String var = facadeTag.getVar();
    if (var.equals(property)) {
        String msg = "The column property [" + property + "] is the same as the TableFacadeTag var attribute ["
                + var + "].";
        logger.error(msg);
        throw new IllegalStateException(msg);
    }

    return true;
}

From source file:com.jslsolucoes.tagria.lib.util.TagUtil.java

public static String complementForDetailTable(SimpleTagSupport simpleTagSupport) {
    if (simpleTagSupport == null) {
        return "";
    } else {/*www . j a  v a  2s  . c  om*/
        DetailTableTag detailTable = (DetailTableTag) SimpleTagSupport.findAncestorWithClass(simpleTagSupport,
                DetailTableTag.class);
        return detailTable != null ? "_" + detailTable.getIteration() : "";
    }
}

From source file:org.jmesa.model.tag.TagUtils.java

/**
 * @return Is true is the validation passes
 *///www.  ja va2s  .  c  om
static boolean validateColumn(SimpleTagSupport simpleTagSupport, String property) {

    if (property == null) {
        return true; // no coflicts
    }

    HtmlRowTag rowTag = (HtmlRowTag) SimpleTagSupport.findAncestorWithClass(simpleTagSupport, HtmlRowTag.class);
    Map<String, ?> pageItem = rowTag.getPageItem();
    if (pageItem.get(property) != null) {
        String msg = "The column property [" + property
                + "] is not unique. One column value will overwrite another.";
        logger.error(msg);
        throw new IllegalStateException(msg);
    }

    TableModelTag facadeTag = (TableModelTag) SimpleTagSupport.findAncestorWithClass(simpleTagSupport,
            TableModelTag.class);
    String var = facadeTag.getVar();
    if (var.equals(property)) {
        String msg = "The column property [" + property + "] is the same as the TableFacadeTag var attribute ["
                + var + "].";
        logger.error(msg);
        throw new IllegalStateException(msg);
    }

    return true;
}