[thelist] Java/JSP puzzler revisited (simplified)
Tom Dell'Aringa
pixelmech at yahoo.com
Thu Oct 20 13:45:30 CDT 2005
--- Hassan Schroeder <hassan at webtuitive.com> wrote:
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
> this would be a lot easier to test with access to your MenuItemNode
> class and a sample nodesInVerticalOrder :-)
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Yeah, especially since I'm not a java developer! I have no idea where I could even begin to locate
that info.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
> That said, here's a rough stab at a solution; hopefully it'll at
> least point you in a helpful direction!
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
It makes sense, but I get this compilation error:
Error: No entity named "level" was found in this environment.
javax.servlet.ServletException: Compilation error occured:
Found 1 errors in JSP file:
D:\\FoundationServer\\portal\\templates\\template0003\\VSdWdcXRUbfWeVeQZQdUQdUUXTaUYaQc\\vertical_svm_sp3.jsp:194:
Error: No entity named "level" was found in this environment.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
> > <%
>
> /* assuming nodesInVerticalOrder supports it, which seems
> * reasonable, change this Iterator to a ListIterator()
> */
> ListIterator verticalNodes = nodesInVerticalOrder.listIterator();
> > if (!verticalNodes.hasNext()) return;
> >
> > StringBuffer dataCell = new StringBuffer();
> >
> > // start root UL
> > dataCell.append("<ul>");
> >
> > // iterate through each nav item and write it out
> > while (verticalNodes.hasNext()) {
> >
> > MenuItemNode node = (MenuItemNode) verticalNodes.next();
>
> int previousLevel = level;
> > int level = node.getLevel(); // # from 1-4 always have access to this for each LI
>
> if ( verticalNodes.hasPrevious() )
> {
> dataCell.append("</li>");
> }
> if ( level > previousLevel )
> {
> dataCell.append("<ul>");
> }
> if ( level < previousLevel )
> {
> dataCell.append("</ul>");
> }
> > // begin new list item, write out LI and anchor
> > dataCell.append("<li class=\"" +className+ "\">");
> > dataCell.append("<a href=\"" + node.getHref() + "\">" + node.getTitle() + "</a>");
> >
>
> > //close the LI item
> /* dataCell.append("</li>\n"); */
> > }
> > // close out the root UL
> /* add final LI close here */
> dataCell.append("</li></ul>");
> > %>
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
I don't understand why level would all of a sudden be an unknown - does the assignment
int previousLevel = level;
cause some kind of problem with scope or something? Being a JavaScript guy, that seems fine to me,
but I don't know the nuances of Java...
Tom
http://www.pixelmech.com/
A man spoke frantically into the phone: "My wife is pregnant and her contractions are only two minutes apart"! "Is this her first child?" the doctor asked. "No, you idiot!" the man shouted. "This is her husband!"
Q: What do you call a muddy chicken who crossed the road two times?
A: A dirty double crosser...
More information about the thelist
mailing list