You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by vkbhaskar <vk...@yahoo.com> on 2008/06/12 15:01:14 UTC

Replace a fragment with AjaxLink

How do I replace a fragment with an AjaxLink ?

I am trying something like this.

Fragment orig = new Fragment("container","original",this);
orig.setOutputMarkupId(true);
add(orig);
add(new AjaxLink("link") {
    public void onClick(AjaxTarget target) {
       Fragment repl = new Fragment("container","replace",MyPage.this);
       repl.setOutputMarkupId(true);
       MyPage.this.replace(repl);
       target.add(repl);
    }
}
);

But I am getting ArrayIndexOutofBoundsExceptions, when the link is clicked.
-- 
View this message in context: http://www.nabble.com/Replace-a-fragment-with-AjaxLink-tp17799454p17799454.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: Replace a fragment with AjaxLink

Posted by Eelco Hillenius <ee...@gmail.com>.
> OK I figured out what the problem is.
> If you want to replace one fragment with another over AJAX, then they must
> have the same "markupId"s.

Yep. Not just for Ajax though... this is true for all component replacement.

Eelco

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


Re: Replace a fragment with AjaxLink

Posted by vkbhaskar <vk...@yahoo.com>.
OK I figured out what the problem is.
If you want to replace one fragment with another over AJAX, then they must
have the same "markupId"s.
Otherwise it won't work.
I solved the problem by making "orig" fragment "final".
And after repl.setOutputMarkupId(true); I added
repl.setMarkupId(orig.getMarkupId());

and then it works.

May be something for the WIKI.





Thomas Mäder wrote:
> 
> What's the stack trace?
> 
> On Thu, Jun 12, 2008 at 3:01 PM, vkbhaskar <vk...@yahoo.com> wrote:
> 
>>
>> How do I replace a fragment with an AjaxLink ?
>>
>> I am trying something like this.
>>
>> Fragment orig = new Fragment("container","original",this);
>> orig.setOutputMarkupId(true);
>> add(orig);
>> add(new AjaxLink("link") {
>>    public void onClick(AjaxTarget target) {
>>       Fragment repl = new Fragment("container","replace",MyPage.this);
>>       repl.setOutputMarkupId(true);
>>       MyPage.this.replace(repl);
>>       target.add(repl);
>>    }
>> }
>> );
>>
>> But I am getting ArrayIndexOutofBoundsExceptions, when the link is
>> clicked.
>> --
>> View this message in context:
>> http://www.nabble.com/Replace-a-fragment-with-AjaxLink-tp17799454p17799454.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Replace-a-fragment-with-AjaxLink-tp17799454p17800094.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: Replace a fragment with AjaxLink

Posted by Thomas Mäder <to...@gmail.com>.
What's the stack trace?

On Thu, Jun 12, 2008 at 3:01 PM, vkbhaskar <vk...@yahoo.com> wrote:

>
> How do I replace a fragment with an AjaxLink ?
>
> I am trying something like this.
>
> Fragment orig = new Fragment("container","original",this);
> orig.setOutputMarkupId(true);
> add(orig);
> add(new AjaxLink("link") {
>    public void onClick(AjaxTarget target) {
>       Fragment repl = new Fragment("container","replace",MyPage.this);
>       repl.setOutputMarkupId(true);
>       MyPage.this.replace(repl);
>       target.add(repl);
>    }
> }
> );
>
> But I am getting ArrayIndexOutofBoundsExceptions, when the link is clicked.
> --
> View this message in context:
> http://www.nabble.com/Replace-a-fragment-with-AjaxLink-tp17799454p17799454.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>