Now in the default constructor of my page I added a behavior linking to the page with page parameters and I added such a constructor taking parameters. In this constructor, I set a new AjaxRequestTarget on the request cycle and add some component to the target.
When I request my page, I see the ajax request coming in (using
firebug), but the response is empty and contains the header
Ajax-Location which triggers a redirect (javascript location update).
Why does this "redirect" occur?
A part of the default constructor looks like this:
final Label label = new Label("info", "<img src=\""
+ urlFor( AbstractDefaultAjaxBehavior.INDICATOR ) + "\"/>");
add( label.setOutputMarkupId( true ).setEscapeModelStrings(false) );
label.add( new AbstractDefaultAjaxBehavior() {
@Override
protected void respond( AjaxRequestTarget target ) {
throw new UnsupportedOperationException();
}
@Override
public void renderHead( IHeaderResponse response ) {
super.renderHead( response );
response.renderOnDomReadyJavascript( getCallbackScript().toString()
);
}
@Override
public CharSequence getCallbackUrl( boolean onlyTargetActivePage ) {
final PageParameters parameters = new PageParameters();
parameters.add( "foo", "bar" );
return urlFor( Index.class, parameters );
}
});
The constructor taking page parameters looks like this:
public Index( PageParameters pageParameters ) {
final AjaxRequestTarget target = new AjaxRequestTarget( this );
WebRequestCycle.get().setRequestTarget( target );
final Label lazyLabel = new Label( "info", pageParameters.getString(
"foo" ) );
target.addComponent( lazyLabel.setOutputMarkupId( true ) );
}
What's wrong with this? Can the page when invoked via ajax with request
params output the necessary xml?
Thanx && cheers,
Martin
On Sat, 2009-04-18 at 19:05 -0500, Jeremy Thomerson wrote:
> Using urlFor(...) generates a stateful, session-relative link - unless you
> call urlFor(Class, PageParameters) - which is stateless because it encodes
> the class and parameters in the URL. In the other URLs, the state is stored
> in the session, and the URL is basically a map to navigate the component
> tree to get back to the component that generated the URL.
>
> --
> Jeremy Thomerson
> http://www.wickettraining.com
>
>
>
> On Sat, Apr 18, 2009 at 4:27 PM, Martin Grotzke <
> [email protected]> wrote:
>
> > What exactly causes the page to be stateful when urlFor(Component,
> > Interface) is invoked?
> >
> > I would like to make only minimal changes compared to original wicket
> > ajax handling and would really like to reuse as much as possible of
> > wicket ajax handling (e.g. adding components to be updated to the
> > AjaxRequestTarget).
> >
> > Do you think it would be possible to create a Behavior that uses a
> > callback url which links to a (stateless) page with page parameters.
> > This page provides a constructor taking parameters and sets an
> > AjaxRequestTarget on the RequestCycle. It creates and adds all
> > components which shall be changed to the target.
> >
> > What do you think? Can you imagine other ways of being as close as
> > possible to wicket?
> >
> > Thanx && cheers,
> > Martin
> >
> >
> >
> > On Fri, 2009-04-17 at 15:40 -0700, Igor Vaynberg wrote:
> > > sure, you can use behaviors and requesttargets of whatever kind. just
> > > make sure nothing on your page calls urlfor(component, interface) -
> > > this is what causes the page to be stateful.
> > >
> > > -igor
> > >
> > > On Fri, Apr 17, 2009 at 3:14 PM, Martin Grotzke
> > > <[email protected]> wrote:
> > > > Wow, very fast response!
> > > >
> > > > Is it possible to use wicket concepts like RequestTarget and Behavior
> > on
> > > > the serverside? I'd like to have this integrated with wicket as much as
> > > > possible.
> > > >
> > > > Cheers,
> > > > Martin
> > > >
> > > >
> > > > On Fri, 2009-04-17 at 14:55 -0700, Igor Vaynberg wrote:
> > > >> you cannot use wicket ajax facilities as they are designed for
> > > >> stateful pages - the link that wicket uses for ajax callback is
> > > >> inherently stateful.
> > > >>
> > > >> what you can do is write javascript yourself using jquery, or
> > > >> something else to perform an ajax callback to some url you control and
> > > >> then replace some markup on your page with returned markup.
> > > >>
> > > >> -igor
> > > >>
> > > >> On Fri, Apr 17, 2009 at 2:52 PM, Martin Grotzke
> > > >> <[email protected]> wrote:
> > > >> > Hello,
> > > >> >
> > > >> > can somebody help with this?
> > > >> >
> > > >> > Thanx && cheers,
> > > >> > Martin
> > > >> >
> > > >> >
> > > >> > On Mon, 2009-04-13 at 12:16 +0200, [email protected]:
> > > >> >> Hi,
> > > >> >>
> > > >> >> I'm currently evaluating how it's possible to have stateless pages
> > with
> > > >> >> some information loaded asynchronously via AJAX.
> > > >> >>
> > > >> >> I found these postings that are somehow related to this
> > > >> >> http://www.nabble.com/Stateless-AJAX-links-td20031309.html
> > > >> >>
> > http://www.nabble.com/Directions-for-Stateless-Ajax-td17518987.html
> > > >> >>
> > > >> >> but I'm not sure what exactly has to be done to achieve what I
> > want.
> > > >> >>
> > > >> >> Basically I have a simple page where I added an AjaxBehavior to a
> > label
> > > >> >> that shall get replaced via AJAX:
> > > >> >>
> > > >> >> final Label label = new Label( "info", "foo" );
> > > >> >> add( label.setOutputMarkupId( true ) );
> > > >> >> label.add(new AbstractDefaultAjaxBehavior() {
> > > >> >>
> > > >> >> @Override
> > > >> >> protected void respond( AjaxRequestTarget target ) {
> > > >> >> final Label lazyLabel = new Label( "info", "loaded
> > asynchronously" );
> > > >> >> Index.this.replace( lazyLabel.setOutputMarkupId( true ) );
> > > >> >> target.addComponent( lazyLabel );
> > > >> >> }
> > > >> >>
> > > >> >> @Override
> > > >> >> public void renderHead( IHeaderResponse response ) {
> > > >> >> super.renderHead( response );
> > > >> >> response.renderOnDomReadyJavascript(
> > getCallbackScript().toString() );
> > > >> >> }
> > > >> >>
> > > >> >> } );
> > > >> >>
> > > >> >> This turns the previously statelesss page to stateful, AFAICS
> > because of
> > > >> >> getStatelessHint( Component component )
> > > >> >> returning false for the label.
> > > >> >>
> > > >> >> When I change this to return true, wicket says the page is expired
> > on the AJAX request...
> > > >> >>
> > > >> >> Can anybody say what had to be done?
> > > >> >>
> > > >> >> Btw: I'm using wicket-1.4-SNAPSHOT.
> > > >> >>
> > > >> >> Thanx in advance,
> > > >> >> cheers,
> > > >> >> Martin
> > > >> >>
> > > >> >>
> > > >> >>
> > ---------------------------------------------------------------------
> > > >> >> To unsubscribe, e-mail: [email protected]
> > > >> >> For additional commands, e-mail: [email protected]
> > > >> >>
> > > >> >
> > > >>
> > > >> ---------------------------------------------------------------------
> > > >> To unsubscribe, e-mail: [email protected]
> > > >> For additional commands, e-mail: [email protected]
> > > >>
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [email protected]
> > > For additional commands, e-mail: [email protected]
> > >
> >
signature.asc
Description: This is a digitally signed message part
