Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why doesn't this work? 1

Status
Not open for further replies.

Kindon

Programmer
Apr 19, 2001
54
US
<tiles:importAttribute />
<nd:tabmgr page='<%= pageContext.getAttribute(&quot;currentPage&quot;)%>'/>

<nd:tabmgr> is a taglib that I wrote. If you pass it text for the current page, it displays a tab menu with the currentPage selected. Works like a charm like this:

<nd:tabmgr page='main'/>

I used <tiles:importAttribute /> to make all the tiles template attributes accessable through the pageContext. This to works well.

When I went back and debugged it, I found that the string &quot;<%= pageContext.getAttribute(&quot;currentPage&quot;)%>&quot; was not rendered but sent directly to the taglib as a text string. Arg!

It appears that the tag lib is rendered first. And then the JSP tags are rendered last. What is going on here? Is this how it works? Is there a way to render the JSP tag first?
 
OK. Here is a very important thing. pageContext.getAttribute(&quot;currentPage&quot;) returns an Object, not a String. So I have to do this:

tab = pageContext.getAttribute(&quot;currentPage&quot;).toString();

However, when I tried this it still failed to highlight the selected page's tab:

<nd:tabmgr page=&quot;<%= tab%>&quot;/>

So, I tried rewriting the taglib to accept a body like this:
<nd:tabmgr><%= tab%></nd:tabmgr>

This worked! Now the selected page's tab is highlighted.

So, you can't use <%= %> for taglib attributes. But you can use it in the taglib body. Be sure you are getting the string you want. It took a bit of checking to find out exactly what string was getting passed. Bite! But it works now!
 
Hello there.

You *CAN* actually use <%=%> (also called RTEXPR) for taglib attributes.

For each tag you want to enable use of RTEXPR, just add (or modify) the tag definition in your TLD-file by setting rtexprvalue to true.

<tag>
<name>myCustomTag</name>
<tagclass>my.tagclass</tagclass>
<bodycontent>JSP</bodycontent>
<attribute>
<name>name</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
.....

 
Hi.
I am having some problems with the following bit of code...

<tiles:put name=&quot;navigation&quot; value=&quot;<%=pageContext.getAttribute(&quot;navigation&quot;)%>&quot;/>

I keep getting an error saying navigation has no value.
this is the error im getting.....
&quot;logonLayout.jsp&quot;: Attribute navigation has no value at line 25, column 76

did I just not define it in the tags or what? sorry i'm a little new to using tiles but trying to learn as I go.
thanks for any help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top