struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jim Barrows" <jbarr...@sssc.com>
Subject RE: JSTL, Tiles PutList and Tomcat 5.028
Date Fri, 03 Dec 2004 17:07:54 GMT


> -----Original Message-----
> From: Jerry Rodgers [mailto:jrodgers@aravo.com]
> Sent: Friday, December 03, 2004 9:55 AM
> To: 'Struts Users Mailing List'
> Subject: RE: JSTL, Tiles PutList and Tomcat 5.028
> 
> 
> Thanks James, 
> 
> It looks like if I put a break point in the setItems() method 
> of the forEach
> I am passed a string - that string appears to be the 
> .toString() of the
> SimpleMenuItem(s) collection. 
> 
> I check the .toString() of SimpleMenuItem and it has the 
> format of the long
> string below from my previous message - i.e. the 5 or so items in the
> collection. 
> 
> How does / or should the ForEach turn that string back into a 
> collection of
> items. 

If I understand what you're saying.... You have something like:
Collection foo;
Collection bar;
bar.add(foo);
then something like foo[i][j] MIGHT work.
On the other hand ifyou have just a collletion fo foo.. you want foo[i].

> 
> When looking at the parameter on the method signature I had 
> expected that I
> would get the "EXPRESSION" that needed to be evaluated by 
> jstl within the
> tag instead it appears the expression has been run prior to 
> the call of the
> method an then the .toString() has been called. 
> 
> Thanks for everyone's help and input on this - I have now 
> spent two/three
> very late nights tracking this down.
> 
> -Jerry
> 
> 
> 
> 
> -----Original Message-----
> From: Jim Barrows [mailto:jbarrows@sssc.com] 
> Sent: Friday, December 03, 2004 8:45 AM
> To: Struts Users Mailing List
> Subject: RE: JSTL, Tiles PutList and Tomcat 5.028
> 
> 
> 
> > -----Original Message-----
> > From: Jerry Rodgers [mailto:jrodgers@aravo.com]
> > Sent: Friday, December 03, 2004 9:20 AM
> > To: 'Struts Users Mailing List'; 'Mark Lowe'
> > Subject: RE: JSTL, Tiles PutList and Tomcat 5.028
> > 
> > 
> > One other thing to add :> there is a "key" in the pageContext 
> > attributes
> > called topnav and that DOES contain an actual collection of 
> > SimpleMenuItems.
> > The plot thickens - how does the ForEach get the collection?
> 
> I think it looks up the scope chain....  request, session, application
> 
> > 
> > -Jerry 
> > 
> > -----Original Message-----
> > From: Jerry Rodgers [mailto:jrodgers@aravo.com] 
> > Sent: Friday, December 03, 2004 8:02 AM
> > To: 'Struts Users Mailing List'; 'Mark Lowe'
> > Subject: RE: JSTL, Tiles PutList and Tomcat 5.028
> > 
> > Hi Matk, 
> > 
> > I have the following statement
> > 
> > <tiles:importAttribute /> 
> > 
> > Which I "think" am lead to believe it imports all the 
> > attributes into the
> > page scope. 
> > 
> > In an effort to figure out what was happening I downloaded 
> > the jstl 1.0.6
> > and built a debug project in eclipse so I could step into the 
> > ForEach tag
> > and I am not sure what I am really looking at yet in there 
> > but it appears
> > that indeed the item does contain a string and that the items 
> > collection on 
> > the tag has a "somewhat" string delimited representation of 
> > the collection. 
> > 
> > See below: This is that actual value in the string in the 
> > debugger... Is
> > this how it is stored then is ir "reconstituted" into 
> > SimpleMenuItem(s) as
> > the tag loops. The string "looks" like a collection because 
> > of the "," i.e.
> > it looks like a string tokenizer.
> > 
> > [SimpleMenuItem[value=nav.adminhome,
> > link=/aems/session/changefiltertoken.do?btnResetFilter=true,
> > tooltip=impersonationItem, ], SimpleMenuItem[value=nav.account,
> > link=/aems/party/persondetail.do, ], 
> > SimpleMenuItem[value=nav.organization,
> > link=/aems/party/organizationdetail.do, ], 
> > SimpleMenuItem[value=nav.library,
> > link=/aems/file/filelibrarylist.do, ], 
> > SimpleMenuItem[value=nav.addressbook,
> > link=/aems/communication/personsearchlist.do, ],
> > SimpleMenuItem[value=nav.help, link=#, tooltip=help, ],
> > SimpleMenuItem[value=nav.logout, link=/aems/logout.do, ]]
> > 
> > And give this sting in the items - the actual when call to 
> > next() within the
> > EnumeratonAdapter way in the ForEachSupport class actuall calls the
> > StringTokenizer and returns an item of:
> > 
> > [SimpleMenuItem[value=nav.adminhome
> > 
> > So it looks like it went to the first ","  and thus the 
> > subject of my email
> > might really be changed to: "What is causing ForEach to 
> > read/load my tiles
> > putlist collection as a string and not as a collection of the
> > SimpleMenuItems they really are"? Pretty darn long subject :> 
> > 
> > 
> > On a side note - not sure if this means anything - when I 
> compiled the
> > course I was required by eclipse to add two new methods to the
> > PageContextImpl in the 
> > org.apache.taglibs.standard.lang.jstl.test package
> > does it looks like perhaps the different JSP version might be 
> > an issue. i.e.
> > will jstl 1.0.6 work in Tomcat 5.0.28? 
> > 
> > 
> > /* (non-Javadoc)
> >  * @see javax.servlet.jsp.JspContext#getExpressionEvaluator()
> >  */
> > public ExpressionEvaluator getExpressionEvaluator() {
> > 	// TODO Auto-generated method stub
> > 	return null;
> > }
> > 
> > /* (non-Javadoc)
> >  * @see javax.servlet.jsp.JspContext#getVariableResolver()
> >  */
> > public VariableResolver getVariableResolver() {
> > 	// TODO Auto-generated method stub
> > 	return null;
> > }
> > 
> > 
> > Thanks,
> > Jerry 
> > 
> > 
> > 
> > 
> > -----Original Message-----
> > From: Mark Lowe [mailto:melowe@gmail.com] 
> > Sent: Friday, December 03, 2004 2:49 AM
> > To: Struts Users Mailing List
> > Subject: Re: JSTL, Tiles PutList and Tomcat 5.028
> > 
> > Have you done this in the jsp?
> > 
> > <tiles:useAttribute name="topnav" scope="page" />
> > 
> > MArk
> > 
> > On Thu, 2 Dec 2004 12:39:01 -0700, Jim Barrows 
> > <jbarrows@sssc.com> wrote:
> > > 
> > > 
> > > 
> > > 
> > > > -----Original Message-----
> > > > From: Jerry Rodgers [mailto:jrodgers@aravo.com]
> > > > Sent: Thursday, December 02, 2004 12:11 PM
> > > > To: user@struts.apache.org
> > > > Subject: JSTL, Tiles PutList and Tomcat 5.028
> > > >
> > > >
> > > > Hi All,
> > > >
> > > >
> > > >
> > > > I have a jsp page that I am trying to run on Tomcat that
> > > > currently works in
> > > > Weblogic. It appears the primary problem is that the forEach
> > > > tag is not
> > > > putting the variable menuItem into the pageContext attributes
> > > > and or it
> > > > thinks the menuItem is of type String. I am not sure 
> > where my actually
> > > > problem is (tiles, tomcat etc).
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > It appears Tomcat is generating code when compiling the JSP
> > > > that isn't aware
> > > > of the type of class the
> > > > org.apache.struts.tiles.beans.SimpleMenuItem is -
> > > > it looks like at run time it thinks it is a String.
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > A snippet of my JSP looks like this (jstl tags - partial):
> > > >
> > > > <core:forEach var="menuItem" varStatus="status" 
> items="${topnav}">
> > > >
> > > > <core:choose>
> > > >
> > > >  <core:when test="${menuItem.tooltip=='help'}">
> > > 
> > > I do something similar in my code, and it works.
> > > It does look like it's not figuring out what type the menuItem is
> > though....
> > > 
> > > <snip/>
> > > 
> > > 
> > > 
> > > >
> > > > When I check the pageContext attributes via a debugger I
> > > > actually see an
> > > > item in the collection with the key "topnav" and it contains
> > > > a Vector of
> > > > items that appear to be of type SimpleMenuItem. However I
> > > > never see the item
> > > > called menuItem that I thought the forEach tag would place in
> > > > there for me.
> > > 
> > > And I think the tutorial is agreeing with you:
> > > The forEach tag allows you to iterate over a collection of 
> > objects. You
> > specify the collection via the items attribute, and the 
> > current item is
> > available through a scope variable named by the item attribute.
> > > 
> > > A large number of collection types are supported by 
> > forEach, including all
> > implementations of java.util.Collection and java.util.Map. If 
> > the items
> > attribute is of type java.util.Map, then the current item 
> > will be of type
> > java.util.Map.Entry, which has the following properties:
> > > 
> > >     * key - the key under which the item is stored in the 
> > underlying Map
> > >     * value - the value that corresponds to the key
> > > 
> > > Arrays of objects as well as arrays of primitive types (for 
> > example, int)
> > are also supported. For arrays of primitive types, the 
> > current item for the
> > iteration is automatically wrapped with its standard wrapper 
> > class (for
> > example, Integer for int, Float for float, and so on).
> > > 
> > > Implementations of java.util.Iterator and 
> java.util.Enumeration are
> > supported but these must be used with caution. Iterator and 
> > Enumeration
> > objects are not resettable so they should not be used within 
> > more than one
> > iteration tag. Finally, java.lang.String objects can be 
> > iterated over if the
> > string contains a list of comma separated values (for example:
> > Monday,Tuesday,Wednesday,Thursday,Friday).
> > > 
> > > Here's the shopping cart iteration from the previous 
> > section with the
> > forEach tag:
> > > 
> > > <c:forEach var="item" items="${sessionScope.cart.items}">
> > >   ...
> > >   <tr>
> > >     <td align="right" bgcolor="#ffffff">
> > >     ${item.quantity}
> > >   </td>
> > >   ...
> > > </c:forEach>
> > > 
> > > The forTokens tag is used to iterate over a collection of 
> > tokens separated
> > by a delimiter.
> > > from 
> http://java.sun.com/webservices/docs/1.3/tutorial/doc/index.html
> > 
> > >
> > >
> > >
> > > Thanks for any help you may be able to provide,
> > >
> > >
> > >
> > > Jerry Rodgers
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> > 
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message