Example usage for org.apache.commons.jelly JellyTagException JellyTagException

List of usage examples for org.apache.commons.jelly JellyTagException JellyTagException

Introduction

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

Prototype

public JellyTagException(Throwable cause) 

Source Link

Usage

From source file:com.cyclopsgroup.waterview.web.taglib.BaseValidatorTag.java

/**
 * Overwrite or implement method processTag()
 *
 * @see com.cyclopsgroup.waterview.utils.TagSupportBase#processTag(org.apache.commons.jelly.XMLOutput)
 *//*w w w  . j  a v  a 2s  .c om*/
protected void processTag(XMLOutput output) throws Exception {
    FieldValidator validator = createValidator();
    if (getParent() instanceof FieldTag) {
        ((FieldTag) getParent()).getField().setValidator(validator);
    } else if (getParent() instanceof ValidatorsTag) {
        ((ValidatorsTag) getParent()).addValidator(validator);
    } else {
        throw new JellyTagException("Parent tag must be Field or Validators");
    }
}

From source file:com.cyclopsgroup.waterview.utils.TagSupport.java

/**
 * Throw MissingAttributeException if an attribute is missing
 *
 * @param name Attribute name/*from  www  .j  av  a  2 s  .  com*/
 * @throws JellyTagException Throw it out
 */
protected final void requireAttribute(String name) throws JellyTagException {
    Object value = null;
    try {
        value = PropertyUtils.getProperty(this, name);
    } catch (Exception e) {
        throw new JellyTagException("Attribute [" + name + "] is not defined in tag");
    }
    if (value == null) {
        throw new MissingAttributeException(name);
    }
}

From source file:com.cyclopsgroup.waterview.core.taglib.DefaultLayoutTag.java

/**
 * Overwrite or implement method processTag()
 *
 * @see com.cyclopsgroup.waterview.utils.TagSupportBase#processTag(org.apache.commons.jelly.XMLOutput)
 *//*from  ww w  .  j av a  2s .  c o m*/
public void processTag(XMLOutput output) throws Exception {
    Page page = (Page) context.getVariable(Page.NAME);
    if (page == null) {
        throw new JellyTagException("JellyLayout must be in a page");
    }
    LookAndFeelService tm = (LookAndFeelService) getServiceManager().lookup(LookAndFeelService.ROLE);
    Theme theme = tm.getRuntimeTheme(getRuntimeData());
    page.setLayout(theme.getLayout(Theme.LAYOUT_FOR_DEFAULT));
}

From source file:com.cyclopsgroup.waterview.jelly.taglib.DefaultLayoutTag.java

/**
 * Override or implement method of parent class or interface
 *
 * @see com.cyclopsgroup.waterview.jelly.AbstractTag#doTag(org.apache.avalon.framework.service.ServiceManager, org.apache.commons.jelly.XMLOutput)
 *//*w ww.ja va  2  s. co  m*/
public void doTag(ServiceManager serviceManager, XMLOutput output) throws Exception {
    Page page = (Page) context.getVariable(Page.NAME);
    if (page == null) {
        throw new JellyTagException("JellyLayout must be in a page");
    }
    ModuleManager mm = (ModuleManager) serviceManager.lookup(ModuleManager.ROLE);
    page.setLayout(mm.getDefaultLayout());
}

From source file:com.cyclopsgroup.waterview.jelly.taglib.SystemLayoutTag.java

/**
 * Override or implement method of parent class or interface
 *
 * @see com.cyclopsgroup.waterview.jelly.AbstractTag#doTag(org.apache.avalon.framework.service.ServiceManager, org.apache.commons.jelly.XMLOutput)
 *//*  www .  jav a 2s.  c om*/
public void doTag(ServiceManager serviceManager, XMLOutput output) throws Exception {
    requireAttribute("id");
    Page page = (Page) context.getVariable(Page.NAME);
    if (page == null) {
        throw new JellyTagException("JellyLayout must be in a page");
    }
    ModuleManager mm = (ModuleManager) serviceManager.lookup(ModuleManager.ROLE);
    Layout layout = mm.getLayout(getId());
    if (layout == null) {
        throw new NullPointerException("Layout [" + getId() + "] doesn't exist");
    }
    page.setLayout(layout);
}

From source file:com.cyclopsgroup.waterview.web.taglib.BaseJellyFormControlTag.java

