You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by fachhoch <fa...@gmail.com> on 2010/10/01 23:02:46 UTC

instantiate panels in a spring bean

I am trying to instantiate  some panels inside init-method of a spring bean .

I end up getting this excpetion


org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'userMenuItems': Invocation of init method failed; nested
exception is org.apache.wicket.WicketRuntimeException: There is no
application attached to current thread main




please tell me is it not right to instantiate a panel   inside  a spring
bean ?



-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/instantiate-panels-in-a-spring-bean-tp2946859p2946859.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: instantiate panels in a spring bean

Posted by Arjun Dhar <dh...@yahoo.com>.
...lol I just realized both you guys have over 200 posts. haha ..well i'd
still like to have a crack at the problem :)
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/instantiate-panels-in-a-spring-bean-tp2946859p2952156.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: instantiate panels in a spring bean

Posted by fachhoch <fa...@gmail.com>.
Actually this is groovy script, I load this using   spring lang tags


<lang:groovy id="menuItems" 
        script-source="classpath:mypackage/UserMenuItems.groovy">
    </lang:groovy>
 


please  help me.

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/instantiate-panels-in-a-spring-bean-tp2946859p2953634.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: instantiate panels in a spring bean

Posted by Ben Tilford <be...@tilford.info>.
What are you using to build the project? If your doing stub generation
(mixed java & groovy project) see if the stubs look right. There are a
few bugs in the stub generator when dealing with inner classes but it
shouldn't have compiled in that case.

On 10/2/10, fachhoch <fa...@gmail.com> wrote:
>
> I added super for subclasses it still did not work , as I said it worked
> with
> java the same code when comming from .groovy should work right ?  if it is
> not do I have to give some special treatment for wicket groovy compoments ?
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/instantiate-panels-in-a-spring-bean-tp2946859p2952942.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: instantiate panels in a spring bean

Posted by fachhoch <fa...@gmail.com>.
I added super for subclasses it still did not work , as I said it worked with
java the same code when comming from .groovy should work right ?  if it is
not do I have to give some special treatment for wicket groovy compoments ?
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/instantiate-panels-in-a-spring-bean-tp2946859p2952942.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: instantiate panels in a spring bean

Posted by Ben Tilford <be...@tilford.info>.
I think its just that the subclasses need to call super() or
super(wicketId).

On Sat, Oct 2, 2010 at 9:07 PM, fachhoch <fa...@gmail.com> wrote:

>
> here is my code
>
>
> class UserMenuItems implements MenuItems {
>
>        @Resource(name="manualService")
>        private ManualService  manualService;
>
>
>        List<Component> components ;
>
>
>        //@PostConstruct
>        void myInit(){
>                components= new ArrayList<Component>();
>                components.add (new UserGuidePanel());
>                components.add (new OMBCircularPanel());
>                components.add (new SendComments());
>        }
>
>        @Override
>        public List<Component> getComponents() {
>                myInit();
>                return components;
>        }
>
>
>        private abstract  class CustomPanel  extends  Panel implements
> IMarkupResourceStreamProvider{
>                public CustomPanel() {
>                        super(MenuItems.menuItemId);
>                }
>                public IResourceStream
> getMarkupResourceStream(MarkupContainer
> container,Class<?> containerClass){
>                        return new StringResourceStream(getMarkUp());
>                }
>
>                protected abstract String getMarkUp();
>        }
>
>        private  class UserGuidePanel   extends  CustomPanel {
>                public UserGuidePanel() {
>                        add(new Link("link"){
>                                public void onClick() {
>
>  manualService.getManualBytes(UserContextHolder.getOrgAbbrev());
>                                }
>                        });
>                }
>                @Override
>                protected String getMarkUp() {
>                                        return """
>                                        <wicket:panel>
>                                                 # User Guide
>                                        </wicket:panel>
>                                """;
>                }
>        }
>
> }
>
>
>
>
>
>
> now I got a new problem ,
> this is a groovy file and when I call getComponents method I get this error
>
> Caused by: java.lang.reflect.InvocationTargetException
>        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:513)
>        at
>
> org.apache.wicket.session.DefaultPageFactory.createPage(DefaultPageFactory.java:188)
>        ... 43 more
> Caused by: java.lang.NoSuchMethodError:
> gov.hhs.acf.web.util.UserMenuItems$CustomPanel: method <init>()V not found
>        at
>
> gov.hhs.acf.web.util.UserMenuItems$ArtmsUserGuidePanel.<init>(UserMenuItems.groovy)
>        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:513)
>        at
>
> org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
>        at
>
> org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:107)
>        at
>
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:200)
>        at
> gov.hhs.acf.web.util.UserMenuItems.myInit(UserMenuItems.groovy:33)
>        at gov.hhs.acf.web.util.UserMenuItems$myInit.callCurrent(Unknown
> Source)
>        at
> gov.hhs.acf.web.util.UserMenuItems.getComponents(UserMenuItems.groovy:41)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:597)
>        at
>
> org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(LazyInitProxyFactory.java:416)
>        at org.apache.wicket.proxy.$Proxy142.getComponents(Unknown Source)
>
>
>
> I inject this bean  in my page and call getComponents method  and I end up
> with the error above .I wont get this error if I make this a .java , please
> tell me is it any different to write  a wicket component in groovy ?
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/instantiate-panels-in-a-spring-bean-tp2946859p2952922.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: instantiate panels in a spring bean

