You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tiles.apache.org by Baptiste GAILLARD <ba...@gmail.com> on 2007/10/11 14:57:29 UTC
Struts links in tiles item
Hi, i'm trying to build a menu template using tiles, in my tiles.xml
file I have:
<definition name="leftMenu" extends="generalMenu"
template="/pages/components/linkmenu.jsp">
<put-list-attribute name="leftMenuLinks">
<item value="List Users" link="??" />
<item value="New User" link="??" />
<item value="Datatable Test" link="??" />
</put-list-attribute>
</definition>
The problem is in the link attribut, I want to insert a '<s:url
action=""/>' or '<s:url value=""/>' markup but I don't how to do.
In fact I want to transform this:
<table class="linkmenu">
<tr>
<th class="linkmenu">Title</th>
</tr>
<tr>
<td><a href="<s:url action="list" />">list users</a></td>
</tr>
<tr>
<td><a href="<s:url value="/pages/index.jsp" />">new
user</a></td>
</tr>
<tr>
<td><a href="<s:url value="/pages/index.jsp" />">test
datatable</a></td>
</tr>
</table>
with that :
<table class="linkmenu">
<tr>
<th class="linkmenu">Title</th>
</tr>
<tiles:importAttribute name="leftMenuLinks" />
<c:forEach var="item" items="${leftMenuLinks}">
<tr>
<td><a href="${item.link}"
/>">${item.value}</a></td>
</tr>
</c:forEach>
</table>
So, how can I do that ?
Thanks.
Baptiste GAILLARD.
Re: Struts links in tiles item
Posted by Baptiste GAILLARD <ba...@gmail.com>.
Antonio Petrelli a écrit :
> 2007/10/12, Baptiste GAILLARD <ba...@gmail.com>:
>
>> Ok, thanks, now I want to retrieve the size of the attribut list, I've
>> tried ${leftMenuLinks.size} but it doesn't work, How can I do that ?
>>
>
>
>
> This is a question for JSTL:
> http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/fn/length.fn.html
>
> HTH
> Antonio
>
>
Ok, thank you !
Baptiste.
Re: Struts links in tiles item
Posted by Antonio Petrelli <an...@gmail.com>.
2007/10/12, Baptiste GAILLARD <ba...@gmail.com>:
>
> Ok, thanks, now I want to retrieve the size of the attribut list, I've
> tried ${leftMenuLinks.size} but it doesn't work, How can I do that ?
This is a question for JSTL:
http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/fn/length.fn.html
HTH
Antonio
Re: Struts links in tiles item
Posted by Baptiste GAILLARD <ba...@gmail.com>.
Antonio Petrelli a écrit :
> 2007/10/11, Antonio Petrelli <an...@gmail.com>:
>
>> <td><a href="<s:url action="list"
>> />">${item.value}</a></td>
>>
>
>
>
> Sorry, I meant:
>
> <td><a href="<s:url action="${item.link}"/>">${item.value}</a></td>
>
> Antonio
>
>
Ok, thanks, now I want to retrieve the size of the attribut list, I've
tried ${leftMenuLinks.size} but it doesn't work, How can I do that ?
Thanks.
Baptiste
Re: Struts links in tiles item
Posted by Antonio Petrelli <an...@gmail.com>.
2007/10/11, Antonio Petrelli <an...@gmail.com>:
>
> <td><a href="<s:url action="list"
> />">${item.value}</a></td>
Sorry, I meant:
<td><a href="<s:url action="${item.link}"/>">${item.value}</a></td>
Antonio
Re: Struts links in tiles item
Posted by Antonio Petrelli <an...@gmail.com>.
2007/10/11, Baptiste GAILLARD <ba...@gmail.com>:
> <item value="List Users" link="<s:url action= "
> list " / >" />
You cannot put JSP code in a string and pretend it to be interpreted.
It remains simply a string!
In this case you can write:
<item value="List Users" link="list" />
and in your JSP:
<c:forEach var="item" items="${leftMenuLinks}">
<tr>
<td><a href="<s:url action="list"
/>">${item.value}</a></td>
</tr>
</c:forEach>
HTH
Antonio
Re: Struts links in tiles item
Posted by Baptiste GAILLARD <ba...@gmail.com>.
Antonio Petrelli a écrit :
> 2007/10/11, Baptiste GAILLARD <ba...@gmail.com>:
>
>> <c:forEach var="item" items="${leftMenuLinks}">
>> <tr>
>> <td><a href="${item.link}"
>> />">${item.value}</a></td>
>> </tr>
>> </c:forEach>
>>
>
> Doesn't it work? It seems ok to me.
>
> Antonio
>
>
The problem isn't in the JSP page in fact, but in the tiles.xml.
I've tried that:
<definition name="leftMenu" extends="generalMenu"
template="/pages/components/linkmenu.jsp">
<put-list-attribute name="leftMenuLinks">
<item value="List Users" link="<s:url action= "
list " / >" />
<item value="New User" link="<s:url action= "
list " / >" />
<item value="Datatable Test" link="<s:url action=
" list " / >" />
</put-list-attribute>
</definition>
but this doesn't work
what I want is :
<definition name="leftMenu" extends="generalMenu"
template="/pages/components/linkmenu.jsp">
<put-list-attribute name="leftMenuLinks">
<item value="List Users" link="<s:url action="list" / >" />
<item value="New User" link="<s:url action= "list" />" />
<item value="Datatable Test" link="<s:url action= "list"
/ >" />
</put-list-attribute>
</definition>
but this isn't valid as I have double quotes inside double quotes (link
attribut of item markup), with simple quotes inside double quotes and
double quotes inside simple quotes it doesn't work either.
Do you understand what I want to do here ?
Thanks,
Baptiste
Re: Struts links in tiles item
Posted by Antonio Petrelli <an...@gmail.com>.
2007/10/11, Baptiste GAILLARD <ba...@gmail.com>:
> <c:forEach var="item" items="${leftMenuLinks}">
> <tr>
> <td><a href="${item.link}"
> />">${item.value}</a></td>
> </tr>
> </c:forEach>
Doesn't it work? It seems ok to me.
Antonio