This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 87570 - jsp editor code completion does not recognise inner classes placed in a JSP
Summary: jsp editor code completion does not recognise inner classes placed in a JSP
Status: RESOLVED INVALID
Alias: None
Product: javaee
Classification: Unclassified
Component: JSP (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker with 1 vote (vote)
Assignee: Tomasz Slota
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-19 21:33 UTC by ssoong
Modified: 2007-09-04 18:59 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ssoong 2006-10-19 21:33:46 UTC
[NB5.5 20061002, JDK 1.505]

I'm not sure if I had reported this circa nb4, but I could not find it by 
query. One could believe this is a feature than a bug. But it is a bugging 
(absence of) feature.

In the following JSP, pressing [ctrl-space], with cursor after "iterx." code-
completion pop-up does not contain the public classes of inner class IterX.

==========================================================================

<%@ page import="
	java.util.Iterator,
	org.jdom.Element,
	org.jdom.Attribute",
	"org.jdom.input.SAXBuilder"
%>

<%
String x = request.getParameter("x");
java.util.List contents = null;

class IterX
{
    public void iterate (Element ei, JspWriter out)
    throws java.io.IOException
    {
        Iterator iter = ei.getChildren().iterator();
        iterate(iter,out);
    }

    public void iterate (Iterator iter, JspWriter out)
    throws java.io.IOException
    {
        while (iter.hasNext())
        {
            Object oj = iter.next();
            if (oj==null )continue;
            
            if (oj instanceof Element)
            {
                Element ej = (Element) oj;
                %>

<%              %><%=ej.getName()%>:<%=ej.getText().replaceAll("[\n\r ]+", "")%
><%
                iterate(ej.getAttributes().iterator(), out);
                iterate(ej,out);
            }
            
            else if (oj instanceof Attribute)
            {
                Attribute aj = (Attribute) oj;
                %>
<%              %>+  <%=aj.getName()%>:<%=aj.getValue()%><%
            }
        }
    }
}

if (fistx!=null)
{
    String xpath = session.getServletContext().getRealPath("/WEB-INF/"+x);
    String xfile = new File(xpath);
    
    SAXBuilder saxb = new SAXBuilder();
    saxb.setValidation(true);
    Document xdoc = saxb.build(xfile);

    IterX iterx = new IterX();
    iterx.iterate(xdoc.getRootElement(), out);
}
%>
Comment 1 ssoong 2006-10-19 21:35:02 UTC
if (fistx!=null)

should have been

if (x!=null)
Comment 2 ssoong 2006-10-19 21:36:17 UTC
and imports should have been,

<%@ page import="
	java.util.Iterator,
	org.jdom.Element,
	org.jdom.Attribute,
	org.jdom.input.SAXBuilder"
%>
Comment 3 ssoong 2006-11-02 20:16:56 UTC
Notice Issue 88539.
Comment 4 Tomasz Slota 2007-08-08 15:17:26 UTC
This does not a legal JSP - inner classes can be only declared within JSP declarations <@! ... @>.

Note that using inner classes defined in JSP is a terrible programming practice, JSP scriptlets as such are discouraged, the more logic they contain the worse.
Comment 5 ssoong 2007-09-04 18:59:47 UTC
I think you meant, <%! ... %>.

Anything is legal to me as long as java and jsp permits it.