cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vadim Gritsenko <vadim.gritse...@verizon.net>
Subject Re: Woody template transformer using jx macros
Date Mon, 05 Jan 2004 16:54:54 GMT
Sylvain Wallez wrote:

> Vadim Gritsenko wrote:
>
>> Sylvain Wallez wrote:
>> ....
>>
>>>    <jx:when test="$widget.getWidget("items").size > 0">
>>
>>
>>
>>
>> Thanks for JXTemplateGenerator example. I assume $widget here should 
>> be woody form, which is stored in the request attribute, and 
>> according to [1], method call syntax is a bit different from the 
>> above. So I ended up with:
>>
>>  <jx:when test="getWidget(getAttribute($request, "form"), 
>> "items")/size > 0">
>

Correction:
  <jx:when test="#{getWidget(getAttribute($request, "form"), 
"items")/size > 0}">


>> which actually worked for me, with JXTemplateGenerator. I'm now 
>> puzzled: how yours expression works?
>
>
>
> It doesn't work ;-)
> I wrote it by mimicing what's in Christopher's code without actually 
> testing it.
>
> Reading in more detail the JX implementation of <wt:form-template> and 
> <wt:repeater>, I found that the variable containing the current widget 
> is not "widget" but "ignored"!!
>
> Christopher, can you confirm this? I would be good to have the 
> "widget" or "currentWidget" variable available to crawl the widget 
> tree from any point in the template.


I don't know how to use those macros yet, but yes, "widget" is better 
name than "ignored" :)


>>> The important difference with the WoodyTransformer is that the 
>>> generator has access to the form model and therefore can produce a 
>>> page layout whose content depend on the actual values of this model.
>>
>>
>>
>>
>> I'm worried a bit about performance of such a beastie - macros on top 
>> of interpreted jxpath language executed in interpreted java machine...
>
>
>
> Yep. But this also avoids an additional transformer.
>
>>> The above example is however a bit too simplistic since the same 
>>> result could be achieved with the WoodyTransformer. The jx:when test 
>>> expression would then be something like 
>>> "$woody-form.getWidget("items").size > 0".
>>
>>
>>
>>
>> Now I'm lost. I have not found code in neither 
>> EffectWidgetReplacingPipe nor in WoodyTemplateTransformer which would 
>> implement any jx: functionality, except commented-out translateText 
>> method. What do I miss?
>
>
>
> Maybe I wasn't clear. A "regular" JXTemplate (without Woody macros) 
> can access the form model to dynamically build the form template 
> that's later expanded by WoodyTransformer.
>
> But if we want to implement the repeater example (different layout 
> depending on the repeater size) using this combination, we can do it 
> only for top-level repeaters and not for nested ones, as the iteration 
> on repeaters is handled by the transformer, and JXTemplate can 
> therefore not access the properties of these nested repeaters (unless 
> the JX template implements itself that iteration, but it is then 
> equivalent to the macros).
>
> Hope it's clearer.


Gotcha! So the options are either to use JX Generator + Woody 
Transformer, or JX Generator + Woody Macros library, where macros 
library performs all the stuff transformer was doing before. Just need 
to see what is performance difference (and compare with bare woody 
transformer).

Vadim



Mime
View raw message