Refine search
actual.addAttribute("",name,name,"CDATA",expression.evaluateAsString(context)); output.startElement(tagName,actual); getTagBody().run(context,output); output.endElement(tagName); } catch (SAXException x) { throw new JellyTagException(x);
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { try { chain.doFilter(request,response); } catch (ServletException e) { Throwable t = e.getRootCause(); if (t instanceof JellyTagException) { JellyTagException jte = (JellyTagException) t; Throwable cause = jte.getCause(); if (cause instanceof AcegiSecurityException) { AcegiSecurityException se = (AcegiSecurityException) cause; throw new ServletException(se); } } throw e; } }
public void doTag(XMLOutput output) throws JellyTagException { if ( var == null ) { throw new JellyTagException( "<define:script> must have a var attribute" ); } context.setVariable( var, getBody() ); }
public void doTag(XMLOutput output) throws JellyTagException { try { output.startElement(uri, localName, qname, attributes); invokeBody(output); output.endElement(uri, localName, qname); } catch (SAXException e) { throw new JellyTagException(e); } }
public void doTag(XMLOutput output) throws JellyTagException { if (value != null) { String text = value.evaluateAsString(context); if (text != null) { try { output.write(text); } catch (SAXException e) { throw new JellyTagException("could not write the XMLOutput",e); } } } }
/** * Factory method to create a new JellyTagException instance from a given * failure exception * @param e is the exception which occurred attempting to load the class * @return JellyTagException */ protected JellyTagException createLoadClassFailedException(Exception e) { return new JellyTagException( "Could not load class: " + className + ". Reason: " + e, e ); } }
/** Evaluates the body of a tag */ public void run(JellyContext context, XMLOutput output) throws JellyTagException { if ( text != null ) { try { output.write(text); } catch (SAXException e) { throw new JellyTagException("could not write to XMLOutput",e); } } } }
/** * Perform tag processing * @param output the destination for output * @throws MissingAttributeException if a required attribute is missing * @throws JellyTagException on any other errors */ public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { if (uri == null && file == null) { throw new MissingAttributeException( "uri" ); } try { if (uri != null) { // we need to create a new JellyContext of the URI // take off the script name from the URL context.runScript(uri, output, true, isInherit() ); } else { context.runScript(new java.io.File(file), output, true, isInherit()); } } catch (JellyException e) { throw new JellyTagException("could not import script",e); } }
/** Evaluates the body of a tag */ public void run(JellyContext context, XMLOutput output) throws JellyTagException { Object result = expression.evaluate(context); if ( result != null ) { try { output.objectData(result); } catch (SAXException e) { throw new JellyTagException("Could not write to XMLOutput",e); } } } }
/** * Evaluates this tag after all the tags properties have been initialized. * */ public void doTag(XMLOutput output) throws JellyTagException { MessageTag parent = null; Tag t = findAncestorWithClass(this, MessageTag.class); if (t != null) { parent = (MessageTag) t; } else { // must be nested inside a <fmt:message> action. throw new JellyTagException("must be nested inside a <fmt:message> action."); } Object valueInput = null; if (this.value != null) { valueInput = this.value.evaluate(context); } else { // get value from body valueInput = getBodyText(); } parent.addParam(valueInput); }
/** * Parses the body of this tag and returns the parsed document */ protected void parseBody(XMLOutput output) throws JellyTagException { ContentHandler handler = getJellyParser(); XMLOutput newOutput = new XMLOutput(handler); try { handler.startDocument(); invokeBody(newOutput); handler.endDocument(); } catch (SAXException e) { throw new JellyTagException(e); } }
public void doTag(XMLOutput output) throws JellyTagException { StructuredMessageFormatTag tag = (StructuredMessageFormatTag)findAncestorWithClass(StructuredMessageFormatTag.class); if(tag == null) throw new JellyTagException("This tag must be enclosed inside a <structuredMessageFormat> tag" ); StringWriter sw = new StringWriter(); XMLOutput o = XMLOutput.createXMLOutput(sw); invokeBody(o); tag.addArgument(sw); } }
public void doTag(XMLOutput output) throws JellyTagException { ChooseTag tag = (ChooseTag) findAncestorWithClass( ChooseTag.class ); if ( tag == null ) { throw new JellyTagException( "This tag must be enclosed inside a <choose> tag" ); } if ( ! tag.isBlockEvaluated() && test != null ) { if ( test.evaluateAsBoolean( context ) ) { tag.setBlockEvaluated(true); invokeBody(output); } } }
@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); } } };
@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 void doTag(XMLOutput output) throws JellyTagException { if (test == null && xpath == null) { throw new MissingAttributeException( "test" ); } if (test != null) { if (! test.evaluateAsBoolean(context)) { fail( getBodyText(), "evaluating test: "+ test.getExpressionText() ); } } else { try { Object xpathContext = getXPathContext(); if (! xpath.booleanValueOf(xpathContext)) { fail( getBodyText(), "evaluating xpath: "+ xpath ); } } catch (JaxenException anException) { throw new JellyTagException("Error evaluating xpath", anException); } } }
public void doTag(XMLOutput output) throws JellyTagException { String text = getText(); if (text == null) { text = getBodyText(false); } char[] ch = text.toCharArray(); try { output.comment(ch, 0, ch.length); } catch (SAXException e) { throw new JellyTagException(e); } }
public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { if (name == null) { throw new MissingAttributeException( "name" ); } try { output.startDTD(name, publicId, systemId); invokeBody(output); output.endDTD(); } catch (SAXException e) { throw new JellyTagException(e); } }
public void doTag(XMLOutput output) throws JellyTagException { String message = null; if(var == null) message = "var"; else if(field == null) message = "field"; else if(className == null) message = "className"; if(message != null) throw new MissingAttributeException(message); try { Class type = ClassLoaderUtils.getClassLoader(getClass()).loadClass(className); Object result = type.getField(field).get(null); JellyContext context = getContext(); context.setVariable(var, result); } catch(Throwable t) { throw new JellyTagException("Could not access " + className + "." + var + ". Original exception message: " + t.getMessage(), t); } }
public void doTag(XMLOutput output) throws JellyTagException { try { output.startElement(uri, localName, qname, attributes); invokeBody(output); output.endElement(uri, localName, qname); } catch (SAXException e) { throw new JellyTagException(e); } finally { attributes.clear(); context = null; } }