[SunONE-JATO] Re: getModel(java.lang.Class clazz) method in ViewBean

Billy--

You can use the same technique with Class objects:

public Class VOYAGER_LOCKED_MODEL=

com.sun.cms.voyager.model.VoyagerLockedModel.class;

...

getModel(VOYAGER_LOCKED_MODEL);

Todd

-- Original Message --

From: "chubbykidd" <<a href="/group/SunONE-JATO/post?protectID=014166219007078048234218065176249063000 105238234061130234143025">bacon33@o...</a>>

Sent: Wednesday, October 23, 2002 4:57 PM

Subject: [SunONE-JATO] Re: getModel(java.lang.Class clazz) method in

ViewBean

> Thanks for the reply Craig. I'm not sure what is going on because the

> first thing I checked was the spelling and everything looks okay.

>

> I'm trying to use String constants to represent my class files so the

> app stays consistent and all developers can reference these constants

> from an interface. So basically my call to the method looks like

>

> getModel(Class.forName(VOYAGER_LOCKED_MODEL));

>

> where VOYAGER_LOCKED_MODEL =

> "com.sun.cms.voyager.model.VoyagerLockedModel";

>

> It's working for my other models, just not this one.

>

> - Billy -

>

> In <a href="/group/SunONE-JATO/post?protectID=246075234167171124217231170221059165026 048139046">SunONE-JATO@y...</a>, "Craig V. Conover" <<a href="/group/SunONE-JATO/post?protectID=219212113009229091025149066024064239039 098031046209130">craig.conover@s...</a>> wrote:

> > Billy,

> > Any method could throw a NullPointerException. That's a developer error

> > typically with misspelling a literal.

> > Make sure that your class name is spelled correctly.

> >

> > Better yet, why are you using Class.forName... ?

> > Just do this instead to get compiler time type checking, rather than

> > getting the runtime NullPointerException:

> > getModel(com.sun.cms.voyager.model.VoyagerLockedModel.class)

> >

> > Is there any particular reason you are using Class.forName and not the

> > suggested way?

> > c

> >

> >

> > chubbykidd wrote:

> >

> > >I have a method which calls the getModel(java.lang.Class clazz) method

> > >of the ViewBean class. I'm getting a NullPointerException when this

> > >method is called. The javadocs don't say anything about this method

> > >throwing an Exception. Can someone help me out on this one?

> > >

> > >My method call looks like this...

> > >

> >

> >getModel(Class.forName("com.sun.cms.voyager.model.VoyagerLockedModel"));

> > >

> > >

> > >- Billy -

> > >

> > >

> > >

> > >To download the latest version of JATO, please visit:

> > ><a href="http://www.sun.com/software/download/developer/5102.html">http://www.s un.com/software/download/developer/5102.html</a>

> > >

> > >For more information about JATO, please visit:

> > ><a href="http://developer.iplanet.com/tech/appserver/framework/index.jsp">http: //developer.iplanet.com/tech/appserver/framework/index.jsp</a>

> > >

> > >

> > >

> > >

> > >

> > >

>

>

>

> To download the latest version of JATO, please visit:

> <a href="http://www.sun.com/software/download/developer/5102.html">http://www.s un.com/software/download/developer/5102.html</a>

>

> For more information about JATO, please visit:

> <a href="http://developer.iplanet.com/tech/appserver/framework/index.jsp">http: //developer.iplanet.com/tech/appserver/framework/index.jsp</a>

>

>

>

>

>

[4238 byte] By [Guest] at [2007-11-25 9:26:27]
# 1

Yes, I actually changed my constants to

public static final Class VOYAGER_LOCKED_MODEL =

com.sun.cms.voyager.model.VoyagerLockedModel.class; after i read

craigs e-mail. I'm still receiving the same NullPointerException

even with this change. Now that I've changed them to Class constants

they are validated at compile time so I think this rules out the

possibilty that I have a name or spelling mistake for the class,

right? Because everything is compiling fine.

- Billy -

