I'm working on a set of classes that generate the templates for pages
"on-the-fly" using a configurable layout.
To do that I have to make it work without .html files and without
.page files. Here is what i've done:
1) To create Specifications without specification files, I create a
class that implements ISpecificationResolverDelegate, and then I
register in the .application file a extension in this way:
<extension name="org.apache.tapestry.specification-resolver-delegate"
class="fullPackage.MyDelegator" />
MyDelegator has to implement a method named findPageSpecification()
which returns an IComponentSpecification. Here is an example of this
method:
public synchronized final IComponentSpecification
findPageSpecification( IRequestCycle cycle, INamespace
namespace, String simplePageName) {
Class pageClass =
aMethodWichResolvesPageClassBasingOnPageName(simplePageName);
IComponentSpecification pageSpec = new ComponentSpecification();
pageSpec.setComponentClassName(pageClass.getName());
IResourceLocation applicationLocation = namespace.getSpecificationLocation();
pageSpec.setSpecificationLocation(location);
return pageSpec;
}
2) To create templates without files, I implemented the
ITemplateSourceDelegate and register ed it in .application file like
this:
<extension name="org.apache.tapestry.template-source-delegate"
class="fullPackage.MyTemplateDelegate" />
Inside the method of MyTemplateDelegate you have to create a Template
and parse it using org.apache.tapestry.parse.TemplateParser.
One inconvinient I had was thath i18n didn't find .properties files,
so i have to create an extrange ResourceLocation subclass wich has
different names and paths.
It seems to work pretty well, and I'm happy to see pages drawing
themselves, I really don't enjoy writing HTML divs and tables to
scatter components in the page.
On 4/26/05, Paul Jackson <[EMAIL PROTECTED]> wrote:
> In your "project.application" file you can specify the following class
> which will be default class for your pages. That way you won't have to
> do it for the simple pages.
>
> <application name="Fee Billing Application" ...>
> ...
> <property name="org.apache.tapestry.default-page-class"
> value="com.meridianinfo.common.tap.BasePage"/>
> ...
> </application>
>
> In our application of about 90 pages we do have about 5 pages which do
> only specify the page class only.
>
> Paul Jackson
> Ph +61 (0)2 9256 5564
> Meridian Informatics (www.meridianinfo.com)
> Custom Software for Agile Financial Services
>
> -----Original Message-----
> From: Howard Lewis Ship [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, 26 April 2005 9:23 PM
> To: Tapestry users
> Subject: Re: Anyway to get rid of the .page file?
>
> Tapestry 4.0 includes a new mechanism whereby it searches a list of
> packages
> for your page or component classes. This is used if you omit the page
> specification, or omit the class attribute from the page specification.
> So
> you can go a bit further without a page specification, but it's still
> quite
> recommended!
>
> On 4/25/05, Todd O'Bryan <[EMAIL PROTECTED]> wrote:
> >
> > You're going to want the .page file.
> >
> > Unless you have such a simplistic website that you don't really need
> > Tapestry in the first place, you will need properties on your pages,
> > either to hold information that people enter in forms or to hold
> > information that you've passed in to the page from elsewhere to
> > display. You declare these in the .page file.
> >
> > Todd
> >
> > On Apr 25, 2005, at 10:18 AM, Hao Chen wrote:
> >
> > > Hi, all
> > >
> > > I am new to Tapestry and just started playing with Tapestry 3.1. I
> > > like defining all component attributes inside the .html file. But
> > > because the page class is defined inside the .page file using
> > > <page-specification class="...">, I cannot get rid of the .page file
> > > completely. So I have provide a one-line .page file for every page.
> > > This is really cumbersome.
> > >
> > > I wonder if there is anyway to eliminate the .page file? Can we
> define
> > > some HTML directive and put the page class information inside the
> > > .html file?
> > >
> > > Thanks,
> > > - Hao
> > >
> > >
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail:
> [EMAIL PROTECTED]
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
> --
> Howard M. Lewis Ship
> Independent J2EE / Open-Source Java Consultant
> Creator, Jakarta Tapestry
> Creator, Jakarta HiveMind
>
> Professional Tapestry training, mentoring, support
> and project work. http://howardlewisship.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]