Am 09.10.2011 19:42, schrieb Antonio Petrelli:
> However there is a more elegant way to pass attributes.
> In list.jsp:
>
> <c:forEach var="i" begin="1" end="10" step="1">
> <li><em>Loop #${i}:</em>
> <t:insertAttribute name="dynamic">
> <t:putAttribute name="var" value="${i}" />
> </t:insertAttribute></li>
> </c:forEach>
>
> Then the "put-attribute" in the definition XML file is no more needed.
>
Thanks for your answer!
I know, that I could use <t:insertAttribute> to solve the problem in my
simplified example. But I could not use it, to achieve, what I really
want to do.
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!
Am 09.10.2011 19:42, schrieb Antonio Petrelli:
The problem is that list.jsp and dynamic.jsp are two different pages. Just
like<jsp:include> paged-scope attributes in including page are not visible
in the included one (and viceversa).
Yes, that's true!
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.
Apparently the EL sees the environment of that moment, because it picks
up the changed variable i, when I push that variable to request scope.
But perhaps the EL does not see the environment of that page!
The later would - in my view - be a bug, or, to put it in other words:,
it would be nice feature to have, if the EL would see the page-scope
variables or even the nested scoped variables of the moment, where it is
inserted. Because, then the EL in the definition would behave exactly
the same way, as the EL in your solution above!
Greetings Kai