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.TiledFormControlTag.java

/**
 * Overwrite or implement method processTag()
 *
 * @see com.cyclopsgroup.waterview.web.taglib.BaseJellyFormControlTag#processTag(org.apache.commons.jelly.XMLOutput)
 *//*w  w w  . j  av  a 2 s . c o  m*/
protected void processTag(XMLOutput output) throws Exception {
    if (getColumns() < 1) {
        throw new JellyTagException("Columns must be bigger than 1");
    }
    super.processTag(output);
}

From source file:com.cyclopsgroup.waterview.jelly.taglib.PanelTag.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  w  w  w .j a  v  a2  s . c  o m*/
public void doTag(ServiceManager serviceManager, XMLOutput output) throws Exception {
    requireAttribute("name");
    Page page = (Page) getContext().getVariable(Page.NAME);
    if (page == null) {
        throw new JellyTagException("Can not use panel without a runtime page");
    }
    PanelContent panelContent = page.getPanelContent(getName());
    if (panelContent == null) {
        invokeBody(output);
    } else {
        if (panelContent.isAppend()) {
            invokeBody(output);
        }
        //TODO handle views
        View[] views = panelContent.getViews();
        for (int i = 0; i < views.length; i++) {
            View view = views[i];
            PageRuntime runtime = getRuntime();
            Context viewContext = new DefaultContext(new HashMap(), runtime.getPageContext());
            try {
                view.execute(runtime, viewContext);
                view.render(runtime, viewContext);
            } catch (Exception e) {
                runtime.getOutput().print("<pre>");
                e.printStackTrace(runtime.getOutput());
                runtime.getOutput().println("</pre>");
            }
        }
        //Panel panel = null;
        //panel.render(runtime, views);
    }
}

From source file:com.cyclopsgroup.waterview.richweb.taglib.TreeTag.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 w  w w . j av a 2  s.  com*/
protected void doTag(ServiceManager serviceManager, XMLOutput output) throws Exception {
    requireAttribute("tree");
    requireAttribute("instance");
    invokeBody(output);
    if (treeScript == null || nodeVar == null) {
        throw new JellyTagException("A TreeScript tag must be defined in Tree tag");
    }

    JellyContext jc = new JellyContext(getContext());
    jc.setVariable(RuntimeTree.NAME, getInstance());
    jc.setVariable(nodeVar, getInstance().createRuntimeNode(tree.getRootNode()));
    treeScript.run(jc, output);
}

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

/**
 * Overwrite or implement method processTag()
 *
 * @see com.cyclopsgroup.waterview.utils.TagSupportBase#processTag(org.apache.commons.jelly.XMLOutput)
 *//*  ww  w  . j  a v  a  2s .c o m*/
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);
}

From source file:com.cyclopsgroup.waterview.jelly.AbstractTag.java

/**
 * Override or implement method of parent class or interface
 *
 * @see org.apache.commons.jelly.Tag#doTag(org.apache.commons.jelly.XMLOutput)
 *///ww  w .  ja  va  2s. c  o  m
public final void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException {
    ServiceManager serviceManager = (ServiceManager) getContext().getVariable(ServiceManager.class.getName());
    try {
        doTag(serviceManager, output);
    } catch (JellyTagException e) {
        throw e;
    } catch (Exception e) {
        throw new JellyTagException(e);
    }
}

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

/**
 * Overwrite or implement method processTag()
 *
 * @see com.cyclopsgroup.waterview.utils.TagSupportBase#processTag(org.apache.commons.jelly.XMLOutput)
 *//*ww  w.j a  v  a 2s  . co  m*/
public void processTag(XMLOutput output) throws Exception {
    requireAttribute("className");
    requireParent(TagLibraryTag.class);
    try {
        TagPackage pkg = (TagPackage) Class.forName(getClassName()).newInstance();
        TagLibraryTag tagLibraryTag = (TagLibraryTag) getParent();
        JellyEngine jellyEngine = (JellyEngine) getContext().getVariable(JellyEngine.ROLE);
        jellyEngine.registerTagPackage(tagLibraryTag.getUri(), pkg);
        logger.debug("Tag package " + pkg + " is registered in waterview");
    } catch (Exception e) {
        throw new JellyTagException(e);
    }
}

