On May 18, 2012, at 7:02 AM, Adam Heath wrote:

> Imho, we should *not* be calling into the delegator inside freemarker 
> templates.  Templates should not be tied to the backend *at all*.  They 
> should only deal with 100% completely generic collection objects. Because 
> they are currently tied to the delegator, this makes it *impossible* to have 
> a separate web-frontend, that isn't tied to ofbiz at all.

I agree on the general rule; unfortunately there are exceptions where enforcing 
this rule is too problematic; however I agree that the practice of calling the 
delegator API from FM is used much more than it should.
Apart from moving data preparation code to data preparation scripts where 
possible, we could also define a FM transform to implement these calls and this 
will protect the access to the delegator because in the transform we would 
perform all the necessary null checks etc...
The risk is to end up with a big sets of transforms that re-implement the 
delegator API, but we could start by implementing the calls that are currently 
clearly broken (findByAnd) and then create new ones (or refactor existing code) 
*before* you will refactor other delegator methods.
In this way we will have a temp fix (waiting for the official fix from FM) and 
also a better implementation of templates (that execute calls to delegator only 
thru a transform)

Kind regards,

Jacopo

Reply via email to