That won't work, since getObject takes a parameter of Component....what would I pass in?

On 4/2/06, karthik Guru < [EMAIL PROTECTED]> wrote:
The model isn't of type Blog. The object stored within
LoadableDetachableModel is of type Blog.

Blog blog = (Blog)blogModel.getObject( )

should hopefully work.?

On 4/2/06, Vincent Jenks <[EMAIL PROTECTED] > wrote:
> I'm just testing something out.  Since I use EJB3 and need lazy
> initialization I'm making an attempt to see if passing an object with a
> collection of lazily-loaded elements in an IModel, from page-to-page, will
> prevent a LazyInitializationException (Hibernate).
>
> I start here in the first page:
>
> public class ViewBlog extends WebPage
> {
>     public ViewBlog()
>     {
>         //get Blog in detached model
>         IModel blogModel = new LoadableDetachableModel()
>         {
>             protected Object load()
>             {
>                 return BlogProxy.getDefault(); //via proxy
>             }
>         };
>
>         //add panel components
>         add(new HeaderPanel("headerPanel", blogModel));
> ............
>
> ...and then in the HeaderPanel I do this:
>
> public class HeaderPanel extends Panel
> {
>     public HeaderPanel(String id, IModel blogModel)
>     {
>         super(id);
>
>          Blog blog = (Blog)blogModel; //EXCEPTION HERE!
> ..............
>
> I get this exception:
>
> java.lang.ClassCastException: com.myapp.ui.ViewBlog$1
>     at com.myapp.ui.panel.HeaderPanel.<init>(HeaderPanel.java :34)
>     at com.myapp.ui.ViewBlog.<init>(ViewBlog.java:53)
>     at
> sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
>     at
> sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java
> :39)
>     at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>     at
> java.lang.reflect.Constructor.newInstance (Constructor.java:494)
>     at java.lang.Class.newInstance0 (Class.java:350)
>     at java.lang.Class.newInstance(Class.java:303)
>
> How do I down-cast to Blog (entity bean) from the IModel param?
>


--
-- karthik --


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmdlnk&kid0944&bid$1720&dat1642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to