Re: Call Ajax on Parent Page from Popup page.

2010-05-10 Thread Serban Balamaci

Thank you Jeremy,
It's working this way, although that label was a simple container for the
script:
script language=JavaScript wicket:id=refreshJS/script
I do not understand why it was not working. 

Now I have a problem in the sense that it's working only let's say the
first time. Because I get:
Ajax GET stopped because of precondition check,
url:?wicket:interface=:13:right-content-panel-container:right-content-panel-id:details-panel:tabs:panel:create-proposal-panel::IBehaviorListener:0:-1

I believe it's because this behavior is added in an ajax tab panel. If I
change the tab panel and then return back, I guess the behavior it's being
added again in the header and somehow gets mixed up. 

If I do not change tab panels it works every time.

It's not related to calling the function from the popup, I get this error
even if I do call the method as onclick in the same page.


-
http://balamaci.wordpress.com http://balamaci.wordpress.com 
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Call-Ajax-on-Parent-Page-from-Popup-page-tp2134034p2165281.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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



Re: Call Ajax on Parent Page from Popup page.

2010-05-10 Thread Serban Balamaci

I have solved it by overiding getPreconditionScript() in the behaviour to
return return true;:
protected CharSequence getPreconditionScript() {
return return true;
}

I hope I do not run into any problems with this.

Cheers.


-
http://balamaci.wordpress.com http://balamaci.wordpress.com 
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Call-Ajax-on-Parent-Page-from-Popup-page-tp2134034p2165297.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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



Call Ajax on Parent Page from Popup page.

2010-05-07 Thread Serban Balamaci

Hello.

I have a case where I'm trying to refresh the parent page from a popup page.

On the parent page I have:

AbstractDefaultAjaxBehavior clientSideCallingBehavior =
new AbstractDefaultAjaxBehavior() {
protected void respond(AjaxRequestTarget target) {
System.out.println(Refreshing ...);
}
};

Label lblCallback = new Label(refreshJS, new 
LoadableDetachableModel() {


protected Object load() {
String callbackScript = var callRefresh = 
function(value) { wicketAjaxGet('

+ clientSideCallingBehavior.getCallbackUrl(false)
+ ', null, null, function() {return true;}); 
return false;};

return callbackScript;
}
});
lblCallback.add(clientSideCallingBehavior);
lblCallback.setEscapeModelStrings(false);
add(lblCallback);


In the popup page I have on a link call the callRefresh method:
AjaxLink cancel = new AjaxLink(cancel) {
public void onClick(AjaxRequestTarget target) {
target.appendJavascript(window.opener.callRefresh(););
}
};

org.apache.wicket.protocol.http.request.InvalidUrlException: 
org.apache.wicket.WicketRuntimeException: component 
right-content-panel-container:right-content-panel-id:details-panel:tabs:panel:refreshJS 
not found on page 
com.asf.ufe.web.pages.evaluation.AccountEvaluationPage[id = 2], listener 
interface = [RequestListenerInterface name=IBehaviorListener, 
method=public abstract void 
org.apache.wicket.behavior.IBehaviorListener.onRequest()]
at 
org.apache.wicket.protocol.http.WebRequestCycleProcessor.resolve(WebRequestCycleProcessor.java:262)

at org.apache.wicket.RequestCycle.step(RequestCycle.java:1310)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
at 
org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:479)
at 
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:312)
at 
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)
Caused by: org.apache.wicket.WicketRuntimeException: component 
right-content-panel-container:right-content-panel-id:details-panel:tabs:panel:refreshJS 
not found on page 
com.asf.ufe.web.pages.evaluation.AccountEvaluationPage[id = 2], listener 
interface = [RequestListenerInterface name=IBehaviorListener, 
method=public abstract void 
org.apache.wicket.behavior.IBehaviorListener.onRequest()]
at 
org.apache.wicket.request.AbstractRequestCycleProcessor.resolveListenerInterfaceTarget(AbstractRequestCycleProcessor.java:426)
at 
org.apache.wicket.request.AbstractRequestCycleProcessor.resolveRenderedPage(AbstractRequestCycleProcessor.java:471)
at 
org.apache.wicket.protocol.http.WebRequestCycleProcessor.resolve(WebRequestCycleProcessor.java:144)

... 26 more

If I do make the call to callRefresh from the Parent Page(the same page 
where the behaviour is located) with onclick=callRefresh();return 
false; it works.


Do you have any ideeas? Does it have to be the last page in the PageMap 
for ajax to work?

Thanks.


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



Re: Call Ajax on Parent Page from Popup page.

2010-05-07 Thread Jeremy Thomerson
First thing I would try would be: get rid of that label.  You don't need it.
 Just add a behavior directly to the page or panel that adds the necessary
JS function:

add(new AbstractDefaultAjaxBehavior() {
private static final long serialVersionUID = 1L;
 @Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
response.renderJavascript(function callMeFromSomewhere() {  +
super.getCallbackScript() + };, callMeFromSomewhere);
}

@Override
protected void respond(AjaxRequestTarget target) {
System.out.println(I did something on the server side.);
target.appendJavascript(alert(' + new Date().toString() + '););
}
});


--
Jeremy Thomerson
http://www.wickettraining.com



On Fri, May 7, 2010 at 6:45 AM, Serban Balamaci serban.balam...@asf.rowrote:

 Hello.

 I have a case where I'm trying to refresh the parent page from a popup
 page.

 On the parent page I have:

AbstractDefaultAjaxBehavior clientSideCallingBehavior =
new AbstractDefaultAjaxBehavior() {
protected void respond(AjaxRequestTarget target) {
System.out.println(Refreshing ...);
}
};

