You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by rikizz <mu...@gmail.com> on 2010/06/28 19:54:38 UTC

including wicket component into jsp

Hi all,

I know the many posts have been written on the same problem, but I have been
looking at the answers for 5 hours without having a simple example to work
with..
I basically need to include a single component (a menu) into my jsp pages,
because we are migrating the application from struts/jsp to wicket.
I tried with the following code but it didn't work:

WICKET APPLICATION:

public class WicketApplication extends WebApplication
{    
	public WicketApplication(){}
	public Class<HomePage> getHomePage(){	return HomePage.class;}
	@Override
	protected void init(){
		getMarkupSettings().setStripWicketTags(true);
	
getRequestCycleSettings().setRenderStrategy(IRequestCycleSettings.ONE_PASS_RENDER);
	}
}


PAGE MARKUP:
<html
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd"
>
    <head>  
        <title>Wicket Quickstart Archetype Homepage</title>
    </head>
    <body>
        <strong>Wicket Quickstart Archetype Homepage</strong>
        <br/><br/>
        message will be here
    </body>
</html>

PAGE CODE:

public class HomePage extends WebPage {
    public HomePage(final PageParameters parameters) {
        add(new Label("message", "If you see this message wicket is properly
configured and running"));
    }
    @Override
    protected void onRender(final MarkupStream markupStream){
    	System.out.println("RENDER OF THE PAGE!!");
    }
}

JSP PAGE:
<jsp:include page="/wic/" />

WEB.XML:

<web-app>
	<filter>
		<filter-name>wicket.embedwicket</filter-name>
 		<filter-class>embedwicket.WicketMenuFilter</filter-class>
		<init-param>
			<param-name>applicationClassName</param-name>
			<param-value>embedwicket.WicketApplication</param-value>
 		</init-param>
 	</filter>

 <filter-mapping>
  <filter-name>wicket.embedwicket</filter-name>
	<url-pattern>/wic/*</url-pattern>
	<dispatcher>INCLUDE</dispatcher>
	<dispatcher>REQUEST</dispatcher>
	<dispatcher>FORWARD</dispatcher>
 </filter-mapping>
</web-app>


WicketMenuFilter:
THIS IS MY CUSTOM WICKET FILTER TO MANAGE INCLUDE URI, AS IT WAS SUGGESTED
BY A GUY HERE:
http://apache-wicket.1842946.n4.nabble.com/embedding-Wicket-into-JSP-td1867715.html
http://apache-wicket.1842946.n4.nabble.com/embedding-Wicket-into-JSP-td1867715.html 

Basically I overrided the method
public String getRelativePath(HttpServletRequest request)

buy copying it and replacing the following lines:

String path = Strings.stripJSessionId(request.getRequestURI());
String contextPath = request.getContextPath();

with:

String requestURI = (String)
request.getAttribute("javax.servlet.include.request_uri");
if (requestURI == null) {
	requestURI = request.getRequestURI();
}
String path = Strings.stripJSessionId(requestURI);


I tried to debug the code and the filter is called, but then nothing is
displayed on the browser.. just a blank page..
If I call page directly(not the jsp) , it renders correctly..



Has anyone got a simple working example of this situation?

I would really appreciate id because I am going crazy..

Thank you very much.

Riccardo




-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/including-wicket-component-into-jsp-tp2271266p2271266.html
Sent from the Wicket - User 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: including wicket component into jsp

Posted by rikizz <mu...@gmail.com>.
Hi,

thanks for the reply. Yes i checked, and the wicket filter is called but
debugging wicket code i found that is not calling the onrender method. I
will investigate to find out way..
If anyone has a working example it would be great..
thanks
riccardo

On 28 June 2010 19:40, bht [via Apache Wicket] <
ml-node+2271310-405062206-282193@n4.nabble.com<ml...@n4.nabble.com>
> wrote:

> Have you checked that the wicket filter is called?
>
> I found that the struts filter does not call filterChain.doFilter().
> That may or may not be your problem depending whether anything else is
> in its path after it. I suspect however that this is what you need
> otherwise how can Wicket get the request if the wicket filter is not
> called?
>
> Regards
>
> Bernard
>
> On Mon, 28 Jun 2010 10:54:38 -0700 (PDT), you wrote:
>
> >
> >Hi all,
> >
> >I know the many posts have been written on the same problem, but I have
> been
> >looking at the answers for 5 hours without having a simple example to work
>
> >with..
> >I basically need to include a single component (a menu) into my jsp pages,
>
> >because we are migrating the application from struts/jsp to wicket.
> >I tried with the following code but it didn't work:
> >
> >WICKET APPLICATION:
> >
> >public class WicketApplication extends WebApplication
> >{
> > public WicketApplication(){}
> > public Class<HomePage> getHomePage(){ return HomePage.class;}
> > @Override
> > protected void init(){
> > getMarkupSettings().setStripWicketTags(true);
> >
> >getRequestCycleSettings().setRenderStrategy(IRequestCycleSettings.ONE_PASS_RENDER);
>
> > }
> >}
> >
> >
> >PAGE MARKUP:
> ><html
> >xmlns:wicket="
> http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd"
> >>
> >    <head>
> >        <title>Wicket Quickstart Archetype Homepage</title>
> >    </head>
> >    <body>
> >        <strong>Wicket Quickstart Archetype Homepage</strong>
> >        <br/><br/>
> >        message will be here
> >    </body>
> ></html>
> >
> >PAGE CODE:
> >
> >public class HomePage extends WebPage {
> >    public HomePage(final PageParameters parameters) {
> >        add(new Label("message", "If you see this message wicket is
> properly
> >configured and running"));
> >    }
> >    @Override
> >    protected void onRender(final MarkupStream markupStream){
> >     System.out.println("RENDER OF THE PAGE!!");
> >    }
> >}
> >
> >JSP PAGE:
> ><jsp:include page="/wic/" />
> >
> >WEB.XML:
> >
> ><web-app>
> > <filter>
> > <filter-name>wicket.embedwicket</filter-name>
> > <filter-class>embedwicket.WicketMenuFilter</filter-class>
> > <init-param>
> > <param-name>applicationClassName</param-name>
> > <param-value>embedwicket.WicketApplication</param-value>
> > </init-param>
> > </filter>
> >
> > <filter-mapping>
> >  <filter-name>wicket.embedwicket</filter-name>
> > <url-pattern>/wic/*</url-pattern>
> > <dispatcher>INCLUDE</dispatcher>
> > <dispatcher>REQUEST</dispatcher>
> > <dispatcher>FORWARD</dispatcher>
> > </filter-mapping>
> ></web-app>
> >
> >
> >WicketMenuFilter:
> >THIS IS MY CUSTOM WICKET FILTER TO MANAGE INCLUDE URI, AS IT WAS SUGGESTED
>
> >BY A GUY HERE:
> >
> http://apache-wicket.1842946.n4.nabble.com/embedding-Wicket-into-JSP-td1867715.html<http://apache-wicket.1842946.n4.nabble.com/embedding-Wicket-into-JSP-td1867715.html?by-user=t>
> >
> http://apache-wicket.1842946.n4.nabble.com/embedding-Wicket-into-JSP-td1867715.html<http://apache-wicket.1842946.n4.nabble.com/embedding-Wicket-into-JSP-td1867715.html?by-user=t>
>
> >
> >Basically I overrided the method
> >public String getRelativePath(HttpServletRequest request)
> >
> >buy copying it and replacing the following lines:
> >
> >String path = Strings.stripJSessionId(request.getRequestURI());
> >String contextPath = request.getContextPath();
> >
> >with:
> >
> >String requestURI = (String)
> >request.getAttribute("javax.servlet.include.request_uri");
> >if (requestURI == null) {
> > requestURI = request.getRequestURI();
> >}
> >String path = Strings.stripJSessionId(requestURI);
> >
> >
> >I tried to debug the code and the filter is called, but then nothing is
> >displayed on the browser.. just a blank page..
> >If I call page directly(not the jsp) , it renders correctly..
> >
> >
> >
> >Has anyone got a simple working example of this situation?
> >
> >I would really appreciate id because I am going crazy..
> >
> >Thank you very much.
> >
> >Riccardo
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2271310&i=0>
> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2271310&i=1>
>
>
>
> ------------------------------
>  View message @
> http://apache-wicket.1842946.n4.nabble.com/including-wicket-component-into-jsp-tp2271266p2271310.html
> To unsubscribe from including wicket component into jsp, click here<http://apache-wicket.1842946.n4.nabble.com/subscriptions/Unsubscribe.jtp?code=bXVyYS5yaWNjYXJkb0BnbWFpbC5jb218MjI3MTI2NnwtODk5MjkyMjU5>.
>
>
>

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/including-wicket-component-into-jsp-tp2271266p2271389.html
Sent from the Wicket - User mailing list archive at Nabble.com.

Re: including wicket component into jsp

Posted by bh...@actrix.gen.nz.
Have you checked that the wicket filter is called?

I found that the struts filter does not call filterChain.doFilter().
That may or may not be your problem depending whether anything else is
in its path after it. I suspect however that this is what you need
otherwise how can Wicket get the request if the wicket filter is not
called?

Regards

Bernard

On Mon, 28 Jun 2010 10:54:38 -0700 (PDT), you wrote:

>
>Hi all,
>
>I know the many posts have been written on the same problem, but I have been
>looking at the answers for 5 hours without having a simple example to work
>with..
>I basically need to include a single component (a menu) into my jsp pages,
>because we are migrating the application from struts/jsp to wicket.
>I tried with the following code but it didn't work:
>
>WICKET APPLICATION:
>
>public class WicketApplication extends WebApplication
>{    
>	public WicketApplication(){}
>	public Class<HomePage> getHomePage(){	return HomePage.class;}
>	@Override
>	protected void init(){
>		getMarkupSettings().setStripWicketTags(true);
>	
>getRequestCycleSettings().setRenderStrategy(IRequestCycleSettings.ONE_PASS_RENDER);
>	}
>}
>
>
>PAGE MARKUP:
><html
>xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd"
>>
>    <head>  
>        <title>Wicket Quickstart Archetype Homepage</title>
>    </head>
>    <body>
>        <strong>Wicket Quickstart Archetype Homepage</strong>
>        <br/><br/>
>        message will be here
>    </body>
></html>
>
>PAGE CODE:
>
>public class HomePage extends WebPage {
>    public HomePage(final PageParameters parameters) {
>        add(new Label("message", "If you see this message wicket is properly
>configured and running"));
>    }
>    @Override
>    protected void onRender(final MarkupStream markupStream){
>    	System.out.println("RENDER OF THE PAGE!!");
>    }
>}
>
>JSP PAGE:
><jsp:include page="/wic/" />
>
>WEB.XML:
>
><web-app>
>	<filter>
>		<filter-name>wicket.embedwicket</filter-name>
> 		<filter-class>embedwicket.WicketMenuFilter</filter-class>
>		<init-param>
>			<param-name>applicationClassName</param-name>
>			<param-value>embedwicket.WicketApplication</param-value>
> 		</init-param>
> 	</filter>
>
> <filter-mapping>
>  <filter-name>wicket.embedwicket</filter-name>
>	<url-pattern>/wic/*</url-pattern>
>	<dispatcher>INCLUDE</dispatcher>
>	<dispatcher>REQUEST</dispatcher>
>	<dispatcher>FORWARD</dispatcher>
> </filter-mapping>
></web-app>
>
>
>WicketMenuFilter:
>THIS IS MY CUSTOM WICKET FILTER TO MANAGE INCLUDE URI, AS IT WAS SUGGESTED
>BY A GUY HERE:
>http://apache-wicket.1842946.n4.nabble.com/embedding-Wicket-into-JSP-td1867715.html
>http://apache-wicket.1842946.n4.nabble.com/embedding-Wicket-into-JSP-td1867715.html 
>
>Basically I overrided the method
>public String getRelativePath(HttpServletRequest request)
>
>buy copying it and replacing the following lines:
>
>String path = Strings.stripJSessionId(request.getRequestURI());
>String contextPath = request.getContextPath();
>
>with:
>
>String requestURI = (String)
>request.getAttribute("javax.servlet.include.request_uri");
>if (requestURI == null) {
>	requestURI = request.getRequestURI();
>}
>String path = Strings.stripJSessionId(requestURI);
>
>
>I tried to debug the code and the filter is called, but then nothing is
>displayed on the browser.. just a blank page..
>If I call page directly(not the jsp) , it renders correctly..
>
>
>
>Has anyone got a simple working example of this situation?
>
>I would really appreciate id because I am going crazy..
>
>Thank you very much.
>
>Riccardo


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