In <a href="/group/SunONE-JATO/post?protectID=246075234167171124217231170221059165026 048139046">SunONE-JATO@y...</a>, Todd Fast <<a href="/group/SunONE-JATO/post?protectID=101233080150035167169232031248066208071 048">Todd.Fast@S...</a>> wrote:

> Billy--

>

> You can use the same technique with Class objects:

>

> public Class VOYAGER_LOCKED_MODEL=

> com.sun.cms.voyager.model.VoyagerLockedModel.class;

>

> ...

>

> getModel(VOYAGER_LOCKED_MODEL);

>

> Todd

>

> -- Original Message --

> From: "chubbykidd" <<a href="/group/SunONE-JATO/post?protectID=014166219007078048234218065036129208"&g t;bacon33@o...</a>>

> Sent: Wednesday, October 23, 2002 4:57 PM

> Subject: [SunONE-JATO] Re: getModel(java.lang.Class clazz) method

in

> ViewBean

>

>

> > Thanks for the reply Craig. I'm not sure what is going on

because the

> > first thing I checked was the spelling and everything looks okay.

> >

> > I'm trying to use String constants to represent my class files

so the

> > app stays consistent and all developers can reference these

constants

> > from an interface. So basically my call to the method looks like

> >

> > getModel(Class.forName(VOYAGER_LOCKED_MODEL));

> >

> > where VOYAGER_LOCKED_MODEL =

> > "com.sun.cms.voyager.model.VoyagerLockedModel";

> >

> > It's working for my other models, just not this one.

> >

> > - Billy -

> >

> > In <a href="/group/SunONE-JATO/post?protectID=246075234167171124217231170221059165026 048139046">SunONE-JATO@y...</a>, "Craig V. Conover" <<a href="/group/SunONE-JATO/post?protectID=219212113009229091025149066024064239039 098031046209130">craig.conover@s...</a>>

wrote:

> > > Billy,

> > > Any method could throw a NullPointerException. That's a

developer error

> > > typically with misspelling a literal.

> > > Make sure that your class name is spelled correctly.

> > >

> > > Better yet, why are you using Class.forName... ?

> > > Just do this instead to get compiler time type checking,

rather than

> > > getting the runtime NullPointerException:

> > > getModel(com.sun.cms.voyager.model.VoyagerLockedModel.class)

> > >

> > > Is there any particular reason you are using Class.forName and

not the

> > > suggested way?

> > > c

> > >

> > >

> > > chubbykidd wrote:

> > >

> > > >I have a method which calls the getModel(java.lang.Class

clazz) method

> > > >of the ViewBean class. I'm getting a NullPointerException

when this

> > > >method is called. The javadocs don't say anything about this

method

> > > >throwing an Exception. Can someone help me out on this one?

> > > >

> > > >My method call looks like this...

> > > >

> > >

> > >getModel(Class.forName

("com.sun.cms.voyager.model.VoyagerLockedModel"));

> > > >

> > > >

> > > >- Billy -

> > > >

> > > >

> > > >

> > > >To download the latest version of JATO, please visit:

> > > ><a href="http://www.sun.com/software/download/developer/5102.html">http://www.s un.com/software/download/developer/5102.html</a>

> > > >

> > > >For more information about JATO, please visit:

> > >

><a href="http://developer.iplanet.com/tech/appserver/framework/index.jsp">http: //developer.iplanet.com/tech/appserver/framework/index.jsp</a>

> > > >

> > > >

> > > >

> > > >

> > > >

> > > >

> >

> >

> >

> > To download the latest version of JATO, please visit:

> > <a href="http://www.sun.com/software/download/developer/5102.html">http://www.s un.com/software/download/developer/5102.html</a>

> >

> > For more information about JATO, please visit:

> > <a href="http://developer.iplanet.com/tech/appserver/framework/index.jsp">http: //developer.iplanet.com/tech/appserver/framework/index.jsp</a>

> >

> >

> >

> >

> >

Guest at 2007-7-1 16:30:49 > top of Java-index,Development Tools,Java Tools...