/**
 * Override method runScript in class BaseJellyFormControlTag
 *
 * @see com.cyclopsgroup.waterview.jelly.taglib.BaseJellyControlTag#runScript(org.apache.commons.jelly.Script, org.apache.commons.jelly.XMLOutput)
 *//*from w w  w . j av  a2s . co m*/
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);
}

From source file:com.cyclopsgroup.waterview.richweb.taglib.TreeChildrenTag.java

/**
 * Override or implement method of parent class or interface
 *
 * @see com.cyclopsgroup.waterview.jelly.AbstractTag#doTag(org.apache.avalon.framework.service.ServiceManager, org.apache.commons.jelly.XMLOutput)
 *///from ww  w  .j  av  a 2 s  .c o  m
protected void doTag(ServiceManager serviceManager, XMLOutput output) throws Exception {
    TreeScriptTag treeScriptTag = (TreeScriptTag) findAncestorWithClass(TreeScriptTag.class);
    String var = treeScriptTag.getVar();
    if (treeScriptTag == null) {
        throw new JellyTagException("TreeChildren must be in the TreeScript");
    }
    TreeNode node = (TreeNode) getContext().getVariable(var);
    TreeNode[] children = node.getChildren();

    RuntimeTree treeRuntime = (RuntimeTree) getContext().getVariable(RuntimeTree.NAME);
    for (int i = 0; i < children.length; i++) {
        TreeNode child = children[i];
        JellyContext jc = new JellyContext(getContext());
        jc.setVariable(var, treeRuntime.createRuntimeNode(child));
        treeScriptTag.getBody().run(jc, output);
    }
}

From source file:com.cyclopsgroup.waterview.jelly.taglib.JellyLayoutTag.java

/**
 * Overwrite or implement method processTag()
 *
 * @see com.cyclopsgroup.waterview.utils.TagSupportBase#processTag(org.apache.commons.jelly.XMLOutput)
 *///from  w  w w.  ja  v a2s .  c om
public void processTag(XMLOutput output) throws Exception {
    requireAttribute("script");
    Page page = (Page) context.getVariable(Page.NAME);
    if (page == null) {
        throw new JellyTagException("JellyLayout must be in a page");
    }
    JellyEngine jellyEngine = (JellyEngine) getServiceManager().lookup(JellyEngine.ROLE);
    Layout layout = new JellyLayout(jellyEngine.getScript(getScript()), getScript());
    page.setLayout(layout);
}

From source file:com.cyclopsgroup.waterview.core.taglib.SystemLayoutTag.java

/**
 * Overwrite or implement method processTag()
 *
 * @see com.cyclopsgroup.waterview.utils.TagSupportBase#processTag(org.apache.commons.jelly.XMLOutput)
 *//*from   w  ww  .j av  a  2s  . c o  m*/
public void processTag(XMLOutput output) throws Exception {
    requireAttribute("name");
    Page page = (Page) context.getVariable(Page.NAME);
    if (page == null) {
        throw new JellyTagException("JellyLayout must be in a page");
    }
    LookAndFeelService tm = (LookAndFeelService) getServiceManager().lookup(LookAndFeelService.ROLE);
    Theme theme = tm.getRuntimeTheme(getRuntimeData());
    Layout layout = theme.getLayout(getName());
    if (layout == null) {
        throw new NullPointerException("Layout [" + getName() + "] doesn't exist");
    }
    page.setLayout(layout);
}

From source file:com.cyclopsgroup.waterview.jelly.deftaglib.FrameTag.java

/**
 * Override or implement method of parent class or interface
 *
 * @see com.cyclopsgroup.waterview.jelly.AbstractTag#doTag(org.apache.avalon.framework.service.ServiceManager, org.apache.commons.jelly.XMLOutput)
 *//*www  .  j  a  va 2s.  c o m*/
public void doTag(ServiceManager serviceManager, XMLOutput output) throws Exception {
    requireAttribute("id");
    if (StringUtils.isEmpty(getDescription())) {
        setDescription("Layout [" + getId() + "]");
    }
    invokeBody(output);
    if (getFrame() == null) {
        throw new JellyTagException("There must be a frame defined in layout tag");
    }
    ModuleManager moduleManager = (ModuleManager) serviceManager.lookup(ModuleManager.ROLE);
    moduleManager.registerFrame(getId(), getFrame());
}