Posted by fachhoch <fa...@gmail.com>.
it need not bepublic   I commented annotation @PostConstruct  so its only 
used inside  the class.
 
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/instantiate-panels-in-a-spring-bean-tp2946859p2954369.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: instantiate panels in a spring bean

Posted by Arjun Dhar <dh...@yahoo.com>.
May or may not be consequential, why is "myInit" not public? 
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/instantiate-panels-in-a-spring-bean-tp2946859p2953812.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: instantiate panels in a spring bean

Posted by fachhoch <fa...@gmail.com>.
here is my code



class UserMenuItems implements MenuItems {

	@Resource(name="manualService")
	private ManualService  manualService;
	
	
	List<Component> components ;
	
	
	//@PostConstruct
	void myInit(){
		components= new ArrayList<Component>();
		components.add (new UserGuidePanel());
		components.add (new OMBCircularPanel());
		components.add (new SendComments());
	}  
	
	@Override
	public List<Component> getComponents() {
		myInit();
		return components;
	}
	
		
	private abstract  class CustomPanel  extends  Panel implements 
IMarkupResourceStreamProvider{
		public CustomPanel() {
			super(MenuItems.menuItemId);
		}
		public IResourceStream getMarkupResourceStream(MarkupContainer
container,Class<?> containerClass){
			return new StringResourceStream(getMarkUp());
		}

		protected abstract String getMarkUp();
	}
	
	private  class UserGuidePanel   extends  CustomPanel {
		public UserGuidePanel() {
			add(new Link("link"){
				public void onClick() {
					manualService.getManualBytes(UserContextHolder.getOrgAbbrev());
				}
			});
		}
		@Override
		protected String getMarkUp() {
					return """
					<wicket:panel>
						 # User Guide 
					</wicket:panel>
				""";
		}
	}
        
}






now I got a new problem ,
this is a groovy file and when I call getComponents method I get this error 

Caused by: java.lang.reflect.InvocationTargetException
	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:513)
	at
org.apache.wicket.session.DefaultPageFactory.createPage(DefaultPageFactory.java:188)
	... 43 more
Caused by: java.lang.NoSuchMethodError:
gov.hhs.acf.web.util.UserMenuItems$CustomPanel: method <init>()V not found
	at
gov.hhs.acf.web.util.UserMenuItems$ArtmsUserGuidePanel.<init>(UserMenuItems.groovy)
	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:513)
	at
org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
	at
org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:107)
	at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:200)
	at gov.hhs.acf.web.util.UserMenuItems.myInit(UserMenuItems.groovy:33)
	at gov.hhs.acf.web.util.UserMenuItems$myInit.callCurrent(Unknown Source)
	at
gov.hhs.acf.web.util.UserMenuItems.getComponents(UserMenuItems.groovy:41)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at
org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(LazyInitProxyFactory.java:416)
	at org.apache.wicket.proxy.$Proxy142.getComponents(Unknown Source)



I inject this bean  in my page and call getComponents method  and I end up
with the error above .I wont get this error if I make this a .java , please
tell me is it any different to write  a wicket component in groovy ?
   
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/instantiate-panels-in-a-spring-bean-tp2946859p2952922.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: instantiate panels in a spring bean

Posted by Igor Vaynberg <ig...@gmail.com>.
the application object is the Application subclass. the instances
retrieved are not bound to it.

-igor

