Re: ClassCastException with ListView() SOLVED! Sort of.

2008-05-30 Thread David Nedrow
It looks as though this is some subtlety (or brokenness) to GlassFish  
and Toplink. If I deploy my Wicket app as a module of a Java  
Enterprise package, it all works as expected.


It's a simple workaround for now until I find out if it's a bug, or if  
I'm just not getting my Glassfish config correct.


Basically, using NetBeans, I create a new "Enterprise Application",  
add my Wicket app as a Java EE module, then deploy. Et voila!


In any case, I can move on for the moment. ;)

-David

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ClassCastException with ListView()

2008-05-30 Thread James Carman
If you want to turn off LTW, you can use the AspectJ compiler in your
build.  If you want an example, check out:

http://svn.carmanconsulting.com/public/wicket-advanced/trunk/pom.xml

I have the AspectJ compiler set up to weave in the spring aspects.

On Fri, May 30, 2008 at 3:29 PM, David Nedrow <[EMAIL PROTECTED]> wrote:
> As an aside, this is clearly a configuration item for Spring. From my
> application context
>
>
>  
> class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
>
>
>classpath:META-INF/persistence.xml
>
>
>
> class="org.springframework.instrument.classloading.SimpleLoadTimeWeaver"/>
>
>
>
> This was derived from several JPA+Spring+Wicket examples. The weaver is
> non-optional with the way I've gotten this all working as far as it is.
>
> -David
>
> On May 30, 2008, at 3:20 PM, David Nedrow wrote:
>
>>
>> On May 30, 2008, at 2:26 PM, James Carman wrote:
>>
>>> Take a look at what classloaders loaded each of the classes.  If the
>>> class names are the same, then that means that they were loaded by two
>>> different classloaders.  How are you setting up your application?  Are
>>> all jars in your WEB-INF/lib directory?
>>
>> I added the following to just before line that causes the cast failure...
>>
>>   java.lang.ClassLoader ctxCl =
>> Thread.currentThread().getContextClassLoader();
>>   java.lang.ClassLoader tcCl  =
>> Protocol.class.getClassLoader();
>>   java.lang.ClassLoader soCl  =
>> item.getModelObject().getClass().getClassLoader();
>>
>>   System.out.println("ctxCl=" + ((ctxCl == null)
>>  ? "null"
>>  : ctxCl.toString()));
>>   System.out.println("tcCl=" + ((tcCl == null)
>> ? "null"
>> : tcCl.toString()));
>>   System.out.println("soCl=" + ((soCl == null)
>> ? "null"
>> : soCl.toString()));
>>
>> Below is the run output, which would appear to show WebAppClassloader for
>> the target, and a Spring loader for the source. Isn't the whole point of
>> Spring to do exactly that? Load classes dynamically? In any case, any
>> suggestions, or should I hit the Spring forum now that it appear to be
>> Spring specific?
>>
>> -David
>>
>> [TopLink Info]: 2008.05.30
>> 03:07:21.737--ServerSession(878231)--file:/Users/dnedrow/Developer/NetBeansProjects/FilterRequest/build/web/WEB-INF/classes/-NetConfPU
>> login successful
>> finding all Protocol instances
>> ctxCl=WebappClassLoader
>>  delegate: true
>>  repositories:
>>   /WEB-INF/classes/
>> --> Parent Classloader:
>> EJBClassLoader :
>> urlSet = []
>> doneCalled = false
>> Parent -> [EMAIL PROTECTED]
>> tcCl=WebappClassLoader
>>  delegate: true
>>  repositories:
>>   /WEB-INF/classes/
>> --> Parent Classloader:
>> EJBClassLoader :
>> urlSet = []
>> doneCalled = false
>> Parent -> [EMAIL PROTECTED]
>>
>> [EMAIL PROTECTED]
>>
>>
>> -
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ClassCastException with ListView()

2008-05-30 Thread David Nedrow


On May 30, 2008, at 3:26 PM, James Carman wrote:


Perhaps this thread will help you?

