RE: using templates with XMLC
"Christian Cryder" <[email protected]>
| Newsgroups | gmane.comp.java.enhydra.barracuda.general |
|---|---|
| Message-ID | <[email protected]> |
Sure. Its easy.
As an example, we have a simple chunk of markup in an .html file that
defines a "header" that appears in most of our pages. The designer
edits/manipulates this file.
We have a mockup.ssi ant target that process *.html files to create .ssi
files from them(using the org.enhydra.barracuda.taskdefs.GenerateSSIs
taskdef). In this particular case, header_logged_in.ssi is created. Now, we
also have simple .shtml files (one for each .html file usually) that refer
to these .ssi - ie. they reference all the .ssi files needed to make up each
page in the app.
The build process then "deploys" these .shtml files (using the
org.enhydra.barracuda.taskdefs.CopyAndReplace) by copying them along with
the .ssi files into the XMLC compilation directory - when it does this it
resolves all the .ssi files, and renames the .shtml files to .html. So the
end result is that we have a series of "generated" .html files sitting in
the XMLC source directory that are the result of all these .ssis being
merged into the .shtml files. Then XMLC compiles these merged .html files
into XMLC objects, and the code can use them.
So what we have this far is a single source (one chunk of HTML markup store
in an original .html file, that is used to generate an .ssi, which is then
automatically merged into the .shtml files - and the results act as the
"source" for XMLC to create the templates the Java code will be using.
With me so far?
Now, when we write the application code, we are going to have different
pieces of app logic for each page. And yet part of every page is going to be
"common" across all the others. What we do then, is create a set of common
models that every event handler has access to. The code looks something like
this:
//add in all the common models, plus a local model
public Object getTemplateModels() {
List models = CommonModels.getBasicModels();
models.add(new ContractHomeModel());
return models;
}
Here CommonModels provides a list of models that are used throughout the app
(including one needed to process directives embedded in the header). I take
that list and simply add in any page specific models that are also needed,
and viola! Its handled!
That's a very quick explanation of how its done, but it really isn't hard at
all.
Hope that answers your question...
Christian
----------------------------------------------
Christian Cryder
Internet Architect, ATMReports.com
Project Chair, BarracudaMVC - http://barracudamvc.org
----------------------------------------------
"Coffee? I could quit anytime, just not today"
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of Matthew Hixson
> Sent: Monday, June 09, 2003 5:00 PM
> To: [email protected]
> Subject: [Barracuda] using templates with XMLC
>
>
> I've been becoming more and more interested in using XMLC to replace
> our wad o'JSP and custom tags. One thing I like about Struts' custom
> tags is the templating system. Its very nice to be able to make a
> change to a template .jsp and have it applied across the entire site.
> One problem with maintaining static HTML pages is that you don't have
> the HTML template to help you out so you have to make changes by hand
> to every page in the site. I'm wondering if this is also a problem
> with XMLC. It seems that XMLC wouldn't have any trouble stuffing
> values into a template, but what about the HTML people working on the
> pages? Do they still need to make changes to each page to see them
> when developing? If so is there a solution to this problem?
> Any thoughts?
> Thanks,
> -Wannabe XMLC user
>
> _______________________________________________
> Barracuda mailing list
> [email protected]
> http://barracudamvc.org/lists/listinfo/barracuda