Re: Access to BTemplate on request phase ?

franck routier <[email protected]>
Newsgroups gmane.comp.java.enhydra.barracuda.general
Message-ID <[email protected]>
Diez B. Roggisch wrote:

>Yes and no - sure, you can always process the dom, and then get the 
>directives. But no, its not directly supported.
>  
>
Probably quite expansive, isn't it ?

>Weeeelllll - I don't know much about your app, and not much about hibernate 
>eihter. But let me guess - the generic attribute access pattern boils down to 
>a (hash)map? Thats what such things usually are. So for now, I assume that.
>
In fact Hibernate uses Javabeans to persist objects.
So I don't have hashmap at first, and I wrote a base class implementing 
generic access using reflection. For example, I do :

myDataObject.getStringByKey(mytoken) and my data object bean returns his 
getKey() value.

>My approach would be a iterative model - every entry in the list of values 
>iterated over is a name/value-pair. And the list is created by parsing the 
>request-parameters and then queriying the objects. Thus you don't need to 
>alter any directives and would still have full flexibility on this.
>
So of course I use an Iterative Model to feed BTemplate. So the cycle is :
I get the request parameters, I query the business tier (session ejb 
using hibernate) and get a collection of data objects extending my base 
data object.
Then I iterate throught the collection in an iterative model, and simply 
implement the getItem(key) method by returning 
myCurrentDataObject.getStringByKey(key).

So all this is working.

Now my problem is that I would like to let the "poweruser" change the 
layout of the screen, and choose the attributes she wants to have
(some of them would be compulsory of course). My database will have 
quite a lot of fields for an entity, and not every user will use them 
all (but two users will use differents fields).

So I could just stay with my current  application and BTempalte will do 
the rest. That's quite cool and flexible already.

But say I have 50 fields in a (database) table, and the user only wants 
to use 10 of them (I don't know which one, only the consultants can 
tell, at runtime maybe :-)
What would be cool would be, in the request phase, to know which fields 
are required, then to query only those fields (maybe also get hibernate 
to retrieve only those fields from the database) and only return a 
partial dataobject to the web tier (saving 40 objects instanciations for 
unused attributes, bandwith at serialization, and maybe database access).

So this is my question : how do I get the required fields ? My first 
idea was to get it from BTemplate at the REQ phase, ... but as you said, 
this is not standard, and parsing the dom might make me loose all the 
time I gain by tayloring my request and dataobject...

Is all this a little bit more clear ?
What do you think of it ?

Regards,

Franck Routier
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.