Leszek Gawron wrote:
Daniel Fagerstrom wrote:

Leszek Gawron wrote:
<snip/>

I have commited an initial JXTemplateGenerator to o.a.c.template.jxtg.JXTemplateGenerator and moved Jonas' templating proposal to o.a.c.template.v2 package.

Please review.



Nice!

Don't have time to review in any detail right now. I added some basic test cases. Two of them that tries to test that the cocoon object is accesible from expressions are faulty, I didn't get them to work even with the original JXTG, any idea about what goes wrong?



instead of:

<root>
  protocol: ${cocoon.request.protocol}

  <item attr="** ${parameters.test} **">
    Some text
  </item>

</root>


you should do:

<root>
  protocol: ${request.protocol}

  <item attr="** ${cocoon.parameters.test} **">
    Some text
  </item>

</root>


I. regarding the protocol property:

JXTemplateGenerator.setContexts:
There is a "request" registered populated from:
final Request request = ObjectModelHelper.getRequest(objectModel);

and there is cocoon.request registered populated from:
cocoon.put("request", FOM_JavaScriptFlowHelper
                           .getFOM_Request(objectModel));

It itches me that cocoon.request will only work when working with flow controller. I do not know flow internals to fix that.

II. regarding parameters property:
you have cocoon.parameters:
cocoon.put("parameters", Parameters.toProperties(parameters));

and top level "parameters":
map.put("parameters", parameters);

Second case does not perform the conversion and this is the problem. I am commiting the fix right now.
Got me thinking. Maybe this is intentional? If it is it surely is not intuitive. Still if I convert both cases to Properties there is no elegant solution to provide a default value:

for parameters:

${parameters.getParameter('test','defaultTest')}

When converted one would have to use:

${parameters.getProperty('test', 'defaultTest')} (which is the current use case for cocoon.parameters).

We have to either use Parameters in both cases or state explicitly in docs that the parameters get converted to Properties for template scope. What do we do?

--
Leszek Gawron                                      [EMAIL PROTECTED]
Project Manager                                    MobileBox sp. z o.o.
+48 (61) 855 06 67                              http://www.mobilebox.pl
mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65

Reply via email to