dev@woodstock.java.net

Re: Can somebody take a look at this?

From: richard ratta <Richard.Ratta_at_Sun.COM>
Date: Fri, 14 Sep 2007 12:05:10 -0400

Additional information ...

richard ratta wrote:

>
>
> Winston Prakash wrote:
>
>>
>>>> This exception is filling up Netbeans IDE log. Thrown every time
>>>> the component renderer
>>>> is called. After JDK 1.4, the JLS guideline
>>>
>>>
>>> What is "JLS" ? Java Language Specification ?
>>
>>
>> Yes.
>
>
> Can you give me the section in the JLS that discusses this ?
>
>>>> is not to access resources or classes from
>>>> default package.
>>>
>>>
>>> What is the "default" package in the stack trace below ?
>>
>>
>> The exception does not display the resource name because empty string
>> is passed
>> to ClassLoader.getResource()
>>
>> Sandip and I looked at the code other day.
>> The problem seems to be at
>> com.sun.webui.jsf.util.JavaScriptUtilities.getThemeJavaScript
>>
>> // Fool getResourcePath into returning the prefix.
>> // by passing "", since we don't have path, we just want the
>> // prefix. This will have a trailing "/", so get rid of it.
>> //
>> String themePrefix = themeContext.getResourcePath("");
>> int lastSlash = themePrefix.lastIndexOf("/");
>> if (lastSlash > 0) {
>> themePrefix = themePrefix.substring(0, lastSlash);
>> }
>
>
> Right. This is too get the theme prefix including the app context.
> The problem is that in netbeans since VWP does not have a servlet and
> therefore
> this is just the empty string. At runtime this is not a problem.
>
> This is why I have been suggesting for at least a year that VWP adhere
> to the interfaces that
> the woodstock theme has created. If you implement a ThemeContext
> implementation
> this will not be an issue.

You should have also referenced this code in your email since you
reference JSFThemeContext

    /**
     * Return an appropriate resource path within this theme context.
     * Use is Beans.isDesignTime to prevent ThemeServlet prefix from
     * being appended. Creator handles doing the right thing with
     * getRequestContextPath()
     */
    public String getResourcePath(String path) {
        String resourcePath = path;
        if (Beans.isDesignTime()) { <<<====================================
            ClassLoader cl = getDefaultClassLoader();
            // NB6 gives warnings if the path has a leading "/". So,
strip it of
f if it has one
            URL url = cl.getResource(path.startsWith("/") ?
path.substring(1) :
path);
            if (url != null) {
                resourcePath = url.toExternalForm();
            }
        } else if (path != null) {
            FacesContext context = FacesContext.getCurrentInstance();
            String servletContext = getThemeServletContext();
            StringBuilder sb = new StringBuilder(128);
            // Just to make sure
            //
            if (!servletContext.startsWith("/")) {
                sb.append("/");
            }
            sb.append(servletContext);
            if (!path.startsWith("/") && !servletContext.endsWith("/")) {
                sb.append("/");
            }
            sb.append(path);
            resourcePath = context.getApplication().getViewHandler().
                getResourceURL(context, sb.toString());
        }
        return resourcePath;
    }

If you VWP/Creator had fully implemented FacesContext like we had been
asking over the years
then these design time tests would also not have to be necessary and
again this issue would not have
arisen.

-rick

>
> -rick
>
>>
>> - Winston
>>
>>>> Netbeans enforces it by throwing an exception. Since this part of the
>>>> code in JSFThemeContext viloates seems to violate this principle,
>>>> NB keeps throwing
>>>> the informational exception
>>>>
>>>> java.lang.IllegalStateException: You are trying to access file:
>>>> from the default package. Please see
>>>> http://www.netbeans.org/download/dev/javadoc/org-openide-modules/org/openide/modules/doc-files/classpath.html#default_package
>>>>
>>>> at
>>>> org.netbeans.ProxyClassLoader.printDefaultPackageWarning(ProxyClassLoader.java:478)
>>>>
>>>> at
>>>> org.netbeans.ProxyClassLoader.getResource(ProxyClassLoader.java:258)
>>>> at java.lang.ClassLoader.getResource(ClassLoader.java:972)
>>>> at java.lang.ClassLoader.getResource(ClassLoader.java:972)
>>>> at
>>>> com.sun.webui.jsf.theme.JSFThemeContext.getResourcePath(JSFThemeContext.java:148)
>>>>
>>>> at
>>>> com.sun.webui.jsf.util.JavaScriptUtilities.getThemeJavaScript(JavaScriptUtilities.java:509)
>>>>
>>>> at
>>>> com.sun.webui.jsf.util.JavaScriptUtilities.getDojoConfig(JavaScriptUtilities.java:131)
>>>>
>>>> at
>>>> com.sun.webui.jsf.renderkit.html.HeadRenderer.renderAttributes(HeadRenderer.java:134)
>>>>
>>>> at
>>>> com.sun.webui.jsf.renderkit.html.AbstractRenderer.encodeBegin(AbstractRenderer.java:156)
>>>>
>>>> at
>>>> javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:785)
>>>>
>>>> at
>>>> org.netbeans.modules.visualweb.insync.faces.FacesPageUnit.renderBean(FacesPageUnit.java:1276)
>>>>
>>>> at
>>>> org.netbeans.modules.visualweb.insync.faces.FacesPageUnit.renderNode(FacesPageUnit.java:1532)
>>>>
>>>> at
>>>> org.netbeans.modules.visualweb.insync.faces.FacesPageUnit.renderBean(FacesPageUnit.java:1324)
>>>>
>>>>
>>>> - Winston
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe_at_woodstock.dev.java.net
>>>> For additional commands, e-mail: dev-help_at_woodstock.dev.java.net
>>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_woodstock.dev.java.net
> For additional commands, e-mail: dev-help_at_woodstock.dev.java.net
>