You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Arjun Dhar <dh...@yahoo.com> on 2011/03/09 11:28:55 UTC

Externalizing Page Mounts Via Spring

Hi,
 I wanted to externalize the Page Mounts using Spring.

Earlier in my "Application" class the code was like:

mount(new QueryStringUrlCodingStrategy("login", loginPage.class));


So What I did was:

...
                //Scan for All IMountLoaders in the context and get the
Mount points from them automatically
                Map mountLoadersMap =
springContext.getBeansOfType(IMountLoader.class);
                List mountPoints = ... Get Mount Points from Spring ...
        	for (IRequestTargetUrlCodingStrategy mountPoint : mountPoints) {
        		mount(mountPoint);
        	}
...


::::::::::::::::::::: SPRING FILE CORRESPONDING CONFIG :::::::::::::::::::::

        
	
	
		
		      
        		 
		      
		
	


However this leads to an Exception:
.springframework.beans.BeanInstantiationException: Could not instantiate
bean class [com.me.loginPage]: Constructor threw exception; nested exception
is java.lang.IllegalStateException: you can only locate or create sessions
in the context of a request cycle:

java.lang.IllegalStateException: you can only locate or create sessions in
the context of a request cycle
        at org.apache.wicket.Session.findOrCreate(Session.java:209)
        at org.apache.wicket.Session.get(Session.java:253)
        at
org.apache.wicket.Application$1.onInstantiation(Application.java:299)
        at
org.apache.wicket.Application.notifyComponentInstantiationListeners(Application.java:1093)



I wanna keep the code fluid and dont wanna wire it to any specific
@SpringBean kinda config. Is there an easy way out here?




-----
Don't take life too seriously, your'e not getting out it alive anyway!
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Externalizing-Page-Mounts-Via-Spring-tp3343247p3343247.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: Externalizing Page Mounts Via Spring

Posted by Attila Király <ki...@gmail.com>.
Your xml config tries to instantiate the page. Try this:

<bean
class="org.apache.wicket.request.target.coding.QueryStringUrlCodingStrategy"><constructor-arg
index="0" value="login" /><constructor-arg index="1"
value="com.me.loginPage" /></bean>

Attila

2011/3/9 Arjun Dhar <dh...@yahoo.com>

> Hi,
>  I wanted to externalize the Page Mounts using Spring.
>
> Earlier in my "Application" class the code was like:
>
> mount(new QueryStringUrlCodingStrategy("login", loginPage.class));
>
>
> So What I did was:
>
> ...
>                //Scan for All IMountLoaders in the context and get the
> Mount points from them automatically
>                Map mountLoadersMap =
> springContext.getBeansOfType(IMountLoader.class);
>                List mountPoints = ... Get Mount Points from Spring ...
>                for (IRequestTargetUrlCodingStrategy mountPoint :
> mountPoints) {
>                        mount(mountPoint);
>                }
> ...
>
>
> ::::::::::::::::::::: SPRING FILE CORRESPONDING CONFIG
> :::::::::::::::::::::
>
>
>
>
>
>
>
>
>
>
>
>
> However this leads to an Exception:
> .springframework.beans.BeanInstantiationException: Could not instantiate
> bean class [com.me.loginPage]: Constructor threw exception; nested
> exception
> is java.lang.IllegalStateException: you can only locate or create sessions
> in the context of a request cycle:
>
> java.lang.IllegalStateException: you can only locate or create sessions in
> the context of a request cycle
>        at org.apache.wicket.Session.findOrCreate(Session.java:209)
>        at org.apache.wicket.Session.get(Session.java:253)
>        at
> org.apache.wicket.Application$1.onInstantiation(Application.java:299)
>        at
>
> org.apache.wicket.Application.notifyComponentInstantiationListeners(Application.java:1093)
>
>
>
> I wanna keep the code fluid and dont wanna wire it to any specific
> @SpringBean kinda config. Is there an easy way out here?
>
>
>
>
> -----
> Don't take life too seriously, your'e not getting out it alive anyway!
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Externalizing-Page-Mounts-Via-Spring-tp3343247p3343247.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: Externalizing Page Mounts Via Spring

Posted by Arjun Dhar <dh...@yahoo.com>.
Both very helpful answers

@Mike ManderThe wicket-stuff thing is very cool indeed.
However, I'd like to mounting to be controlled by some
strategy/configuration in most cases which wont help if i have the
Annotation within the WebPage (but yes very very cool to know it exists).

@Attila Király : Yah worked, though one doesnt need index values since they
are in order; but using the String value instead of the object did the
trick!

thank you





-----
Don't take life too seriously, your'e not getting out it alive anyway!
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Externalizing-Page-Mounts-Via-Spring-tp3343247p3343358.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: Externalizing Page Mounts Via Spring

Posted by Mike Mander <wi...@gmx.de>.
Am 09.03.2011 11:28, schrieb Arjun Dhar:
> Hi,
>   I wanted to externalize the Page Mounts using Spring.
>
> Earlier in my "Application" class the code was like:
>
> mount(new QueryStringUrlCodingStrategy("login", loginPage.class));
>
>
> So What I did was:
>
> ...
>                  //Scan for All IMountLoaders in the context and get the
> Mount points from them automatically
>                  Map mountLoadersMap =
> springContext.getBeansOfType(IMountLoader.class);
>                  List mountPoints = ... Get Mount Points from Spring ...
>          	for (IRequestTargetUrlCodingStrategy mountPoint : mountPoints) {
>          		mount(mountPoint);
>          	}
> ...
>
>
> ::::::::::::::::::::: SPRING FILE CORRESPONDING CONFIG :::::::::::::::::::::
>
>
> 	
> 	
> 		
> 		
>          		
> 		
> 		
> 	
>
>
> However this leads to an Exception:
> .springframework.beans.BeanInstantiationException: Could not instantiate
> bean class [com.me.loginPage]: Constructor threw exception; nested exception
> is java.lang.IllegalStateException: you can only locate or create sessions
> in the context of a request cycle:
>
> java.lang.IllegalStateException: you can only locate or create sessions in
> the context of a request cycle
>          at org.apache.wicket.Session.findOrCreate(Session.java:209)
>          at org.apache.wicket.Session.get(Session.java:253)
>          at
> org.apache.wicket.Application$1.onInstantiation(Application.java:299)
>          at
> org.apache.wicket.Application.notifyComponentInstantiationListeners(Application.java:1093)
>
>
>
> I wanna keep the code fluid and dont wanna wire it to any specific
> @SpringBean kinda config. Is there an easy way out here?
>
>
>
>
> -----
> Don't take life too seriously, your'e not getting out it alive anyway!
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Externalizing-Page-Mounts-Via-Spring-tp3343247p3343247.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
>
>
>
There is a realy cool annotation project in wicket-stuff. With this you 
could externalize the packages to scan for pages. Mounting goes to page 
and scanned packages to spring-config.

Doc: 
http://wicketstuff.org/confluence/display/STUFFWIKI/wicketstuff-annotation

Just my 2$.
Mike

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