RE: Re: Bug in BTable

"Christian Cryder" <[email protected]>
Newsgroups gmane.comp.java.enhydra.barracuda.general
Message-ID <[email protected]>
Hi Tim,

You shouldn't ever _have_ to return a BTemplate from the model, if you are
already processing the page using a BTemplate...any child nodes will
automatically be processed using BTemplate delegates that are automatically
created and invoked via TemplateHelper.

> How complex have you all pushed the component model?

Very complex. We haven't encountered anything that it can't really handle
yet.

> TemplateModel (page level model)
>   -> BText (title)
>   -> BList (links)
>      -> BLink
>   -> BList (repeating sections)
>      -> BTemplate (section template)
>        -> BText (section title)
>        -> BList (list of stuff for the section)
>          -> BText (stuff)

Something like this should be totally doable. Nested directives are handled
automatically. I think the only thing that you are thinking of wrongly is
the BTemplate referenced there in the middle. If I read your intent
properly, you really want to pass back a chunk of DOM that is processed
elsewhere (ie. a "component"). We do this all the time...

Now the way that we achieve this is by generating .ssi's...

a) *.html mockups contain chunks of HTML that get extracted to .ssi files
using the the org.enhydra.barracuda.taskdefs.GenerateSSIs taskdef.

b) we have *.shtml files that reference these .ssi files...these are moved
into the XMLC source directory using the
org.enhydra.barracuda.taskdefs.CopyAndReplace taskdef. This effectively
resolves the .shtml references to the .ssi files, sucking the .ssi contents
into the markup template and renaming them as .html

c) these are then compiled into the XMLC objects, which the app uses

d) when we have a screen that uses these objects, there are models specific
to the screen, but there are also "common models" that we want to implement
once and then just reuse to handle these common sections. As an example, if
I have Foo.html, my XMLC object is FooHTML, and my model that processes it
may be something like FooModel. Now, this template also has references to
"common model" directives, like PageModel, CurrentUserModel, etc. These are
all defined in a CommonModels class, which has a method that looks something
like this:

    public static List getReportModels() {
        List models = new ArrayList();
        models.add(new CurrentUserModel());
        models.add(new PageModel());
        models.add(new ReportModel());
        return models;
    }

Now, the RenderFoo event handler extends BTemplateViewHandler, and looks
something like this::

    public Object getTemplateModels() {
        List models = CommonModels.getBasicModels();
        models.add(new FooModel());
        return models;
    }

    public Class getTemplateClass() {return FooHTML.class;}

Does this make sense? What we are effectively doing is using .ssis to inline
all chunks of reusable markup prior to XMLC compilation. Then your code ends
up dealing with one chunk of markup, that just contains references to
different models (some of which are reusable).

Now, if you don't want to do this, there IS a way that your model can
actually return a chunk of markup that should get inlined into the page and
processed for directives, but I don't have a specific example handy. I think
there is one in the Barracuda stuff, but I'd have to go search to find it.

Does this help at all?

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 Tim Dysinger
> Sent: Friday, July 18, 2003 2:06 PM
> To: [email protected]
> Subject: [Barracuda] Re: Bug in BTable
>
>
> Greetings (again),
>
> How complex have you all pushed the component model?  I noticed an email
> from Jim Dow a while back that asked about build custom components.
>
> I have a pretty complex couple of screens to build and so far I have not
> had any luck with build a custom component model for them.
>
> I would like to be able to build the following structure ->
>
> TemplateModel (page level model)
>   -> BText (title)
>   -> BList (links)
>      -> BLink
>   -> BList (repeating sections)
>      -> BTemplate (section template)
>        -> BText (section title)
>        -> BList (list of stuff for the section)
>          -> BText (stuff)
>
> -or-
>
> TemplateModel (page level model)
>   -> BText (title)
>   -> BList (links)
>      -> BLink
>   -> BTemplate (Iterative Model) (repeating sections)
>        -> BText (section title)
>        -> BTemplate (Iterative Model) (list of stuff for the section)
>          -> BText (stuff)
>
> So far I have been able to manually bind any template model to a view and
> it works great, __but__ if I try to return any BTemplate from a
> TemplateModel it blows chunks.  I have seen tidbits of emails on "Nested
> Directives."  Can anyone point me to any examples/pointers?  It seems that
> you cannot return a BTemplate from a TemplateModel.
>
> -Tim
>
>
>
> _______________________________________________
> Barracuda mailing list
> [email protected]
> http://barracudamvc.org/lists/listinfo/barracuda
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.