On Sat, Oct 2, 2010 at 8:01 PM, Arjun Dhar <dh...@yahoo.com> wrote:
>
> I think there has been a huge ball of confusion here created on my part due
> to certain concepts i was focused on. The reference to  ThreadLocal
> originated from here:
>
> https://cwiki.apache.org/WICKET/spring.html
> "Application Object Approach"
> ... Wicket allows you to provide a custom factory for creating this object,
> the wicket-contrib-spring project provides such a factory
> (SpringWebApplicationFactory) that, instead of creating an instance, pulls
> it out of the spring application context. Wicket keeps the instance of the
> application object in a threadlocal variable and provides various helper
> methods in components to get to it, so it is easy to retrieve dependencies
> in wicket components...."
>
> So the ApplicationObject is bound to the ThreadLocal and I think the Spring
> Dependencies are bound to the Applicaiton Object, so I made a logical
> connection there.
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/instantiate-panels-in-a-spring-bean-tp2946859p2952889.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: instantiate panels in a spring bean

Posted by Arjun Dhar <dh...@yahoo.com>.
I think there has been a huge ball of confusion here created on my part due
to certain concepts i was focused on. The reference to  ThreadLocal
originated from here:

https://cwiki.apache.org/WICKET/spring.html
"Application Object Approach"
... Wicket allows you to provide a custom factory for creating this object,
the wicket-contrib-spring project provides such a factory
(SpringWebApplicationFactory) that, instead of creating an instance, pulls
it out of the spring application context. Wicket keeps the instance of the
application object in a threadlocal variable and provides various helper
methods in components to get to it, so it is easy to retrieve dependencies
in wicket components...."

So the ApplicationObject is bound to the ThreadLocal and I think the Spring
Dependencies are bound to the Applicaiton Object, so I made a logical
connection there.

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/instantiate-panels-in-a-spring-bean-tp2946859p2952889.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: instantiate panels in a spring bean

Posted by James Carman <ja...@carmanconsulting.com>.
I was wondering the same thing, but I figured he was rolling, so I
just let it slide.

On Sat, Oct 2, 2010 at 1:21 PM, Igor Vaynberg <ig...@gmail.com> wrote:
> where is this threadlocal everyone is talking about?
>
> -igor
>
> On Sat, Oct 2, 2010 at 12:25 AM, Arjun Dhar <dh...@yahoo.com> wrote:
>>
>> On point i'd like to clarify myself; so @SpringBean is explained with
>> Services in mind, but yes there is no reason for it to represent PROTOTYPE
>> beans. But thats the whole point, thing conversation is not about
>> @SpringBean VS PROTITYPE. @SpringBean can be using to fetch a bean from
>> Spring and put it into ThreadLocal. If within SPRING that  is defined with
>> PROTOTYPE scope then you get a PROTOTYPE bean.... so there is no comparison.
>>
>> The difference is in the concept of injecting components vs services.
>> --
>> View this message in context: http://apache-wicket.1842946.n4.nabble.com/instantiate-panels-in-a-spring-bean-tp2946859p2952224.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: instantiate panels in a spring bean

Posted by Igor Vaynberg <ig...@gmail.com>.
where is this threadlocal everyone is talking about?

-igor

On Sat, Oct 2, 2010 at 12:25 AM, Arjun Dhar <dh...@yahoo.com> wrote:
>
> On point i'd like to clarify myself; so @SpringBean is explained with
> Services in mind, but yes there is no reason for it to represent PROTOTYPE
> beans. But thats the whole point, thing conversation is not about
> @SpringBean VS PROTITYPE. @SpringBean can be using to fetch a bean from
> Spring and put it into ThreadLocal. If within SPRING that  is defined with
> PROTOTYPE scope then you get a PROTOTYPE bean.... so there is no comparison.
>
> The difference is in the concept of injecting components vs services.
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/instantiate-panels-in-a-spring-bean-tp2946859p2952224.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: instantiate panels in a spring bean

Posted by Arjun Dhar <dh...@yahoo.com>.
On point i'd like to clarify myself; so @SpringBean is explained with
Services in mind, but yes there is no reason for it to represent PROTOTYPE
beans. But thats the whole point, thing conversation is not about
@SpringBean VS PROTITYPE. @SpringBean can be using to fetch a bean from
Spring and put it into ThreadLocal. If within SPRING that  is defined with
PROTOTYPE scope then you get a PROTOTYPE bean.... so there is no comparison.

The difference is in the concept of injecting components vs services.
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/instantiate-panels-in-a-spring-bean-tp2946859p2952224.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: instantiate panels in a spring bean

