webtier@glassfish.java.net

Re: [webtier] Load a view file from the classpath?

From: Lincoln Baxter, III <lincolnbaxter_at_gmail.com>
Date: Thu, 5 Nov 2009 19:19:42 -0500

Well... the resource naming does not work. Blows up in UIComponentBase.

    private static void validateId(String id) {

        if (id == null) {
            return;
        }
        int n = id.length();
        if (n < 1) {
            throw new IllegalArgumentException("Empty id attribute is not
allowed");
        }
        for (int i = 0; i < n; i++) {
            char c = id.charAt(i);
            if (i == 0) {
                if (!Character.isLetter(c) && (c != '_')) {
                    throw new IllegalArgumentException(id);
                }
            } else {
                if (!Character.isLetter(c) &&
                        !Character.isDigit(c) &&
                        (c != '-') && (c != '_')) {
                    throw new IllegalArgumentException(id);
                }
            }
        }

    }

On Thu, Nov 5, 2009 at 5:58 PM, Lincoln Baxter, III <lincolnbaxter_at_gmail.com
> wrote:

> Thanks, Jason!
>
>
> resourceUrl =
> Thread.currentThread().getContextClassLoader().getResource(resource);
>
> I'm thinking there may be some possibilities with the ClassLoader
> generating a URL that would become the ViewId... but it sounds very hit or
> miss if JSF would be able to use that... probably a miss.
>
> Gonna keep banging my head on it,
> --Lincoln
>
>
> On Thu, Nov 5, 2009 at 5:55 PM, Jason Lee <jasondlee_at_sun.com> wrote:
>
>> On Nov 5, 2009, at 4:44 PM, Lincoln Baxter, III wrote:
>>
>> I think that should be possible... how would you recommend I point
>> VDLFactory at the file on the classpath. Is there a way to get it to accept
>> a URL, or a resource?
>>
>>
>> Util.notNull("context", context);
>> String actualViewId = derivePhysicalViewId(context, viewId,
>> false);
>> return
>> vdlFactory.getViewDeclarationLanguage(actualViewId).createView(context,
>>
>> actualViewId);
>>
>> Or do I even need to do this as long as all of the Handlers know to
>> translate the custom ViewId into something real?
>>
>> I guess I'm a little lost since it looks like everything I would do to
>> "Build a UIViewRoot" requires a String viewId... which I'm not sure would
>> let me do what I need to with the classpath.
>>
>>
>> That's a good question. I've considered the issue you're trying to solve
>> in passing over the past couple of weeks, but haven't gone much deeper than
>> the ViewHandler (too many other irons in the fire). I'll see if I can give
>> that some more active thought. Which doesn't help you now, but we'll see
>> what I can find on my end. :)
>>
>> <http://www.java.com> * Jason Lee *
>> Senior Java Developer
>> GlassFish Administration Console
>>
>> *Sun Microsystems, Inc.*
>> Phone x31197/+1 405-343-1964
>> Email jasondlee_at_sun.com
>> Blog http://blogs.sun.com/jasondlee
>> Blog http://blogs.steeplesoft.com
>>
>>
>