Beispiel #1
0
  public void testVarNoBreakTag() throws Exception {
    setUpScript("testBreakTag.jelly");
    Script script = getJelly().compileScript();

    script.run(getJellyContext(), getXMLOutput());

    String varNotBroken = (String) getJellyContext().getVariable("varNotBroken");

    assertEquals("varNotBroken", "false", varNotBroken);
  }
Beispiel #2
0
  public void testConditionalBreakTag() throws Exception {
    setUpScript("testBreakTag.jelly");
    Script script = getJelly().compileScript();

    script.run(getJellyContext(), getXMLOutput());

    String simpleResult = (String) getJellyContext().getVariable("conditionalResult");

    assertEquals("conditionalResult", "12345", simpleResult);
  }
Beispiel #3
0
 public void testImportResourcesFromUncompiledScript()
     throws JellyException, UnsupportedEncodingException, IOException, SAXException {
   JellyContext context = new JellyContext();
   URL url = TestImport.class.getResource("/resources/import.jelly");
   StringWriter writer = new StringWriter();
   XMLOutput out = XMLOutput.createXMLOutput(writer);
   Script script = new XMLParser().parse(url);
   script.run(context, out);
   out.close();
   assertEquals(expected, writer.toString());
 }
  /**
   * Overwrite or implement method processTag()
   *
   * @see
   *     com.cyclopsgroup.waterview.utils.TagSupportBase#processTag(org.apache.commons.jelly.XMLOutput)
   */
  protected void processTag(XMLOutput output) throws Exception {
    requireAttribute("script");
    invokeBody(XMLOutput.createDummyXMLOutput());

    if (formTag == null) {
      throw new JellyTagException("Form tag must be defined");
    }
    JellyEngine je = (JellyEngine) getServiceManager().lookup(JellyEngine.ROLE);
    Script script = je.getScript(getScript());

    JellyContext jc = new JellyContext(getContext());
    jc.setVariable("formTag", formTag);
    jc.setVariable("form", formTag.getForm());

    script.run(jc, output);
  }
 /**
  * Override method runScript in class BaseJellyFormControlTag
  *
  * @see
  *     com.cyclopsgroup.waterview.jelly.taglib.BaseJellyControlTag#runScript(org.apache.commons.jelly.Script,
  *     org.apache.commons.jelly.XMLOutput)
  */
 protected void runScript(Script script, XMLOutput output) throws Exception {
   FormTag.setHideControls(true, getContext());
   String formContent = getBodyText();
   FormTag.setHideControls(false, getContext());
   if (formTag == null) {
     throw new JellyTagException("Form tag must be defined");
   }
   JellyContext jc = new JellyContext(getContext());
   jc.setVariable("formControl", this);
   jc.setVariable("formTag", formTag);
   jc.setVariable("form", formTag.getForm());
   jc.setVariable("formContent", formContent);
   script.run(jc, output);
 }
Beispiel #6
0
 // Tag interface
 // -------------------------------------------------------------------------
 public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException {
   if (script == null) {
     throw new MissingAttributeException("script");
   }
   script.run(context, output);
 }
Beispiel #7
0
 /**
  * Evaluate a Jelly script and return output as a String.
  *
  * @since 1.267
  */
 public static String runScript(Script script) throws JellyTagException {
   StringWriter out = new StringWriter();
   script.run(getCurrentJellyContext(), XMLOutput.createXMLOutput(out));
   return out.toString();
 }