Posted by James Carman <ja...@carmanconsulting.com>.
On Sat, Oct 2, 2010 at 3:37 AM, Ben Tilford <be...@tilford.info> wrote:
> This might interest you http://kenai.com/projects/joint/pages/WicketExample
>
> Its using the netbeans lookup api instead of spring to build a menu based on
> what components are available on the classpath.

Very cool idea, but not exactly relevant to what we're discussing
here.  Very nice way of dynamically building a menu system in your
application.  Just drop in a new "Navigatable" class and it gets
auto-discovered.  Very cool, indeed!

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: instantiate panels in a spring bean

Posted by Ben Tilford <be...@tilford.info>.
This might interest you http://kenai.com/projects/joint/pages/WicketExample

Its using the netbeans lookup api instead of spring to build a menu based on
what components are available on the classpath.
On Oct 2, 2010 12:32 AM, "James Carman" <ja...@carmanconsulting.com> wrote:
> So, why would you use the initialize method of a prototype bean to
> instantiate components rather than just use whatever method you're
> going to call on that bean to instantiate your components? Also, why
> not just use a regular spring bean and just have some factory method
> that creates components for you (I do this in my application). The
> point is that it's silly to use the init() method to instantiate
> components. If your bean is non-prototype, then you just flat out
> can't do that. Components aren't shareable. If it is prototype,
> there really is no need.
>
> On Sat, Oct 2, 2010 at 3:12 AM, Arjun Dhar <dh...@yahoo.com> wrote:
>>
>> https://cwiki.apache.org/WICKET/spring.html
>>
>> ..As per my understanding @SpringBean is to inject context services (like
>> DAO's etc ..assumed to be SINGLETON's) and puts them in a ThreadLocal to
be
>> available to Wicket Components. Its a convenient way to provide Context
to
>> all Wicket components. The purpose seems clear "Context sharing of
>> services".
>> I'd further assume these services to be stateless and also
Non-Serializable.
>> Since its objects in a ThreadLocal, I guess one can also use it for
>> injecting components in theory. ..I've never tried it that way, if you
have
>> please let me know.
>>
>> Injecting components on the other hand is about Injecting serialized
objects
>> (which should be replicatable across in a cluster; unlike your DAO's).
..ok,
>> lets not over complicate it by going that far. But from the problem
>> described it seems he wants to "Inject Components" not "Services". ..and
I
>> think that is fair.
>>
>> My point is clear, if you want to "inject" components, then those have to
be
>> in PROTOTYPE scope. "@SpringBean" is just an annotation for convenience
but
>> all the documentation & examples point to it being convenient to provide
>> "Inject Services" to wicket components not "Injected components".
>>
>> One is Stateless the other Stateful and serializable, I think
conceptually
>> that is a big difference.
>> --
>> View this message in context:
http://apache-wicket.1842946.n4.nabble.com/instantiate-panels-in-a-spring-bean-tp2946859p2952221.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

Re: instantiate panels in a spring bean

Posted by Arjun Dhar <dh...@yahoo.com>.
"The point is that it's silly to use the init() "  ---> I agree! I never
mentioned init() :)
I think we were on different pages. I thought you were asking him "Why would
you want to use spring to inject components ..you had a very short reply to
the intiial question :) ". I missed the point that it was on the basis of
"init()" that you were opposing what he was doing. 

I understand your point.


-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/instantiate-panels-in-a-spring-bean-tp2946859p2952240.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: instantiate panels in a spring bean

Posted by James Carman <ja...@carmanconsulting.com>.
So, why would you use the initialize method of a prototype bean to
instantiate components rather than just use whatever method you're
going to call on that bean to instantiate your components?  Also, why
not just use a regular spring bean and just have some factory method
that creates components for you (I do this in my application). The
point is that it's silly to use the init() method to instantiate
components.  If your bean is non-prototype, then you just flat out
can't do that.  Components aren't shareable.  If it is prototype,
there really is no need.

