2011/10/10 Kai <[email protected]>

> Am 10.10.2011 10:11, schrieb Antonio Petrelli:
>
>  2011/10/10 Kai<[email protected]>
>>
>>  In my real problem, list.jsp ist much more complex and I want to reuse it
>>> on several pages. The only part of list.jsp which changes from page to
>>> page
>>> is the part in dynamic.jsp, which is bind in in the definition.
>>>
>>> Therefore I cannot "hartcode" the Template with a<t:insertAttribute>-Tag
>>> inside the list.jsp-Template. Because then, I would have to copy list.jsp
>>> for every page and would end up with several versions of list.jsp, which
>>> only differ in this one<t:insertAttribute>-Tag. That would not be good,
>>> because I would have to edit several nearly identical copies, if I want
>>> to
>>> change list.jsp later on!
>>>
>>>
>> Try to explain your use case further, maybe there are better solutions
>> (e.g.
>> ViewPreparer).
>>
>>  I am programming a picture-album.
>
> There are severale pages, which are listing a set of pictures. For example,
> an import, a selected set of pictues, a picture-story, ... The markup for
> these picture-listings basically is the same on all these pages. Therefore,
> I would like to use one single template for that markup (the list.jsp in my
> simplified example).
>
> But on every page-type, there are different Links for further actions
> beneath each listed picture. On the import-page there would be a
> rotate-link. On the page that lists selected pictures, there would be the
> links remove, move up and move down. On the picture-story-page there would
> be no links at all... Each set of links is a different sub-template (the
> dynamic.jsp in my simplified example).
>
> Hence, I am looking for a way to embed different templates inside the
> base-template.
>
> A perfect match for one base-definition, which uses list.jsp as template,
> and a set of special definitions, which inherit from the base definition and
> overwrite an attribute (the attribute dynamic in my example), to insert an
> inner template with the specific links.
>
> But then, on each insertion of that inner template, the inner template has
> to know the actual picture of the set of pictures, the outer template is
> iterating over.
>
> That would work perfectly, if I would use <t:insertAttribute> in the outer
> template, as you have shown in your last mail. But I cannot do that, because
> I would need several versions of the outer template then. One for each
> specialised set of links, because for each set of specialised links, another
> template has to be included!
>
> Hence, I tried to pick up the variable with an EL-Expression in the
> definition...


Very interesting and challenging question.
I suppose that these "dynamic" pieces have something in common (e.g. an id,
an URL of the picture). This data can be passed as an attribute. The rest,
i.e. the specialized links/operations that you do on each picture, should be
computed internally in each piece, is it right?
If yes, list.jsp can be reused anywhere (I mean for any kind of picture
template), as long as you identify all the needed data that each piece
needs, and pass them always, even if they don't use it.



> But I have understand, that the EL in the XML-definition is evaluated, when
>>> the definition is inserted. In case of the nested anonymous definition,
>>> that
>>> would happen while the forEach-Loop is renderd.
>>> Therefore I had concluded that the EL sees the environment of that moment
>>> and that page.
>>>
>>>
>> It's true that EL is evaluated when the inserted page is rendered, but the
>> *value* of the attribute is in the page that includes it.
>>
>>  Oh.
>
> I had expected, that the EL would behave in the same way it behaves, when
> it is written in the <t:insertAttribute>-Tag like in your last mail...
>

No, in my example, the EL expression is evaluated then passed to the
attribute. In your example, the attribute is rendered and, when rendering,
the EL expression is evaluated (to nothing).

Antonio

Reply via email to