http://forum.springframework.org/archive/index.php/t-29565.html


I found a similar thread that basically dealt with the same thing,  
recommending  
org 
.springframework 
.instrument.classloading.glassfish.GlassFishLoadTimeWeaver for the  
weaver, but that causes the app to not be able to locate the class at  
all.


I'll ask on the Spring forum.

Thanks for all the help. Back when I get the Spring bit working with  
annotations.


-David

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ClassCastException with ListView()

2008-05-30 Thread James Carman
Perhaps this thread will help you?

http://forum.springframework.org/archive/index.php/t-29565.html


On Fri, May 30, 2008 at 3:20 PM, David Nedrow <[EMAIL PROTECTED]> wrote:
>
> On May 30, 2008, at 2:26 PM, James Carman wrote:
>
>> Take a look at what classloaders loaded each of the classes.  If the
>> class names are the same, then that means that they were loaded by two
>> different classloaders.  How are you setting up your application?  Are
>> all jars in your WEB-INF/lib directory?
>
> I added the following to just before line that causes the cast failure...
>
>java.lang.ClassLoader ctxCl =
> Thread.currentThread().getContextClassLoader();
>java.lang.ClassLoader tcCl  =
> Protocol.class.getClassLoader();
>java.lang.ClassLoader soCl  =
> item.getModelObject().getClass().getClassLoader();
>
>System.out.println("ctxCl=" + ((ctxCl == null)
>   ? "null"
>   : ctxCl.toString()));
>System.out.println("tcCl=" + ((tcCl == null)
>  ? "null"
>  : tcCl.toString()));
>System.out.println("soCl=" + ((soCl == null)
>  ? "null"
>  : soCl.toString()));
>
> Below is the run output, which would appear to show WebAppClassloader for
> the target, and a Spring loader for the source. Isn't the whole point of
> Spring to do exactly that? Load classes dynamically? In any case, any
> suggestions, or should I hit the Spring forum now that it appear to be
> Spring specific?
>
> -David
>
> [TopLink Info]: 2008.05.30
> 03:07:21.737--ServerSession(878231)--file:/Users/dnedrow/Developer/NetBeansProjects/FilterRequest/build/web/WEB-INF/classes/-NetConfPU
> login successful
> finding all Protocol instances
> ctxCl=WebappClassLoader
>  delegate: true
>  repositories:
>/WEB-INF/classes/
> --> Parent Classloader:
> EJBClassLoader :
> urlSet = []
> doneCalled = false
>  Parent -> [EMAIL PROTECTED]
> tcCl=WebappClassLoader
>  delegate: true
>  repositories:
>/WEB-INF/classes/
> --> Parent Classloader:
> EJBClassLoader :
> urlSet = []
> doneCalled = false
>  Parent -> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ClassCastException with ListView()

2008-05-30 Thread David Nedrow
As an aside, this is clearly a configuration item for Spring. From my  
application context


 
class 
= 
"org 
.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">



classpath:META-INF/persistence.xml



class 
="org.springframework.instrument.classloading.SimpleLoadTimeWeaver"/>




This was derived from several JPA+Spring+Wicket examples. The weaver  
is non-optional with the way I've gotten this all working as far as it  
is.


-David

On May 30, 2008, at 3:20 PM, David Nedrow wrote:



On May 30, 2008, at 2:26 PM, James Carman wrote:


Take a look at what classloaders loaded each of the classes.  If the
class names are the same, then that means that they were loaded by  
two
different classloaders.  How are you setting up your application?   
Are

all jars in your WEB-INF/lib directory?


I added the following to just before line that causes the cast  
failure...


   java.lang.ClassLoader ctxCl =  
Thread.currentThread().getContextClassLoader();
   java.lang.ClassLoader tcCl  =  
Protocol.class.getClassLoader();
   java.lang.ClassLoader soCl  =  