On Sat, Oct 2, 2010 at 3:12 AM, Arjun Dhar <dh...@yahoo.com> wrote:
>
> https://cwiki.apache.org/WICKET/spring.html
>
> ..As per my understanding @SpringBean is to inject context services (like
> DAO's etc ..assumed to be SINGLETON's) and puts them in a ThreadLocal to be
> available to Wicket Components. Its a convenient way to provide Context to
> all Wicket components. The purpose seems clear "Context sharing of
> services".
> I'd further assume these services to be stateless and also Non-Serializable.
> Since its objects in a ThreadLocal, I guess one can also use it for
> injecting components in theory. ..I've never tried it that way, if you have
> please let me know.
>
> Injecting components on the other hand is about Injecting serialized objects
> (which should be replicatable across in a cluster; unlike your DAO's). ..ok,
> lets not over complicate it by going that far. But from the problem
> described it seems he wants to "Inject Components" not "Services". ..and I
> think that is fair.
>
> My point is clear, if you want to "inject" components, then those have to be
> in PROTOTYPE scope. "@SpringBean" is just an annotation for convenience but
> all the documentation & examples point to it being convenient to provide
> "Inject Services" to wicket components not "Injected components".
>
> One is Stateless the other Stateful and serializable, I think conceptually
> that is a big difference.
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/instantiate-panels-in-a-spring-bean-tp2946859p2952221.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: instantiate panels in a spring bean

Posted by Arjun Dhar <dh...@yahoo.com>.
https://cwiki.apache.org/WICKET/spring.html

..As per my understanding @SpringBean is to inject context services (like
DAO's etc ..assumed to be SINGLETON's) and puts them in a ThreadLocal to be
available to Wicket Components. Its a convenient way to provide Context to
all Wicket components. The purpose seems clear "Context sharing of
services".
I'd further assume these services to be stateless and also Non-Serializable.
Since its objects in a ThreadLocal, I guess one can also use it for
injecting components in theory. ..I've never tried it that way, if you have
please let me know.

Injecting components on the other hand is about Injecting serialized objects
(which should be replicatable across in a cluster; unlike your DAO's). ..ok,
lets not over complicate it by going that far. But from the problem
described it seems he wants to "Inject Components" not "Services". ..and I
think that is fair.

My point is clear, if you want to "inject" components, then those have to be
in PROTOTYPE scope. "@SpringBean" is just an annotation for convenience but
all the documentation & examples point to it being convenient to provide
"Inject Services" to wicket components not "Injected components". 

One is Stateless the other Stateful and serializable, I think conceptually
that is a big difference.
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/instantiate-panels-in-a-spring-bean-tp2946859p2952221.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: instantiate panels in a spring bean

Posted by James Carman <ja...@carmanconsulting.com>.
On Fri, Oct 1, 2010 at 11:41 PM, Arjun Dhar <dh...@yahoo.com> wrote:
>
> I'm a dud in Wicket compared to other geniuses around here but I'd like to
> have a crack if you dont mind.
> Note: Ensure your beans are PROTOTYPE not SINGLETON (default); since you
> really should not retain references to Wicket components ...as Igor
> mentioned in a recent post!
>

Ok, and what would be the point of using a prototype bean instead of
just using the @SpringBean injection technique (assuming you're using
spring so that you can access your dependencies easily)?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: instantiate panels in a spring bean

Posted by Arjun Dhar <dh...@yahoo.com>.
Hey dont mean to arge here .... but Why not? 

You can get beans in PROTOTYPE scope (does not have to be re-usable; this
aspect of Spring is all about IOC) and leverage IOC to inject panels rather
than hard wiring them in the code. I like the idea. "fachhoch " can you
please paste the code, I'd like to work on the problem.

I'm a dud in Wicket compared to other geniuses around here but I'd like to
have a crack if you dont mind.
Note: Ensure your beans are PROTOTYPE not SINGLETON (default); since you
really should not retain references to Wicket components ...as Igor
mentioned in a recent post!

thanks.



-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/instantiate-panels-in-a-spring-bean-tp2946859p2952155.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: instantiate panels in a spring bean

Posted by James Carman <ja...@carmanconsulting.com>.
What do you plan on doing with these panels?  They can't be re-used.

On Fri, Oct 1, 2010 at 5:02 PM, fachhoch <fa...@gmail.com> wrote:
>
> I am trying to instantiate  some panels inside init-method of a spring bean .
>
> I end up getting this excpetion
>
>
> org.springframework.beans.factory.BeanCreationException: Error creating bean
> with name 'userMenuItems': Invocation of init method failed; nested
> exception is org.apache.wicket.WicketRuntimeException: There is no
> application attached to current thread main
>
>
>
>
> please tell me is it not right to instantiate a panel   inside  a spring
> bean ?
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/instantiate-panels-in-a-spring-bean-tp2946859p2946859.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org