Embedding a Wicket Page inside a DIV
I have a page built in SpringMVC. I have a iFrame in this page that loads a Wicket Page. I want to replace the iFrame with a DIV and load the Wicket page inside the DIV using Ajax. I used Prototype to load the wicket page. The page loads but the wicket javascript does not work anymore. I guess this is because the head tag from the wicket response is not processed. I then tried Wicket Ajax, but the call returns a SendRedirect. I guess we cannot load wicket Pages using Wicket Ajax. How do I get this to work ? Thanks Avinash P
Re: Embedding a Wicket Page inside a DIV
Am Mittwoch, den 26.08.2009, 01:29 -0500 schrieb Avinash palicharla: I have a page built in SpringMVC. I have a iFrame in this page that loads a Wicket Page. I want to replace the iFrame with a DIV and load the Wicket page inside the DIV using Ajax. good luck with this one.. does this page come from the same server? I used Prototype to load the wicket page. The page loads but the wicket javascript does not work anymore. I guess this is because the head tag from the wicket response is not processed. yes... 1) you can process the head 2) you can fake it, if you include wicket-*.js in your page mm:) - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Embedding a Wicket Page inside a DIV
Thank you :) Yes, the page comes from the same server. I got the Head to work by including the following. = script type=text/javascript src=app/resources/org.apache.wicket.markup.html.WicketEventReference/wicket-event.js/script script type=text/javascript src=app/resources/org.apache.wicket.ajax.WicketAjaxReference/wicket-ajax.js/script script type=text/javascript src=app/resources/org.apache.wicket.ajax.AbstractDefaultAjaxBehavior/wicket-ajax-debug.js/script script type=text/javascript id=wicket-ajax-debug-enable!--/*--![CDATA[/*!--*/ wicketAjaxDebugEnable=true; /*--]^]^*//script script === Now wicket Ajax work but we have a problem. All the wicket Ajax urls have only a query string and so the request goes to Spring MVC controller and not Wicket. To simplify the problem I removed Spring MVC out of context, ie created a new web app with one html page(with a DIV) and one Wicket Page and used Ajax to load the Wicket page into the DIV(of the HTML page). A smaller app will also save me a lot of time during build-deploy. Now I believe I need to do the following to get wicket Ajax to work 1. Somehow prepend the wicket url to the query string passed to Ajax. eg:- onclick=var wcall=wicketAjaxGet('* ?wicket:interface=:2:radioForm:xx:radioGroup:r1::IBehaviorListener:0:*',null,null, function() {return Wicket.$('r1a') != null;}.bind(this)); should become onclick=var wcall=wicketAjaxGet(*'/myapp/wicket/myPage.html ?wicket:interface=:2:radioForm:xx:radioGroup:r1::IBehaviorListener:0:*',null,null, function() {return Wicket.$('r1a') != null;}.bind(this)); I have no idea of how to change the URL. I will dig deeper and find out if i can do that. Any advice in the mean time will be of great help. Thanks, Avinash P On Wed, Aug 26, 2009 at 4:35 AM, Michael Mosmann mich...@mosmann.de wrote: Am Mittwoch, den 26.08.2009, 01:29 -0500 schrieb Avinash palicharla: I have a page built in SpringMVC. I have a iFrame in this page that loads a Wicket Page. I want to replace the iFrame with a DIV and load the Wicket page inside the DIV using Ajax. good luck with this one.. does this page come from the same server? I used Prototype to load the wicket page. The page loads but the wicket javascript does not work anymore. I guess this is because the head tag from the wicket response is not processed. yes... 1) you can process the head 2) you can fake it, if you include wicket-*.js in your page mm:) - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Embedding a Wicket Page inside a DIV
Solved the problem. We need to extend WebRequestCycleProcessor and return that from our Application class. We also need to extend WebRequestCodingStrategy and return that from our WebRequestCycleProcessor . Following is the code. public class MyWicketApp extends WebApplication{ protected IRequestCycleProcessor newRequestCycleProcessor(){ return new MyWebRequestCycleProcessor(); } } public class MyWebRequestCycleProcessor extends WebRequestCycleProcessor{ protected IRequestCodingStrategy newRequestCodingStrategy(){ return new MyWebRequestCodingStrategy(/app); } } The real stuff is in the following class. public class MyWebRequestCodingStrategy extends WebRequestCodingStrategy{ // The path to appent to the contextPath to get the filter path. private String wicketFilterPath; public MyWebRequestCodingStrategy(String wicketFilterPath){ this.wicketFilterPath = wicketFilterPath; } protected CharSequence encode(RequestCycle requestCycle, IListenerInterfaceRequestTarget requestTarget){ // We know that WebRequestCodingStrategy#encode(RequestCycle, IListenerInterfaceRequestTarget) returns a AppendingStringBuffer. AppendingStringBuffer url = (AppendingStringBuffer)super.encode(requestCycle, requestTarget); if(isRequestFromDIV((WebRequest)requestCycle.getRequest())){ if(url.indexOf(?) -1){ url.append(); } url.append(pageLoadedInDiv=true); * String urlPrefix = getRequestURI((WebRequest)requestCycle.getRequest()); //TODO: optimize. Work with AppendingStringBuffer.value(). url = new AppendingStringBuffer(urlPrefix + url);* } return url; } protected CharSequence encode(RequestCycle requestCycle, ISharedResourceRequestTarget requestTarget){ AppendingStringBuffer url = (AppendingStringBuffer)super.encode(requestCycle, requestTarget); // Make an absolut reference to the resource. Reletive will not work. String urlPrefix = getContextPath((WebRequest)requestCycle.getRequest())+wicketFilterPath+'/'; //TODO: optimize. url = new AppendingStringBuffer(urlPrefix+url); return url; } private String getContextPath(WebRequest request) { return request.getHttpServletRequest().getContextPath(); } private String getRequestURI(WebRequest request) { return request.getHttpServletRequest().getRequestURI(); } private boolean isRequestFromDIV(WebRequest request) { // To identify our special request. We dont need this if we choose to make every path absolute. return true.equals(request.getParameter(pageLoadedInDiv)); } } The html file. html xmlns=http://www.w3.org/1999/xhtml; head xmlns:wicket=http://wicket.apache.org; script src=prototype-1.6.0.3.js/script script type=text/javascript src=app/resources/org.apache.wicket.markup.html.WicketEventReference/wicket-event.js/script script type=text/javascript src=app/resources/org.apache.wicket.ajax.WicketAjaxReference/wicket-ajax.js/script script type=text/javascript src=app/resources/org.apache.wicket.ajax.AbstractDefaultAjaxBehavior/wicket-ajax-debug.js/script script type=text/javascript id=wicket-ajax-debug-enable!--/*--![CDATA[/*!--*/ wicketAjaxDebugEnable=true; /*--]^]^*//script script function loadWicketContainer(){ *new Ajax.Updater('wicketContainer', '/wsb/app/page_1.jas?pageLoadedInDiv=true', { method: 'get' }); * } /script /head body onload=loadWicketContainer() div id=wicketContainer /div /body /html Thanks Avinash P On Wed, Aug 26, 2009 at 7:09 AM, Avinash palicharla avinashredd...@gmail.com wrote: Thank you :) Yes, the page comes from the same server. I got the Head to work by including the following. = script type=text/javascript src=app/resources/org.apache.wicket.markup.html.WicketEventReference/wicket-event.js/script script type=text/javascript src=app/resources/org.apache.wicket.ajax.WicketAjaxReference/wicket-ajax.js/script script type=text/javascript src=app/resources/org.apache.wicket.ajax.AbstractDefaultAjaxBehavior/wicket-ajax-debug.js/script script type=text/javascript id=wicket-ajax-debug-enable!--/*--![CDATA[/*!--*/ wicketAjaxDebugEnable=true; /*--]^]^*//script script === Now wicket Ajax work but we have a problem. All the wicket Ajax urls have only a query string and so the request goes to Spring MVC controller and not Wicket. To simplify the problem I removed Spring MVC out of context, ie created a new web app with one html page(with a DIV) and one Wicket Page and used Ajax to load the Wicket page into the DIV(of the HTML page). A smaller app will also save me a lot of time during build-deploy. Now I believe I need to do the following to get wicket Ajax to work 1. Somehow prepend the wicket url to the query string passed to Ajax. eg:- onclick=var wcall=wicketAjaxGet('*