Hi,

I think the check in InMethod grid is wrong.

#isAjax() returns true if the request has either header "Wicket-Ajax"
or a parameter with the same name.

ART#get() checks whether the currently executed IRequestHandler or the
scheduled one after is is AjaxRequestTarget and returns it.
But since you do setResponsePage() you schedule a new
RenderPageRequestHandler after ART and that's why it is null at that
point.

On Fri, Jun 22, 2012 at 3:15 PM, Minas Manthos <[email protected]> wrote:
> Hi,
>
> Sorry, I have to explain detailed, but the situation is not complicated. I
> run into a NPE and I'm not sure if it's a wicket or inmethod-grid issue (or
> even my fault ;-), so I need your assistance where to fill a issue.
>
> Situation:
> I have a page with a inmethod grid. From there I can navigate to a page
> containing a edit form. The PageParameters contains a PageReference, so
> onSubmit I'm able to response back to the page I came from, like:
>
>    setResponsePage(reference.getPage());
>
> This works great when I'm using org.apache.wicket.markup.html.form.Button.
> When I'm using AjaxButton instead of Button I'm getting a NPE in
> com.inmethod.grid.common.AbstractGrid (line 130, constructor ->
> Behavior#afterRender)...
>
>   if (getWebRequest().isAjax()) {
>
> AjaxRequestTarget.get().appendJavaScript(getInitializationJavascript());
>   }
>
> ...this, because isAjax() is true, but AjaxRequestTarget.get() is null.
>
> Something I figure out: When I use setResponsePage to a new version (instead
> of using Page from PageManager) like:
>
>    Page page = reference.getPage();
>    setResponsePage(page.getClass(), page.getPageParameter()) ;
>
> ...isAjax() returns false, so NPE happens only when I use Page from
> PageManager (and I have to).
>
> So the question is:
> It's wrong that isAjax() returns true in case of Page from PageManager
> ...or...
> is the if-statement of inmethod AbstractGrid wrong?
>
> Any help would be appreciated.
>
> regards
> minas.
>
> If you want I can upload a minimal project to reproduce.
> wicket 1.5.7, wicketstuff 1.5.5
>
>
> --
> View this message in context: 
> http://apache-wicket.1842946.n4.nabble.com/NPE-with-setResponsePage-using-Page-from-PageManager-tp4650186.html
> Sent from the Forum for Wicket Core developers mailing list archive at 
> Nabble.com.



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

Reply via email to