how to create menues with tiles2?

View: New views
12 Messages — Rating Filter:   Alert me  

how to create menues with tiles2?

by xbranko :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Following the example at the tutorial page I am not getting the menu rendered. There is no exception, and instead of the menu, I get the iterator control variable displayed.

tiles-def.xml:
  <definition name="menu" template="/Menu.jsp">
    <put-list-attribute name="menu.Attributes">
      <item value="Home page" link="menu.do" />
      <item value="News" link="news.do" />
    </put-list-attribute>
  </definition>

  <definition name="main" template="/main.jsp">
          <put-attribute name="mymenu"    value="menu" />
  </definition>

Menu.jsp:
<%@taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<div align="center">
  <tiles:importAttribute name="menu.Attributes"/>
    <c:forEach var="item" items="${menu.Attributes}">
      <a href="${item.link}">${item.value}</a> |
    </c:forEach>
</div>

What gets rendered on the page:
${item.value} |

Why is this? What am I doing wrong or not setting up correctly?
This is with tiles 2.0.6

Many thanks,
Branko

Re: how to create menues with tiles2?

by Antonio Petrelli-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2008/6/27 xbranko <xbranko@...>:
>      <a href="${item.link}">${item.value}</a> |
>...
> What gets rendered on the page:
> http://localhost:8080/$%7Bitem.link%7D ${item.value}  |

I think that you have EL evaluation turned off, you have to specify at
least Servlet 2.4 version in your web.xml file.

Antonio

Re: how to create menues with tiles2?

by xbranko :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Antonio Petrelli-3 wrote:
I think that you have EL evaluation turned off, you have to specify at
least Servlet 2.4 version in your web.xml file.
According to my web.xml it should be on 2.5:
<web-app id="WebApp_ID"
         xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
         version="2.5">

Is there some other way to turn EL evaluation explicitly?

Branko

Parent Message unknown Re: how to create menues with tiles2?

by Rick Mangi-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You also probably need to define an id name and type when importing

----- Original Message -----
From: xbranko <xbranko@...>
To: users@... <users@...>
Sent: Sat Jun 28 13:14:31 2008
Subject: Re: how to create menues with tiles2?



Antonio Petrelli-3 wrote:
>
>
> I think that you have EL evaluation turned off, you have to specify at
> least Servlet 2.4 version in your web.xml file.
>
>

According to my web.xml it should be on 2.5:
<web-app id="WebApp_ID"
         xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
         version="2.5">

Is there some other way to turn EL evaluation explicitly?

Branko
--
View this message in context: http://www.nabble.com/how-to-create-menues-with-tiles2--tp18163991p18172894.html
Sent from the tiles users mailing list archive at Nabble.com.


Re: how to create menues with tiles2?

by xbranko :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Rick Mangi-2 wrote:
You also probably need to define an id name and type when importing
How does one do that? And where? In my tiles-def.xml, menu definition has a name "menu", that is being used as a value in the other definition.

Branko

Parent Message unknown Re: how to create menues with tiles2?

by Rick Mangi-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

No in the import tag in the jsp page. Sorry not at my computer right now so I can't send example. The import tag requires Id, name and class. Hth - rick

----- Original Message -----
From: xbranko <xbranko@...>
To: users@... <users@...>
Sent: Sat Jun 28 13:23:12 2008
Subject: Re: how to create menues with tiles2?




Rick Mangi-2 wrote:
>
> You also probably need to define an id name and type when importing
>

How does one do that? And where? In my tiles-def.xml, menu definition has a
name "menu", that is being used as a value in the other definition.

Branko
--
View this message in context: http://www.nabble.com/how-to-create-menues-with-tiles2--tp18163991p18172982.html
Sent from the tiles users mailing list archive at Nabble.com.


Re: how to create menues with tiles2?

by Antonio Petrelli-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2008/6/27 xbranko <xbranko@...>:
>  <tiles:importAttribute name="menu.Attributes"/>

Rick is correct, there is a problem with dots in "menu.Attributes",
because, without the "toName" attribute, it will be imported in the
"menu.Attributes" name under page scope.
So, either use a "toName" attribute, e.g.:
<tiles:importAttribute name="menu.Attributes" toName="menuAttributes"/>
<c:forEach var="item" items="${menuAttributes}">
...

Or change its use in <c:forEach>, e.g.:
<c:forEach var="item" items="${pageScope['menu.Attributes']}">

HTH
Antonio

Re: how to create menues with tiles2?

by Antonio Petrelli-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2008/6/28 xbranko <xbranko@...>:
> <web-app id="WebApp_ID"
>         xmlns="http://java.sun.com/xml/ns/j2ee"
>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
> http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
>         version="2.5">

Oh, BTW, this root element is wrong, since from 2.5 Sun renamed "j2ee"
to "javaee", do a search-and-replace from one to the other.

Antonio

Re: how to create menues with tiles2?

by xbranko :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I did everything that was suggested. Changed the web.xml (j2ee -> javaee), used the 'toName' on import, used the pageScope[''] notation, but am still getting the same behavior, i.e. no menus! I've even changed the name by removing the dot menu.Attributes -> menuAttributes.

What else can it be? What else should I try? In the debugger can see menuAttributes are being passed as attribute of the pageContext, but they are not being used. The ForEachTag is setting the items over which to iterate over to literal ${pageScope['menuAttributes']}, and not to what this evaluates to! Where is this supposed to be evaluated?

Branko

Re: how to create menues with tiles2?

by Antonio Petrelli-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2008/6/30 xbranko <xbranko@...>:
The ForEachTag is setting the items over which to
> iterate over to literal ${pageScope['menuAttributes']}, and not to what this
> evaluates to!

Mmm one last chance, try to use this:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core_rt" %>

Antonio

Re: how to create menues with tiles2?

by xbranko :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Antonio Petrelli-3 wrote:
Mmm one last chance, try to use this:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core_rt" %>

Antonio
This gives:
org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core_rt cannot be resolved in either web.xml or the jar files deployed with this application

Eclipse Web tools jsp editor also flagged this as a problem. Does this work for you? Do you have a small self contained test example that you could share? I can try it on my end and try to see what is different. Any other idea? Anyway -- just wanted to say a big THANK YOU for all your help!

Branko

Re: how to create menues with tiles2?

by Antonio Petrelli-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2008/7/1 xbranko <xbranko@...>:

>
>
> Antonio Petrelli-3 wrote:
>>
>> Mmm one last chance, try to use this:
>> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core_rt" %>
>>
>> Antonio
>>
>>
> This gives:
> org.apache.jasper.JasperException: The absolute uri:
> http://java.sun.com/jsp/jstl/core_rt cannot be resolved in either web.xml or
> the jar files deployed with this application

Oh right, sorry, you are under Servlet 2.5, that do not need the "_rt"
versions of JSTL.
I was using this one since I use Servlet 2.4.
At this point I don't know what to say, but to try with another
application server :-(

Antonio
LightInTheBox - Buy quality products at wholesale price