Label lblCallback = new Label(refreshJS, new
 LoadableDetachableModel() {

protected Object load() {
String callbackScript = var callRefresh = function(value) {
 wicketAjaxGet('
+ clientSideCallingBehavior.getCallbackUrl(false)
+ ', null, null, function() {return true;}); return
 false;};
return callbackScript;
}
});
lblCallback.add(clientSideCallingBehavior);
lblCallback.setEscapeModelStrings(false);
add(lblCallback);


 In the popup page I have on a link call the callRefresh method:
AjaxLink cancel = new AjaxLink(cancel) {
public void onClick(AjaxRequestTarget target) {
target.appendJavascript(window.opener.callRefresh(););
}
};

 org.apache.wicket.protocol.http.request.InvalidUrlException:
 org.apache.wicket.WicketRuntimeException: component
 right-content-panel-container:right-content-panel-id:details-panel:tabs:panel:refreshJS
 not found on page com.asf.ufe.web.pages.evaluation.AccountEvaluationPage[id
 = 2], listener interface = [RequestListenerInterface name=IBehaviorListener,
 method=public abstract void
 org.apache.wicket.behavior.IBehaviorListener.onRequest()]
at
 org.apache.wicket.protocol.http.WebRequestCycleProcessor.resolve(WebRequestCycleProcessor.java:262)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1310)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
at
 org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:479)
at
 org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:312)
at
 org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)
 Caused by: org.apache.wicket.WicketRuntimeException: component
 right-content-panel-container:right-content-panel-id:details-panel:tabs:panel:refreshJS
 not found on page com.asf.ufe.web.pages.evaluation.AccountEvaluationPage[id
 = 2], listener interface = [RequestListenerInterface name=IBehaviorListener,
 method=public abstract void
 org.apache.wicket.behavior.IBehaviorListener.onRequest()]
at
 org.apache.wicket.request.AbstractRequestCycleProcessor.resolveListenerInterfaceTarget(AbstractRequestCycleProcessor.java:426)
at
 org.apache.wicket.request.AbstractRequestCycleProcessor.resolveRenderedPage(AbstractRequestCycleProcessor.java:471)
at
 org.apache.wicket.protocol.http.WebRequestCycleProcessor.resolve(WebRequestCycleProcessor.java:144)
... 26 more

 If I do make the call to callRefresh from the Parent Page(the same page
 where the behaviour is located) with onclick=callRefresh();return false;
 it works.

 Do you have any ideeas? Does it have to be the last page in the PageMap for
 ajax to work?
 Thanks.


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




Re: Call Ajax on Parent Page from Popup page.

2010-05-07 Thread Fernando Wermus
add a WindowClosedCallback. Then you can make the refresh to your parent
page.


On Fri, May 7, 2010 at 8:45 AM, Serban Balamaci serban.balam...@asf.rowrote:

 Hello.

 I have a case where I'm trying to refresh the parent page from a popup
 page.

 On the parent page I have:

AbstractDefaultAjaxBehavior clientSideCallingBehavior =
new AbstractDefaultAjaxBehavior() {
protected void respond(AjaxRequestTarget target) {
System.out.println(Refreshing ...);
}
};

Label lblCallback = new Label(refreshJS, new
 LoadableDetachableModel() {

protected Object load() {
String callbackScript = var callRefresh = function(value) {
 wicketAjaxGet('
+ clientSideCallingBehavior.getCallbackUrl(false)
+ ', null, null, function() {return true;}); return
 false;};
return callbackScript;
}
});
lblCallback.add(clientSideCallingBehavior);
lblCallback.setEscapeModelStrings(false);
add(lblCallback);


 In the popup page I have on a link call the callRefresh method:
AjaxLink cancel = new AjaxLink(cancel) {
public void onClick(AjaxRequestTarget target) {
target.appendJavascript(window.opener.callRefresh(););
}
};

 org.apache.wicket.protocol.http.request.InvalidUrlException:
 org.apache.wicket.WicketRuntimeException: component
 right-content-panel-container:right-content-panel-id:details-panel:tabs:panel:refreshJS
 not found on page com.asf.ufe.web.pages.evaluation.AccountEvaluationPage[id
 = 2], listener interface = [RequestListenerInterface name=IBehaviorListener,
 method=public abstract void
 org.apache.wicket.behavior.IBehaviorListener.onRequest()]
at
 org.apache.wicket.protocol.http.WebRequestCycleProcessor.resolve(WebRequestCycleProcessor.java:262)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1310)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
at
 org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:479)
at
 org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:312)
at
 org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)
 Caused by: org.apache.wicket.WicketRuntimeException: component
 right-content-panel-container:right-content-panel-id:details-panel:tabs:panel:refreshJS
 not found on page com.asf.ufe.web.pages.evaluation.AccountEvaluationPage[id
 = 2], listener interface = [RequestListenerInterface name=IBehaviorListener,
 method=public abstract void
 org.apache.wicket.behavior.IBehaviorListener.onRequest()]
at
 org.apache.wicket.request.AbstractRequestCycleProcessor.resolveListenerInterfaceTarget(AbstractRequestCycleProcessor.java:426)
at
 org.apache.wicket.request.AbstractRequestCycleProcessor.resolveRenderedPage(AbstractRequestCycleProcessor.java:471)
at
 org.apache.wicket.protocol.http.WebRequestCycleProcessor.resolve(WebRequestCycleProcessor.java:144)
... 26 more

 If I do make the call to callRefresh from the Parent Page(the same page
 where the behaviour is located) with onclick=callRefresh();return false;
 it works.

 Do you have any ideeas? Does it have to be the last page in the PageMap for
 ajax to work?
 Thanks.


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




-- 
Fernando Wermus.

www.linkedin.com/in/fernandowermus