item.getModelObject().getClass().getClassLoader();


   System.out.println("ctxCl=" + ((ctxCl == null)
  ? "null"
  : ctxCl.toString()));
   System.out.println("tcCl=" + ((tcCl == null)
 ? "null"
 : tcCl.toString()));
   System.out.println("soCl=" + ((soCl == null)
 ? "null"
 : soCl.toString()));

Below is the run output, which would appear to show  
WebAppClassloader for the target, and a Spring loader for the  
source. Isn't the whole point of Spring to do exactly that? Load  
classes dynamically? In any case, any suggestions, or should I hit  
the Spring forum now that it appear to be Spring specific?


-David

[TopLink Info]: 2008.05.30 03:07:21.737--ServerSession(878231)-- 
file:/Users/dnedrow/Developer/NetBeansProjects/FilterRequest/build/ 
web/WEB-INF/classes/-NetConfPU login successful

finding all Protocol instances
ctxCl=WebappClassLoader
 delegate: true
 repositories:
   /WEB-INF/classes/
--> Parent Classloader:
EJBClassLoader :
urlSet = []
doneCalled = false
Parent -> [EMAIL PROTECTED]
tcCl=WebappClassLoader
 delegate: true
 repositories:
   /WEB-INF/classes/
--> Parent Classloader:
EJBClassLoader :
urlSet = []
doneCalled = false
Parent -> [EMAIL PROTECTED]
soCl 
= 
org 
.springframework 
[EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ClassCastException with ListView()

2008-05-30 Thread David Nedrow


On May 30, 2008, at 2:26 PM, James Carman wrote:


Take a look at what classloaders loaded each of the classes.  If the
class names are the same, then that means that they were loaded by two
different classloaders.  How are you setting up your application?  Are
all jars in your WEB-INF/lib directory?


I added the following to just before line that causes the cast  
failure...


java.lang.ClassLoader ctxCl =  
Thread.currentThread().getContextClassLoader();
java.lang.ClassLoader tcCl  =  
Protocol.class.getClassLoader();
java.lang.ClassLoader soCl  =  
item.getModelObject().getClass().getClassLoader();


System.out.println("ctxCl=" + ((ctxCl == null)
   ? "null"
   : ctxCl.toString()));
System.out.println("tcCl=" + ((tcCl == null)
  ? "null"
  : tcCl.toString()));
System.out.println("soCl=" + ((soCl == null)
  ? "null"
  : soCl.toString()));

Below is the run output, which would appear to show WebAppClassloader  
for the target, and a Spring loader for the source. Isn't the whole  
point of Spring to do exactly that? Load classes dynamically? In any  
case, any suggestions, or should I hit the Spring forum now that it  
appear to be Spring specific?


-David

[TopLink Info]: 2008.05.30 03:07:21.737--ServerSession(878231)--file:/ 
Users/dnedrow/Developer/NetBeansProjects/FilterRequest/build/web/WEB- 
INF/classes/-NetConfPU login successful

finding all Protocol instances
ctxCl=WebappClassLoader
  delegate: true
  repositories:
/WEB-INF/classes/
--> Parent Classloader:
EJBClassLoader :
urlSet = []
doneCalled = false
 Parent -> [EMAIL PROTECTED]
tcCl=WebappClassLoader
  delegate: true
  repositories:
/WEB-INF/classes/
--> Parent Classloader:
EJBClassLoader :
urlSet = []
doneCalled = false
 Parent -> [EMAIL PROTECTED]
soCl 
= 
org 
.springframework 
[EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ClassCastException with ListView()

2008-05-30 Thread James Carman
Take a look at what classloaders loaded each of the classes.  If the
class names are the same, then that means that they were loaded by two
different classloaders.  How are you setting up your application?  Are
all jars in your WEB-INF/lib directory?

On Fri, May 30, 2008 at 2:22 PM, David Nedrow <[EMAIL PROTECTED]> wrote:
>
> On May 30, 2008, at 12:20 PM, James Carman wrote:
>
>> Protocol.class.equals(item.getModelObject().getClass())
>
> Interesting, this returns false.
>
> -David
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ClassCastException with ListView()

2008-05-30 Thread David Nedrow


On May 30, 2008, at 12:17 PM, Gwyn Evans wrote:


Just to double-check Thomas's point (1), are there any of the jars
being loaded from the AppServer's class-path rather than the Web-App's
classpath?  (What AppServer anyway?)


No, the only thing "endorsed" is the mysql connector.

This is running on GlasshFish v2.

-David

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ClassCastException with ListView()

2008-05-30 Thread David Nedrow


On May 30, 2008, at 12:20 PM, James Carman wrote:


Protocol.class.equals(item.getModelObject().getClass())


Interesting, this returns false.

-David

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ClassCastException with ListView()

2008-05-30 Thread James Carman
On Fri, May 30, 2008 at 12:17 PM, Gwyn Evans <[EMAIL PROTECTED]> wrote:
> On Fri, May 30, 2008 at 5:14 PM, David Nedrow <[EMAIL PROTECTED]> wrote:
>>
>> On May 30, 2008, at 11:47 AM, Thomas Mäder wrote:
>>
>>> 2) You're being done in by the BoundCompoundPropertyModel you have in the
>>> item. Fire up the debugger and check the values directly (relying on
>>> toString() is bad; some object might be lying to you. Step into the
>>> item.getModelObject().
>>
>> After stepping into getModelObject(), I can clearly see that there is a list
>> of protocol items containing expected data.
>
> Just to double-check Thomas's point (1), are there any of the jars
> being loaded from the AppServer's class-path rather than the Web-App's
> classpath?  (What AppServer anyway?)
>

You can do Protocol.class.equals(item.getModelObject().getClass()) to
see if you're running into classloader issues.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ClassCastException with ListView()

2008-05-30 Thread Gwyn Evans
On Fri, May 30, 2008 at 5:14 PM, David Nedrow <[EMAIL PROTECTED]> wrote:
>
> On May 30, 2008, at 11:47 AM, Thomas Mäder wrote:
>
>> 2) You're being done in by the BoundCompoundPropertyModel you have in the
>> item. Fire up the debugger and check the values directly (relying on
>> toString() is bad; some object might be lying to you. Step into the
>> item.getModelObject().
>
> After stepping into getModelObject(), I can clearly see that there is a list
> of protocol items containing expected data.

Just to double-check Thomas's point (1), are there any of the jars
being loaded from the AppServer's class-path rather than the Web-App's
classpath?  (What AppServer anyway?)

/Gwyn

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ClassCastException with ListView()

2008-05-30 Thread James Carman
Can you create a quickstart that exhibits this behavior?  Your dao
could be a simple thing that doesn't use a persistence library and
returns some manufactured objects.

On Fri, May 30, 2008 at 12:14 PM, David Nedrow <[EMAIL PROTECTED]> wrote:
>
> On May 30, 2008, at 11:47 AM, Thomas Mäder wrote:
>
>> 2) You're being done in by the BoundCompoundPropertyModel you have in the
>> item. Fire up the debugger and check the values directly (relying on
>> toString() is bad; some object might be lying to you. Step into the
>> item.getModelObject().
>
> After stepping into getModelObject(), I can clearly see that there is a list
> of protocol items containing expected data.
>
> -David
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ClassCastException with ListView()

2008-05-30 Thread David Nedrow


On May 30, 2008, at 11:47 AM, Thomas Mäder wrote:

2) You're being done in by the BoundCompoundPropertyModel you have  
in the

item. Fire up the debugger and check the values directly (relying on
toString() is bad; some object might be lying to you. Step into the
item.getModelObject().


After stepping into getModelObject(), I can clearly see that there is  
a list of protocol items containing expected data.


-David
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ClassCastException with ListView()

2008-05-30 Thread David Nedrow


On May 30, 2008, at 11:46 AM, Ryan Gravener wrote:


How about changing PropertyListView to just ListView.



I hadoriginally been using ListView, but switched to PropertyListView  
while trying to troubleshoot this problem. I had forgotten to roll  
that change back. Switching to ListView makes no difference in the  
behavior.


-David

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ClassCastException with ListView()

2008-05-30 Thread David Nedrow


On May 30, 2008, at 11:41 AM, James Carman wrote:

On Fri, May 30, 2008 at 11:38 AM, David Nedrow <[EMAIL PROTECTED]>  
wrote:


On May 30, 2008, at 11:20 AM, James Carman wrote:

What is the type of item.getModelObject().  Have you run it  
through a

debugger (or just simply put in a println)?


Yes, I had done that first, thinking maybe I didn't understand how  
ListView

worked via the Model.

The object returned by item.getModelObject().toString() is...


Try doing, item.getModelObject().getClass().toString() (unless that's
what you meant to type).


Sorry, that's what I had done but the getClass() didn't make it in to  
my message. ;)



 Can we see an example method from your DAO?
What persistence library are you using (hibernate, jpa, jdo, etc.)?


This is jpa via toplink.

Here's the method I'm calling in the Protocol class (note that the  
logger does fire in findAll())


/**
 * Find all Protocol entities.
 *
 * @param rowStartIdxAndCount
 *Optional int varargs. rowStartIdxAndCount[0]  
specifies the the
 *row index in the query result-set to begin  
collecting the
 *results. rowStartIdxAndCount[1] specifies the the  
maximum

 *count of results to return.
 * @return List all Protocol entities
 */
@Transactional(readOnly = true)
@SuppressWarnings("unchecked")
@Override
public List findAll(final int... rowStartIdxAndCount) {
logger.info("finding all Protocol instances");

try {
final String queryString = "select model from Protocol  
model";


return getJpaTemplate().executeFind(new JpaCallback() {
@Override public Object doInJpa(EntityManager em)  
throws PersistenceException {

Query query = em.createQuery(queryString);

if ((rowStartIdxAndCount != null) &&  
(rowStartIdxAndCount.length > 0)) {
int rowStartIdx = Math.max(0,  
rowStartIdxAndCount[0]);


if (rowStartIdx > 0) {
query.setFirstResult(rowStartIdx);
}

if (rowStartIdxAndCount.length > 1) {
int rowCount = Math.max(0,  
rowStartIdxAndCount[1]);


if (rowCount > 0) {
query.setMaxResults(rowCount);
}
}
}

return query.getResultList();
}
});
} catch (RuntimeException re) {
logger.error("find all failed", re);

throw re;
}
}



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ClassCastException with ListView()

2008-05-30 Thread Thomas Mäder
There are only two ways I can see that you can get a ClassCastException:

1) There is some class loader magic going on. Highly unlikely.
2) You're being done in by the BoundCompoundPropertyModel you have in the
item. Fire up the debugger and check the values directly (relying on
toString() is bad; some object might be lying to you. Step into the
item.getModelObject().

Thomas


On Fri, May 30, 2008 at 5:38 PM, David Nedrow <[EMAIL PROTECTED]> wrote:

>
> On May 30, 2008, at 11:20 AM, James Carman wrote:
>
>  What is the type of item.getModelObject().  Have you run it through a
>> debugger (or just simply put in a println)?
>>
>
> Yes, I had done that first, thinking maybe I didn't understand how ListView
> worked via the Model.
>
> The object returned by item.getModelObject().toString() is...
>
> com.vzbi.ncs.argfrp.jpa.netconf.Protocol
>
> That's what baffles me about the cast exception.
>
>
>
>  On Fri, May 30, 2008 at 11:16 AM, David Nedrow <[EMAIL PROTECTED]> wrote:
>>
>>> I'm getting a cast exception when I attempt to pull a list element from
>>> the
>>> model. I may be mishandling how I'm using the model, but this is
>>> basically
>>> based on several tutorials I've looked at.
>>>
>>> (Note, as people have pointed out here, I use the "old fashioned" naming
>>> style for my interfaces and DAOs.)
>>>
>>> Anyone see a problem with the below code?
>>>
>>> public class ShowProtocolsPanel extends Panel {
>>>  @SpringBean(name="ProtocolDAO")
>>>  private IProtocolDAO dao;
>>>
>>>  public ShowProtocolsPanel(String id) {
>>>  super(id);
>>>
>>>  IModel protocolsModel = new LoadableDetachableModel() {
>>>  protected Object load() {
>>>  return dao.findAll();
>>>  }
>>>  };
>>>
>>>  add(new PropertyListView("eachItem", protocolsModel) {
>>>  @Override
>>>  protected void populateItem(ListItem item) {
>>>  Protocol protocol = (Protocol) item.getModelObject();
>>>
>>>  item.add(new Label("keyword", protocol.getKeyword()));
>>>  item.add(new Label("description",
>>> protocol.getDescription()));
>>>  }
>>>  });
>>>  }
>>> }
>>>
>>>
>>> -
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>>
>> -
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Re: ClassCastException with ListView()

2008-05-30 Thread Ryan Gravener
How about changing PropertyListView to just ListView.

On Fri, May 30, 2008 at 11:41 AM, James Carman <[EMAIL PROTECTED]>
wrote:

> On Fri, May 30, 2008 at 11:38 AM, David Nedrow <[EMAIL PROTECTED]> wrote:
> >
> > On May 30, 2008, at 11:20 AM, James Carman wrote:
> >
> >> What is the type of item.getModelObject().  Have you run it through a
> >> debugger (or just simply put in a println)?
> >
> > Yes, I had done that first, thinking maybe I didn't understand how
> ListView
> > worked via the Model.
> >
> > The object returned by item.getModelObject().toString() is...
>
> Try doing, item.getModelObject().getClass().toString() (unless that's
> what you meant to type).  Can we see an example method from your DAO?
> What persistence library are you using (hibernate, jpa, jdo, etc.)?
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
Ryan Gravener
http://twitter.com/ryangravener


Re: ClassCastException with ListView()

2008-05-30 Thread James Carman
On Fri, May 30, 2008 at 11:38 AM, David Nedrow <[EMAIL PROTECTED]> wrote:
>
> On May 30, 2008, at 11:20 AM, James Carman wrote:
>
>> What is the type of item.getModelObject().  Have you run it through a
>> debugger (or just simply put in a println)?
>
> Yes, I had done that first, thinking maybe I didn't understand how ListView
> worked via the Model.
>
> The object returned by item.getModelObject().toString() is...

Try doing, item.getModelObject().getClass().toString() (unless that's
what you meant to type).  Can we see an example method from your DAO?
What persistence library are you using (hibernate, jpa, jdo, etc.)?

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ClassCastException with ListView()

2008-05-30 Thread David Nedrow


On May 30, 2008, at 11:20 AM, James Carman wrote:


What is the type of item.getModelObject().  Have you run it through a
debugger (or just simply put in a println)?


Yes, I had done that first, thinking maybe I didn't understand how  
ListView worked via the Model.


The object returned by item.getModelObject().toString() is...

com.vzbi.ncs.argfrp.jpa.netconf.Protocol

That's what baffles me about the cast exception.


On Fri, May 30, 2008 at 11:16 AM, David Nedrow <[EMAIL PROTECTED]>  
wrote:
I'm getting a cast exception when I attempt to pull a list element  
from the
model. I may be mishandling how I'm using the model, but this is  
basically

based on several tutorials I've looked at.

(Note, as people have pointed out here, I use the "old fashioned"  
naming

style for my interfaces and DAOs.)

Anyone see a problem with the below code?

public class ShowProtocolsPanel extends Panel {
  @SpringBean(name="ProtocolDAO")
  private IProtocolDAO dao;

  public ShowProtocolsPanel(String id) {
  super(id);

  IModel protocolsModel = new LoadableDetachableModel() {
  protected Object load() {
  return dao.findAll();
  }
  };

  add(new PropertyListView("eachItem", protocolsModel) {
  @Override
  protected void populateItem(ListItem item) {
  Protocol protocol = (Protocol) item.getModelObject();

  item.add(new Label("keyword", protocol.getKeyword()));
  item.add(new Label("description",
protocol.getDescription()));
  }
  });
  }
}


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ClassCastException with ListView()

2008-05-30 Thread James Carman
On Fri, May 30, 2008 at 11:24 AM, Thomas Mäder <[EMAIL PROTECTED]> wrote:
> What's the actual class of the returned from "item.getModelObject()"?
>

Jinx!

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ClassCastException with ListView()

2008-05-30 Thread Thomas Mäder
What's the actual class of the returned from "item.getModelObject()"?

On Fri, May 30, 2008 at 5:16 PM, David Nedrow <[EMAIL PROTECTED]> wrote:

> I'm getting a cast exception when I attempt to pull a list element from the
> model. I may be mishandling how I'm using the model, but this is basically
> based on several tutorials I've looked at.
>
> (Note, as people have pointed out here, I use the "old fashioned" naming
> style for my interfaces and DAOs.)
>
> Anyone see a problem with the below code?
>
> public class ShowProtocolsPanel extends Panel {
>@SpringBean(name="ProtocolDAO")
>private IProtocolDAO dao;
>
>public ShowProtocolsPanel(String id) {
>super(id);
>
>IModel protocolsModel = new LoadableDetachableModel() {
>protected Object load() {
>return dao.findAll();
>}
>};
>
>add(new PropertyListView("eachItem", protocolsModel) {
>@Override
>protected void populateItem(ListItem item) {
>Protocol protocol = (Protocol) item.getModelObject();
>
>item.add(new Label("keyword", protocol.getKeyword()));
>item.add(new Label("description",
> protocol.getDescription()));
>}
>});
>}
> }
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Re: ClassCastException with ListView()

2008-05-30 Thread James Carman
What is the type of item.getModelObject().  Have you run it through a
debugger (or just simply put in a println)?

On Fri, May 30, 2008 at 11:16 AM, David Nedrow <[EMAIL PROTECTED]> wrote:
> I'm getting a cast exception when I attempt to pull a list element from the
> model. I may be mishandling how I'm using the model, but this is basically
> based on several tutorials I've looked at.
>
> (Note, as people have pointed out here, I use the "old fashioned" naming
> style for my interfaces and DAOs.)
>
> Anyone see a problem with the below code?
>
> public class ShowProtocolsPanel extends Panel {
>@SpringBean(name="ProtocolDAO")
>private IProtocolDAO dao;
>
>public ShowProtocolsPanel(String id) {
>super(id);
>
>IModel protocolsModel = new LoadableDetachableModel() {
>protected Object load() {
>return dao.findAll();
>}
>};
>
>add(new PropertyListView("eachItem", protocolsModel) {
>@Override
>protected void populateItem(ListItem item) {
>Protocol protocol = (Protocol) item.getModelObject();
>
>item.add(new Label("keyword", protocol.getKeyword()));
>item.add(new Label("description",
> protocol.getDescription()));
>}
>});
>}
> }
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



ClassCastException with ListView()

2008-05-30 Thread David Nedrow
I'm getting a cast exception when I attempt to pull a list element  
from the model. I may be mishandling how I'm using the model, but this  
is basically based on several tutorials I've looked at.


(Note, as people have pointed out here, I use the "old fashioned"  
naming style for my interfaces and DAOs.)


Anyone see a problem with the below code?

public class ShowProtocolsPanel extends Panel {
@SpringBean(name="ProtocolDAO")
private IProtocolDAO dao;

public ShowProtocolsPanel(String id) {
super(id);

IModel protocolsModel = new LoadableDetachableModel() {
protected Object load() {
return dao.findAll();
}
};

add(new PropertyListView("eachItem", protocolsModel) {
@Override
protected void populateItem(ListItem item) {
Protocol protocol = (Protocol) item.getModelObject();

item.add(new Label("keyword", protocol.getKeyword()));
item.add(new Label("description",  
protocol.getDescription()));

}
});
}
}


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]