From source file:com.cyclopsgroup.tornado.hibernate.taglib.NewTag.java

/**
 * Overwrite or implement method getAttributeType()
 *
 * @see com.cyclopsgroup.waterview.utils.DynaTagSupport#getAttributeType(java.lang.String)
 *//*  www . j a v a2s . c om*/
public Class getAttributeType(String attributeName) throws JellyTagException {
    if (attributeName.equals("var")) {
        return String.class;
    }
    if (descriptors == null) {
        ClassTag classTag = (ClassTag) requireParent(ClassTag.class);
        descriptors = PropertyUtils.getPropertyDescriptors(classTag.getEntityClass());
    }
    for (int i = 0; i < descriptors.length; i++) {
        PropertyDescriptor descriptor = descriptors[i];
        if (descriptor.getName().equals(attributeName)) {
            return descriptor.getPropertyType();
        }
    }
    throw new JellyTagException("Attribute " + attributeName + " is not supported");
}

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

/**
 * Overwrite or implement method processTag()
 *
 * @see com.cyclopsgroup.waterview.utils.TagSupportBase#processTag(org.apache.commons.jelly.XMLOutput)
 *///ww  w . j  a va  2s. c  om
protected void processTag(XMLOutput output) throws Exception {
    requireAttribute("type");
    requireAttribute("path");
    Script script = null;
    if (StringUtils.equals(getType(), "system")) {
        JellyEngine je = (JellyEngine) getServiceManager().lookup(JellyEngine.ROLE);
        script = je.getScript(getPath());
    } else if (StringUtils.equals(getType(), "classpath")) {
        URL resource = getClass().getClassLoader().getResource(getPath());
        if (resource != null) {
            script = context.compileScript(resource);
        }
    } else if (StringUtils.equals(getType(), "file")) {
        File file = new File(getPath());
        if (file.exists()) {
            script = context.compileScript(file.toURL());
        }
    } else {
        throw new JellyTagException("Type must be system|classpath|file, default value is system");
    }
    if (script == null) {
        throw new FileNotFoundException("Resource " + getPath() + " is not found in " + getType());
    }
    JellyContext jc = new JellyContext(getContext());
    if (script != null) {
        script.run(jc, output);
        output.flush();
    }
}

From source file:com.cyclopsgroup.tornado.hibernate.taglib.HqlTabularDataTag.java

/**
 * Override method processTag in class HQLTabularDataTag
 *
 * @see com.cyclopsgroup.waterview.utils.TagSupportBase#processTag(org.apache.commons.jelly.XMLOutput)
 *///from ww  w .  j a  va  2  s.c o  m
protected void processTag(XMLOutput output) throws Exception {
    requireAttribute("dataSource");
    TableControlTag tableControl = (TableControlTag) requireParent(TableControlTag.class);
    invokeBody(output);
    if (StringUtils.isEmpty(hql) && parameterTags.isEmpty()) {
        hql = getBodyText();
    }
    if (StringUtils.isEmpty(hql)) {
        throw new JellyTagException("HQL must be defined");
    }
    HibernateService hibernate = (HibernateService) getServiceManager().lookup(HibernateService.ROLE);
    HqlLargeList data = new HqlLargeList(hql, hibernate, getDataSource());
    for (Iterator i = parameterTags.iterator(); i.hasNext();) {
        HqlParameterTag param = (HqlParameterTag) i.next();
        String type = "char";
        if (StringUtils.isNotEmpty(param.getType())) {
            type = param.getType();
        }
        data.addParameter(param.getName(), type, param.getValue());
    }
    tableControl.setTabularData(data);
}

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

/**
 * Overwrite or implement method processTag()
 *
 * @see com.cyclopsgroup.waterview.utils.TagSupportBase#processTag(org.apache.commons.jelly.XMLOutput)
 *//*from w w  w. ja  va  2s.  c  o  m*/
public void processTag(XMLOutput output) throws Exception {
    requireAttribute("name");
    invokeBody(output);
    if (getLayout() == null) {
        throw new JellyTagException("There must be a layout defined in layout tag");
    }
    LookAndFeelService laf = (LookAndFeelService) getServiceManager().lookup(LookAndFeelService.ROLE);
    laf.registerLayout(this);
}