List of usage examples for org.apache.commons.jelly XMLOutput createDummyXMLOutput
public static XMLOutput createDummyXMLOutput()
From source file:com.cyclopsgroup.waterview.jelly.JellyRunner.java
/** * Main entry to run a script//from w w w . j av a 2 s .co m * * @param args Script paths * @throws Exception Throw it out */ public static final void main(String[] args) throws Exception { List scripts = new ArrayList(); for (int i = 0; i < args.length; i++) { String path = args[i]; File file = new File(path); if (file.isFile()) { scripts.add(file.toURL()); } else { Enumeration enu = JellyRunner.class.getClassLoader().getResources(path); CollectionUtils.addAll(scripts, enu); } } if (scripts.isEmpty()) { System.out.println("No script to run, return!"); return; } String basedir = new File("").getAbsolutePath(); Properties initProperties = new Properties(System.getProperties()); initProperties.setProperty("basedir", basedir); initProperties.setProperty("plexus.home", basedir); WaterviewPlexusContainer container = new WaterviewPlexusContainer(); for (Iterator j = initProperties.keySet().iterator(); j.hasNext();) { String initPropertyName = (String) j.next(); container.addContextValue(initPropertyName, initProperties.get(initPropertyName)); } container.addContextValue(Waterview.INIT_PROPERTIES, initProperties); container.initialize(); container.start(); JellyEngine je = (JellyEngine) container.lookup(JellyEngine.ROLE); JellyContext jc = new JellyContext(je.getGlobalContext()); for (Iterator i = scripts.iterator(); i.hasNext();) { URL script = (URL) i.next(); System.out.print("Running script " + script); jc.runScript(script, XMLOutput.createDummyXMLOutput()); System.out.println("... Done!"); } container.dispose(); }
From source file:com.cyclopsgroup.waterview.web.taglib.BaseJellyTableControlTag.java
/** * Override method runScript in class BaseJellyTableControlTag * * @see com.cyclopsgroup.waterview.jelly.taglib.BaseJellyControlTag#runScript(org.apache.commons.jelly.Script, org.apache.commons.jelly.XMLOutput) *///from w w w . java2 s .c o m protected void runScript(Script script, XMLOutput output) throws Exception { invokeBody(XMLOutput.createDummyXMLOutput()); if (tableTag == null) { throw new JellyException("One table must be defined"); } if (data == null) { throw new JellyException("Tabular data must be included"); } JellyContext jc = new JellyContext(getContext()); jc.setVariable("tableTag", tableTag); jc.setVariable("table", tableTag.getTable()); jc.setVariable("tabularData", data); jc.setVariable("tableControl", this); script.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) *///from w w w . j av a2 s. co 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.web.taglib.DisplayPortletTag.java
/** * Overwrite or implement method processTag() * * @see com.cyclopsgroup.waterview.jelly.taglib.BaseJellyControlTag#processTag(org.apache.commons.jelly.XMLOutput) *///from w w w . j a v a 2s .com protected void processTag(XMLOutput output) throws Exception { invokeBody(XMLOutput.createDummyXMLOutput()); requireAttribute("portlet"); super.processTag(output); }
From source file:com.cyclopsgroup.waterview.web.taglib.JellyTableControlTag.java
/** * Overwrite or implement method processTag() * * @see com.cyclopsgroup.waterview.utils.TagSupportBase#processTag(org.apache.commons.jelly.XMLOutput) *//*w w w. j a va 2 s.c om*/ protected void processTag(XMLOutput output) throws Exception { requireAttribute("script"); invokeBody(XMLOutput.createDummyXMLOutput()); JellyEngine je = (JellyEngine) getServiceManager().lookup(JellyEngine.ROLE); Script s = je.getScript(getScript()); if (tableTag == null) { throw new JellyException("One table must be defined"); } if (data == null) { throw new JellyException("Tabular data must be included"); } JellyContext jc = new JellyContext(getContext()); jc.setVariable("tableTag", tableTag); jc.setVariable("table", tableTag.getTable()); jc.setVariable("tabularData", getData()); s.run(jc, output); }
From source file:com.cyclopsgroup.waterview.core.taglib.PortletTag.java
/** * Overwrite or implement method processTag() * * @see com.cyclopsgroup.waterview.utils.TagSupportBase#processTag(org.apache.commons.jelly.XMLOutput) *//*ww w . jav a 2 s . co m*/ protected void processTag(XMLOutput output) throws Exception { PortletAware pa = (PortletAware) findAncestorWithClass(PortletAware.class); if (pa == null) { throw new JellyException("Portlet must be in a proper tag"); } invokeBody(XMLOutput.createDummyXMLOutput()); if (view == null) { throw new JellyException("A view must be defined"); } ViewPortlet portlet = new ViewPortlet(view); portlet.setTitle(getTitle()); portlet.setDescription(getDescription()); pa.doPortlet(portlet); }
From source file:com.cyclopsgroup.waterview.web.taglib.HorizontalTabControlTag.java
/** * Overwrite or implement method processTag() * * @see com.cyclopsgroup.waterview.jelly.taglib.BaseJellyControlTag#processTag(org.apache.commons.jelly.XMLOutput) *///from w w w . j av a 2 s. c om protected void processTag(XMLOutput output) throws Exception { requireAttribute("name"); invokeBody(XMLOutput.createDummyXMLOutput()); if (tabTags.isEmpty()) { throw new JellyTagException("At least one tab must be defined"); } String selectedTabName = (String) getRuntimeData().getSessionContext().get(getUniqueTagId()); if (StringUtils.isNotEmpty(selectedTabName)) { setSelected(selectedTabName); } else if (StringUtils.isEmpty(getSelected()) || !tabTags.containsKey(getSelected())) { setSelected((String) tabTags.keySet().iterator().next()); } super.processTag(output); }
From source file:com.cyclopsgroup.waterview.core.taglib.GetPortletsTag.java
/** * Override method processTag in class GetPanelComponentsTag * * @see com.cyclopsgroup.waterview.utils.TagSupportBase#processTag(org.apache.commons.jelly.XMLOutput) *//*from w w w . ja v a 2 s . c o m*/ protected void processTag(XMLOutput output) throws Exception { requireAttribute("var"); requireAttribute("panel"); Page page = (Page) getContext().getVariable(Page.NAME); if (page == null) { throw new JellyTagException("Page is not found"); } PanelContent content = page.getPanelContent(getPanel()); List portlets; if (content == null) { invokeBody(XMLOutput.createDummyXMLOutput()); portlets = new ArrayList(defaultPortlets); } else if (content.isAppend()) { invokeBody(XMLOutput.createDummyXMLOutput()); portlets = new ArrayList(defaultPortlets); CollectionUtils.addAll(portlets, content.getPortlets()); } else { portlets = new ArrayList(); CollectionUtils.addAll(portlets, content.getPortlets()); } getContext().setVariable(getVar(), portlets); }
From source file:com.cyclopsgroup.waterview.navigator.impl.DefaultNavigatorHome.java
/** * Overwrite or implement method in DefaultNavigatorHome * * @see org.apache.avalon.framework.activity.Initializable#initialize() *//*w w w. j a v a2 s . c o m*/ public void initialize() throws Exception { pathIndex = new Hashtable(); parentPathIndex = new MultiHashMap(); pageIndex = new Hashtable(); rootNode = new DefaultNavigatorNode(this, "/", null); rootNode.getAttributes().set(DefaultNavigatorNode.PAGE_NAME, "/Index.jelly"); rootNode.getAttributes().set(DefaultNavigatorNode.TITLE_NAME, "Start"); addNode(rootNode); JellyContext jc = new JellyContext(); jc.setVariable(getClass().getName(), this); jc.registerTagLibrary("http://waterview.cyclopsgroup.com/navigator", new NavigatorTagLibrary()); for (Enumeration en = getClass().getClassLoader() .getResources("META-INF/cyclopsgroup/waterview-navigation.xml"); en.hasMoreElements();) { URL resource = (URL) en.nextElement(); getLogger().info("Reading navigation from " + resource); jc.runScript(resource, XMLOutput.createDummyXMLOutput()); } populateNode(rootNode); }
From source file:com.cyclopsgroup.waterview.jelly.valves.DeterminePageValve.java
private Page loadPage(Script script, JellyEngine jellyEngine) throws JellyTagException { JellyContext jc = new JellyContext(jellyEngine.getGlobalContext()); script.run(jc, XMLOutput.createDummyXMLOutput()); return (Page) jc.getVariable(Page.NAME); }