Search in sources :

Example 1 with ExpressionEvaluator

use of javax.servlet.jsp.el.ExpressionEvaluator in project com.revolsys.open by revolsys.

the class AbstractElementTag method doTag.

/**
 * Process the tag.
 *
 * @throws JspException If there was an exception processing the tag.
 * @throws IOException If an i/o error occurs.
 */
@Override
public void doTag() throws JspException, IOException {
    try {
        final JspContext jspContext = getJspContext();
        final JspWriter out = jspContext.getOut();
        final ExpressionEvaluator expressionEvaluator = jspContext.getExpressionEvaluator();
        final Collection elements = (Collection) expressionEvaluator.evaluate(this.elementExpression, Collection.class, jspContext.getVariableResolver(), null);
        if (elements != null) {
            serializeElements(out, elements);
        }
    } catch (final Throwable t) {
        log.error(t.getMessage(), t);
        throw new JspTagException(t.getMessage(), t);
    }
}
Also used : JspContext(javax.servlet.jsp.JspContext) Collection(java.util.Collection) JspWriter(javax.servlet.jsp.JspWriter) ExpressionEvaluator(javax.servlet.jsp.el.ExpressionEvaluator)

Example 2 with ExpressionEvaluator

use of javax.servlet.jsp.el.ExpressionEvaluator in project com.revolsys.open by revolsys.

the class AbstractMapElementTag method doTag.

/**
 * Process the tag.
 *
 * @throws JspException If there was an exception processing the tag.
 * @throws IOException If an i/o error occurs.
 */
@Override
public void doTag() throws JspException, IOException {
    try {
        final JspContext jspContext = getJspContext();
        final JspWriter out = jspContext.getOut();
        final ExpressionEvaluator expressionEvaluator = jspContext.getExpressionEvaluator();
        final Object t = expressionEvaluator.evaluate(this.mapExpression, Object.class, jspContext.getVariableResolver(), null);
        if (t instanceof Map) {
            final Map map = (Map) t;
            if (map != null) {
                final Object object = map.get(this.key);
                serializeObject(out, object);
            }
        } else {
            log.debug(t);
        }
    } catch (final Throwable t) {
        log.error(t.getMessage(), t);
        throw new JspTagException(t.getMessage(), t);
    }
}
Also used : JspContext(javax.servlet.jsp.JspContext) JspWriter(javax.servlet.jsp.JspWriter) ExpressionEvaluator(javax.servlet.jsp.el.ExpressionEvaluator) Map(java.util.Map)

Aggregations

JspContext (javax.servlet.jsp.JspContext)2 JspWriter (javax.servlet.jsp.JspWriter)2 ExpressionEvaluator (javax.servlet.jsp.el.ExpressionEvaluator)2 Collection (java.util.Collection)1 Map (java.util.Map)1