Re: Embedding a Wicket Page inside a DIV

2009-08-26 Thread Avinash palicharla
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.

http://www.w3.org/1999/xhtml";>
http://wicket.apache.org";>







]^]^>*/

  function loadWicketContainer(){
   *new Ajax.Updater('wicketContainer',
'/wsb/app/page_1.jas?pageLoadedInDiv=true', { method: 'get' }); *
  }
  








 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.
>
> =
>  src="app/resources/org.apache.wicket.markup.html.WicketEventReference/wicket-event.js">
>
>  src="app/resources/org.apache.wicket.ajax.WicketAjaxReference/wicket-ajax.js">
>
>  src="app/resources/org.apache.wicket.ajax.AbstractDefaultAjaxBehavior/wicket-ajax-debug.js">
>
>  id="wicket-ajax-debug-enable">]^]^>*/
> 

Re: Embedding a Wicket Page inside a DIV

2009-08-26 Thread Avinash palicharla
Thank you :)

Yes, the page comes from the same server.

I got the Head to work by including the following.
=






]^]^>*/

Re: Embedding a Wicket Page inside a DIV

2009-08-26 Thread Michael Mosmann
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  tag
> from the wicket response is not processed.

yes...
1) you can process the 
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



Embedding a Wicket Page inside a DIV

2009-08-25 Thread 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.

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  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