Re: T4 Custom Component Questions
I did see them, but didn't see how to include non-JavaScript parts without overriding @Shell. I'd like to be able to find the parent Shell and instruct it to add the extras. The issue with @Script is I can't seem to figure out how to read files that are NOT in the class path. If I move my file into the class path, then I get /WEB-INF/myscript.js as the script src which the browser can't read, since WEB-INF is protected. Seems like Tapestry should make that into an Asset or something, but doesn't. -Norman On Oct 9, 2007, at 7:01 PM, andyhot wrote: Well, you can always hack around Shell, e.t.c., but ... I guess you haven't noticed those: http://tapestry.apache.org/tapestry4.1/apidocs/org/apache/tapestry/ html/Shell.html#includeAdditionalContent(java.lang.String) and http://tapestry.apache.org/tapestry4.1/components/general/style.html and even http://tapestry.apache.org/tapestry4.1/components/general/ shell.html (the delegate parameter) Ken nashua wrote: Here's what you'll see in the markup... !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; script type=text/javascriptdjConfig = {baseRelativePath:/ assets/static/ dojo-0.4.3/,preventBackButtonFix:false,parseWidgets:false,local e:en} /script script type=text/javascript src=/assets/static/dojo-0.4.3/ dojo.js/scriptscript type=text/javascript src=/assets/ static/dojo-0.4.3/dojo2.js/script script type=text/javascript dojo.registerModulePath(tapestry, /assets/static/tapestry); /script script type=text/javascript src=/assets/static/tapestry/ core.js/script script type=text/javascript dojo.require(tapestry.namespace); tapestry.requestEncoding='UTF-8'; /script !-- Application: trails -- !-- Page: Home -- !-- Generated: Tue Oct 09 18:38:01 EDT 2007 -- html head meta name=generator content=Tapestry Application Framework, version 4.1.3 / titleBest WEB Application on the planet!/title link rel=stylesheet type=text/css title=don't select href=/ styles/tapestryskin/theme.css / style type=text/css !-- Checkout these Custom HEAD widget...Style Overrides -- body { padding: 5; margin: 5; background: #fff url( /BlobService.svc? class=org.trails.demo.AdminLayoutcontentType=image/ giffileName=backgd-original.gifid=1property=background ) top left repeat; } div#main { } div#splash { background: #fff url( /BlobService.svc? class=org.trails.demo.AdminLayoutcontentType=image/ jpegfileName=bae.parts.splash.jpgid=1property=splash ) top left no-repeat; } div#page { } /style /head body id=Body script type=text/javascript!-- dojo.require(tapestry.widget.Widget); dojo.require(dojo.widget.*); dojo.require(dojo.html); // --/script div id=page !-- header segment #1 -- a id=PageLink href=/Home.page div id=header Best regards Ken in nashua From: [EMAIL PROTECTED] To: users@tapestry.apache.org Subject: Re: T4 Custom Component Questions Date: Tue, 9 Oct 2007 18:15:03 -0400 Hi Norm, Below is text from a CustomHead I wrote. It does header/splash/ icon images for appfuse css-framework. Integrated to trails features I developed of course. It will give you some insights for the shell derivative. I am a trails developer. So anything trails you might want to tailor. Can't help you with the menu. Best regards Ken in nashua Customhead.java - package org.trails.demo.components; import java.util.Date; import java.util.Iterator; import org.apache.hivemind.HiveMind; import org.apache.tapestry.IAsset; import org.apache.tapestry.IMarkupWriter; import org.apache.tapestry.IPage; import org.apache.tapestry.IRender; import org.apache.tapestry.IRequestCycle; import org.apache.tapestry.IScript; import org.apache.tapestry.Tapestry; import org.apache.tapestry.annotations.Asset; import org.apache.tapestry.annotations.ComponentClass; import org.apache.tapestry.annotations.InjectObject; import org.apache.tapestry.annotations.InjectScript; import org.apache.tapestry.annotations.InjectState; import org.apache.tapestry.annotations.Parameter; import org.apache.tapestry.coerce.ObjectArrayToIteratorConverter; import org.apache.tapestry.engine.ILink; import org.apache.tapestry.html.Shell; import org.apache.tapestry.json.IJSONWriter; import org.apache.tapestry.spec.IApplicationSpecification; import org.trails.component.blob.BlobDownloadService; import org.trails.component.blob.TrailsBlobAsset; import org.trails.demo.AdminLayout; /** * Background Usage... * * html jwcid=@Shell title=Trails stylesheet=ognl:assets.stylesheet * * The html tag is basically the shell to a page. It encompasses headbody * * @Shell is a tapestry component that intercepts html parameters and renders *according to it's semantics. We can do whatever we like
T4 Custom Component Questions
I'm writing a custom component that implements a highly specific menu / dashboard display for my application. Previously this was done via JSP files included into each page. To implement this in Tapestry, I need to generate the HTML for the body of the menu (done via the component template) and I need to add stuff to the Shell component's head section or right after it (to include the JavaScript files, CSS files and some other inline definitions) and then right at the end of the Body (to start a countdown timer in JavaScript.) How does one do this? Norman Franke ASD, Inc. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T4 Custom Component Questions
Hi Norm, Below is text from a CustomHead I wrote. It does header/splash/icon images for appfuse css-framework. Integrated to trails features I developed of course. It will give you some insights for the shell derivative. I am a trails developer. So anything trails you might want to tailor. Can't help you with the menu. Best regards Ken in nashua Customhead.java - package org.trails.demo.components; import java.util.Date; import java.util.Iterator; import org.apache.hivemind.HiveMind; import org.apache.tapestry.IAsset; import org.apache.tapestry.IMarkupWriter; import org.apache.tapestry.IPage; import org.apache.tapestry.IRender; import org.apache.tapestry.IRequestCycle; import org.apache.tapestry.IScript; import org.apache.tapestry.Tapestry; import org.apache.tapestry.annotations.Asset; import org.apache.tapestry.annotations.ComponentClass; import org.apache.tapestry.annotations.InjectObject; import org.apache.tapestry.annotations.InjectScript; import org.apache.tapestry.annotations.InjectState; import org.apache.tapestry.annotations.Parameter; import org.apache.tapestry.coerce.ObjectArrayToIteratorConverter; import org.apache.tapestry.engine.ILink; import org.apache.tapestry.html.Shell; import org.apache.tapestry.json.IJSONWriter; import org.apache.tapestry.spec.IApplicationSpecification; import org.trails.component.blob.BlobDownloadService; import org.trails.component.blob.TrailsBlobAsset; import org.trails.demo.AdminLayout; /** * Background Usage... * * html jwcid=@Shell title=Trails stylesheet=ognl:assets.stylesheet * * The html tag is basically the shell to a page. It encompasses headbody * * @Shell is a tapestry component that intercepts html parameters and renders *according to it's semantics. We can do whatever we like in * @Shell according to it's defined parameters. * * This component is an extension to * @Shell. We instrument additional features with the main purpose of rendering * a custom head * * In short...This guy reaches into the database and applies logo, header and * background to default css within the html shell. internally, tedius * renderings will occur to override specific css-framework fragments and * styles. * * @author kenneth.colassi[EMAIL PROTECTED] * */ @ComponentClass(allowBody = true, allowInformalParameters = true) public abstract class CustomHead extends Shell { @InjectState(adminLayout) public abstract AdminLayout getLayout(); public abstract void setLayout(AdminLayout layout); @InjectObject(service:trails.core.BlobService) public abstract BlobDownloadService getDownloadService(); private static final String generatorContent = Tapestry Application Framework, version + Tapestry.VERSION; @Asset(/js/dojo-0.4.3/dojo.js) public abstract IAsset getDefaultDojoSource(); @Asset(/dojo-0.4.3/) public abstract IAsset getDefaultDojoPath(); @Asset(/tapestry/core.js) public abstract IAsset getDefaultTapestrySource(); @Asset(/tapestry/) public abstract IAsset getDefaultTapestryPath(); @Asset(/styles/tapestryskin/theme.css) public abstract IAsset getTheme(); /** * Injected via jwc - readonly, yes that means no setter */ public abstract IApplicationSpecification getApplicationSpecification(); /** * Injected via jwc - readonly, yes that means no setter */ @InjectScript(CustomHead.script) public abstract IScript getScript(); @Parameter(required = true, cache = true) public abstract IAsset getStylesheet(); public abstract void setStylesheet(IAsset stylesheet); @Parameter(required = true, cache = true) public abstract String getTitle(); public abstract void setTitle(String title); public abstract IRender getDelegate(); public abstract IRender getAjaxDelegate(); public void renderComponent(IJSONWriter writer, IRequestCycle cycle) { } @Override protected void prepareForRender(IRequestCycle cycle) { getLayout(); super.prepareForRender(cycle); } @Override protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) { long startTime = 0; boolean rewinding = cycle.isRewinding(); if (!rewinding) { startTime = System.currentTimeMillis(); writeDocType(writer, cycle); IPage page = getPage(); writer.comment(Application: + getApplicationSpecification().getName()); writer.comment(Page: + page.getPageName()); writer.comment(Generated: + new Date()); writer.begin(html); renderInformalParameters(writer, cycle); writer.println(); writer.begin(head); writer.println(); writer.beginEmpty(meta); writer.attribute(name, generator); writer.attribute(content, generatorContent);
RE: T4 Custom Component Questions
Here's what you'll see in the markup... !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; script type=text/javascriptdjConfig = {baseRelativePath:/assets/static/dojo-0.4.3/,preventBackButtonFix:false,parseWidgets:false,locale:en} /script script type=text/javascript src=/assets/static/dojo-0.4.3/dojo.js/scriptscript type=text/javascript src=/assets/static/dojo-0.4.3/dojo2.js/script script type=text/javascript dojo.registerModulePath(tapestry, /assets/static/tapestry); /script script type=text/javascript src=/assets/static/tapestry/core.js/script script type=text/javascript dojo.require(tapestry.namespace); tapestry.requestEncoding='UTF-8'; /script !-- Application: trails -- !-- Page: Home -- !-- Generated: Tue Oct 09 18:38:01 EDT 2007 -- html head meta name=generator content=Tapestry Application Framework, version 4.1.3 / titleBest WEB Application on the planet!/title link rel=stylesheet type=text/css title=don't select href=/styles/tapestryskin/theme.css / style type=text/css !-- Checkout these Custom HEAD widget...Style Overrides -- body { padding: 5; margin: 5; background: #fff url( /BlobService.svc?class=org.trails.demo.AdminLayoutcontentType=image/giffileName=backgd-original.gifid=1property=background ) top left repeat; } div#main { } div#splash { background: #fff url( /BlobService.svc?class=org.trails.demo.AdminLayoutcontentType=image/jpegfileName=bae.parts.splash.jpgid=1property=splash ) top left no-repeat; } div#page { } /style /head body id=Body script type=text/javascript!-- dojo.require(tapestry.widget.Widget); dojo.require(dojo.widget.*); dojo.require(dojo.html); // --/script div id=page !-- header segment #1 -- a id=PageLink href=/Home.page div id=header Best regards Ken in nashua From: [EMAIL PROTECTED] To: users@tapestry.apache.org Subject: Re: T4 Custom Component Questions Date: Tue, 9 Oct 2007 18:15:03 -0400 Hi Norm, Below is text from a CustomHead I wrote. It does header/splash/icon images for appfuse css-framework. Integrated to trails features I developed of course. It will give you some insights for the shell derivative. I am a trails developer. So anything trails you might want to tailor. Can't help you with the menu. Best regards Ken in nashua Customhead.java - package org.trails.demo.components; import java.util.Date; import java.util.Iterator; import org.apache.hivemind.HiveMind; import org.apache.tapestry.IAsset; import org.apache.tapestry.IMarkupWriter; import org.apache.tapestry.IPage; import org.apache.tapestry.IRender; import org.apache.tapestry.IRequestCycle; import org.apache.tapestry.IScript; import org.apache.tapestry.Tapestry; import org.apache.tapestry.annotations.Asset; import org.apache.tapestry.annotations.ComponentClass; import org.apache.tapestry.annotations.InjectObject; import org.apache.tapestry.annotations.InjectScript; import org.apache.tapestry.annotations.InjectState; import org.apache.tapestry.annotations.Parameter; import org.apache.tapestry.coerce.ObjectArrayToIteratorConverter; import org.apache.tapestry.engine.ILink; import org.apache.tapestry.html.Shell; import org.apache.tapestry.json.IJSONWriter; import org.apache.tapestry.spec.IApplicationSpecification; import org.trails.component.blob.BlobDownloadService; import org.trails.component.blob.TrailsBlobAsset; import org.trails.demo.AdminLayout; /** * Background Usage... * * html jwcid=@Shell title=Trails stylesheet=ognl:assets.stylesheet * * The html tag is basically the shell to a page. It encompasses headbody * * @Shell is a tapestry component that intercepts html parameters and renders *according to it's semantics. We can do whatever we like in * @Shell according to it's defined parameters. * * This component is an extension to * @Shell. We instrument additional features with the main purpose of rendering * a custom head * * In short...This guy reaches into the database and applies logo, header and * background to default css within the html shell. internally, tedius * renderings will occur to override specific css-framework fragments and * styles. * * @author kenneth.colassi[EMAIL PROTECTED] * */ @ComponentClass(allowBody = true, allowInformalParameters = true) public abstract class CustomHead extends Shell { @InjectState(adminLayout) public abstract AdminLayout getLayout(); public abstract void setLayout(AdminLayout layout); @InjectObject(service:trails.core.BlobService) public abstract BlobDownloadService getDownloadService(); private static final String generatorContent = Tapestry Application Framework, version + Tapestry.VERSION; @Asset(/js/dojo-0.4.3
Re: T4 Custom Component Questions
Well, you can always hack around Shell, e.t.c., but ... I guess you haven't noticed those: http://tapestry.apache.org/tapestry4.1/apidocs/org/apache/tapestry/html/Shell.html#includeAdditionalContent(java.lang.String) and http://tapestry.apache.org/tapestry4.1/components/general/style.html and even http://tapestry.apache.org/tapestry4.1/components/general/shell.html (the delegate parameter) Ken nashua wrote: Here's what you'll see in the markup... !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; script type=text/javascriptdjConfig = {baseRelativePath:/assets/static/dojo-0.4.3/,preventBackButtonFix:false,parseWidgets:false,locale:en} /script script type=text/javascript src=/assets/static/dojo-0.4.3/dojo.js/scriptscript type=text/javascript src=/assets/static/dojo-0.4.3/dojo2.js/script script type=text/javascript dojo.registerModulePath(tapestry, /assets/static/tapestry); /script script type=text/javascript src=/assets/static/tapestry/core.js/script script type=text/javascript dojo.require(tapestry.namespace); tapestry.requestEncoding='UTF-8'; /script !-- Application: trails -- !-- Page: Home -- !-- Generated: Tue Oct 09 18:38:01 EDT 2007 -- html head meta name=generator content=Tapestry Application Framework, version 4.1.3 / titleBest WEB Application on the planet!/title link rel=stylesheet type=text/css title=don't select href=/styles/tapestryskin/theme.css / style type=text/css !-- Checkout these Custom HEAD widget...Style Overrides -- body { padding: 5; margin: 5; background: #fff url( /BlobService.svc?class=org.trails.demo.AdminLayoutcontentType=image/giffileName=backgd-original.gifid=1property=background ) top left repeat; } div#main { } div#splash { background: #fff url( /BlobService.svc?class=org.trails.demo.AdminLayoutcontentType=image/jpegfileName=bae.parts.splash.jpgid=1property=splash ) top left no-repeat; } div#page { } /style /head body id=Body script type=text/javascript!-- dojo.require(tapestry.widget.Widget); dojo.require(dojo.widget.*); dojo.require(dojo.html); // --/script div id=page !-- header segment #1 -- a id=PageLink href=/Home.page div id=header Best regards Ken in nashua From: [EMAIL PROTECTED] To: users@tapestry.apache.org Subject: Re: T4 Custom Component Questions Date: Tue, 9 Oct 2007 18:15:03 -0400 Hi Norm, Below is text from a CustomHead I wrote. It does header/splash/icon images for appfuse css-framework. Integrated to trails features I developed of course. It will give you some insights for the shell derivative. I am a trails developer. So anything trails you might want to tailor. Can't help you with the menu. Best regards Ken in nashua Customhead.java - package org.trails.demo.components; import java.util.Date; import java.util.Iterator; import org.apache.hivemind.HiveMind; import org.apache.tapestry.IAsset; import org.apache.tapestry.IMarkupWriter; import org.apache.tapestry.IPage; import org.apache.tapestry.IRender; import org.apache.tapestry.IRequestCycle; import org.apache.tapestry.IScript; import org.apache.tapestry.Tapestry; import org.apache.tapestry.annotations.Asset; import org.apache.tapestry.annotations.ComponentClass; import org.apache.tapestry.annotations.InjectObject; import org.apache.tapestry.annotations.InjectScript; import org.apache.tapestry.annotations.InjectState; import org.apache.tapestry.annotations.Parameter; import org.apache.tapestry.coerce.ObjectArrayToIteratorConverter; import org.apache.tapestry.engine.ILink; import org.apache.tapestry.html.Shell; import org.apache.tapestry.json.IJSONWriter; import org.apache.tapestry.spec.IApplicationSpecification; import org.trails.component.blob.BlobDownloadService; import org.trails.component.blob.TrailsBlobAsset; import org.trails.demo.AdminLayout; /** * Background Usage... * * html jwcid=@Shell title=Trails stylesheet=ognl:assets.stylesheet * * The html tag is basically the shell to a page. It encompasses headbody * * @Shell is a tapestry component that intercepts html parameters and renders *according to it's semantics. We can do whatever we like in * @Shell according to it's defined parameters. * * This component is an extension to * @Shell. We instrument additional features with the main purpose of rendering * a custom head * * In short...This guy reaches into the database and applies logo, header and * background to default css within the html shell. internally, tedius * renderings will occur to override specific css-framework fragments and * styles. * * @author kenneth.colassi[EMAIL PROTECTED] * */ @ComponentClass(allowBody = true, allowInformalParameters = true) public