You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Wayne Pope <wa...@googlemail.com> on 2008/08/17 13:22:49 UTC
I'm adding a new item to a ListView via ajax - how to get reference to the new item?
Hi everyone,
I have a ListView that displays a list of cars (say).
I have a small form on the page whereby they can add a new car using a
AjaxFallbackButton.
I can enter a new car and it updates the ListView
However I want to highlight the newly added item, and I just can't seemt to
figure out how I can 'target' the item.
I'd like to do something like
protected void onSubmit(AjaxRequestTarget target, Form arg1) {
// add new car...
if (target!=null) {
target.addComponent(carList);
target.addCompoent(<THENEWITEM>.addJavascript(new
Effect.Highlight(this).toJavascript()));
}
- the question is how do I get the target reference to the new item added?
Re: I'm adding a new item to a ListView via ajax - how to get reference to the new item?
Posted by Vitaly Tsaplin <vi...@gmail.com>.
My solution was to generate html ids according to some well defined
strategy like using a uniq product ids from a database plus a prefix.
So you will be able to reconstruct the html ids at any time if you
know an id of the object you have just been created. If I am right you
use the target object that is supplied for you in the method onSubmit.
On Sun, Aug 17, 2008 at 1:36 PM, Wayne Pope
<wa...@googlemail.com> wrote:
> Hi,
>
> But how do I get that target?
>
> As the items are being rendered using a ListView - the only time I can get
> access is during the populateItem - but thats a ListItem, I need a
> AjexRequestTarget to append the javascript?
>
>
>
> On Sun, Aug 17, 2008 at 1:28 PM, Vitaly Tsaplin <vi...@gmail.com>wrote:
>
>> Hi,
>>
>> The item is already on your page so just use its html id in the
>> javascript script you use to highlight it.
>>
>> Vitaly
>>
>> On Sun, Aug 17, 2008 at 1:22 PM, Wayne Pope
>> <wa...@googlemail.com> wrote:
>> > Hi everyone,
>> >
>> > I have a ListView that displays a list of cars (say).
>> > I have a small form on the page whereby they can add a new car using a
>> > AjaxFallbackButton.
>> > I can enter a new car and it updates the ListView
>> >
>> > However I want to highlight the newly added item, and I just can't seemt
>> to
>> > figure out how I can 'target' the item.
>> >
>> > I'd like to do something like
>> >
>> > protected void onSubmit(AjaxRequestTarget target, Form arg1) {
>> > // add new car...
>> >
>> > if (target!=null) {
>> > target.addComponent(carList);
>> > target.addCompoent(<THENEWITEM>.addJavascript(new
>> > Effect.Highlight(this).toJavascript()));
>> > }
>> >
>> >
>> > - the question is how do I get the target reference to the new item
>> added?
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: I'm adding a new item to a ListView via ajax - how to get reference to the new item?
Posted by Wayne Pope <wa...@googlemail.com>.
HI everyone,
thanks very much for your help.
So much to learn at the moment so I really appreciate you all helping me out
- it takes a while to get to know what you can and can't do with wicket.
AjaxRequestTarget.get() worked just fine.
On Sun, Aug 17, 2008 at 7:17 PM, Peter Ertl <pe...@gmx.net> wrote:
> use AjaxRequestTarget.get()
>
> Am 17.08.2008 um 15:36 schrieb Martin Grigorov:
>
>
> On Sun, 2008-08-17 at 13:36 +0200, Wayne Pope wrote:
>>
>>> Hi,
>>>
>>> But how do I get that target?
>>>
>>> As the items are being rendered using a ListView - the only time I can
>>> get
>>> access is during the populateItem - but thats a ListItem, I need a
>>> AjexRequestTarget to append the javascript?
>>>
>>> You could append Javascript at render time (in populateItem(ListItem())
>> by adding AjaxCallDecorator to your AjaxButton.
>>
>> Or with AttributePrepender/Appender for the 'onclick' AjaxButton
>> attribute
>>
>>
>>>
>>> On Sun, Aug 17, 2008 at 1:28 PM, Vitaly Tsaplin <
>>> vitaly.tsaplin@gmail.com>wrote:
>>>
>>> Hi,
>>>>
>>>> The item is already on your page so just use its html id in the
>>>> javascript script you use to highlight it.
>>>>
>>>> Vitaly
>>>>
>>>> On Sun, Aug 17, 2008 at 1:22 PM, Wayne Pope
>>>> <wa...@googlemail.com> wrote:
>>>>
>>>>> Hi everyone,
>>>>>
>>>>> I have a ListView that displays a list of cars (say).
>>>>> I have a small form on the page whereby they can add a new car using a
>>>>> AjaxFallbackButton.
>>>>> I can enter a new car and it updates the ListView
>>>>>
>>>>> However I want to highlight the newly added item, and I just can't
>>>>> seemt
>>>>>
>>>> to
>>>>
>>>>> figure out how I can 'target' the item.
>>>>>
>>>>> I'd like to do something like
>>>>>
>>>>> protected void onSubmit(AjaxRequestTarget target, Form arg1) {
>>>>> // add new car...
>>>>>
>>>>> if (target!=null) {
>>>>> target.addComponent(carList);
>>>>> target.addCompoent(<THENEWITEM>.addJavascript(new
>>>>> Effect.Highlight(this).toJavascript()));
>>>>> }
>>>>>
>>>>>
>>>>> - the question is how do I get the target reference to the new item
>>>>>
>>>> added?
>>>>
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: I'm adding a new item to a ListView via ajax - how to get reference to the new item?
Posted by Peter Ertl <pe...@gmx.net>.
use AjaxRequestTarget.get()
Am 17.08.2008 um 15:36 schrieb Martin Grigorov:
> On Sun, 2008-08-17 at 13:36 +0200, Wayne Pope wrote:
>> Hi,
>>
>> But how do I get that target?
>>
>> As the items are being rendered using a ListView - the only time I
>> can get
>> access is during the populateItem - but thats a ListItem, I need a
>> AjexRequestTarget to append the javascript?
>>
> You could append Javascript at render time (in
> populateItem(ListItem())
> by adding AjaxCallDecorator to your AjaxButton.
>
> Or with AttributePrepender/Appender for the 'onclick' AjaxButton
> attribute
>
>>
>>
>> On Sun, Aug 17, 2008 at 1:28 PM, Vitaly Tsaplin <vitaly.tsaplin@gmail.com
>> >wrote:
>>
>>> Hi,
>>>
>>> The item is already on your page so just use its html id in the
>>> javascript script you use to highlight it.
>>>
>>> Vitaly
>>>
>>> On Sun, Aug 17, 2008 at 1:22 PM, Wayne Pope
>>> <wa...@googlemail.com> wrote:
>>>> Hi everyone,
>>>>
>>>> I have a ListView that displays a list of cars (say).
>>>> I have a small form on the page whereby they can add a new car
>>>> using a
>>>> AjaxFallbackButton.
>>>> I can enter a new car and it updates the ListView
>>>>
>>>> However I want to highlight the newly added item, and I just
>>>> can't seemt
>>> to
>>>> figure out how I can 'target' the item.
>>>>
>>>> I'd like to do something like
>>>>
>>>> protected void onSubmit(AjaxRequestTarget target, Form arg1) {
>>>> // add new car...
>>>>
>>>> if (target!=null) {
>>>> target.addComponent(carList);
>>>> target.addCompoent(<THENEWITEM>.addJavascript(new
>>>> Effect.Highlight(this).toJavascript()));
>>>> }
>>>>
>>>>
>>>> - the question is how do I get the target reference to the new item
>>> added?
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: I'm adding a new item to a ListView via ajax - how to get
reference to the new item?
Posted by Martin Grigorov <mc...@e-card.bg>.
On Sun, 2008-08-17 at 13:36 +0200, Wayne Pope wrote:
> Hi,
>
> But how do I get that target?
>
> As the items are being rendered using a ListView - the only time I can get
> access is during the populateItem - but thats a ListItem, I need a
> AjexRequestTarget to append the javascript?
>
You could append Javascript at render time (in populateItem(ListItem())
by adding AjaxCallDecorator to your AjaxButton.
Or with AttributePrepender/Appender for the 'onclick' AjaxButton
attribute
>
>
> On Sun, Aug 17, 2008 at 1:28 PM, Vitaly Tsaplin <vi...@gmail.com>wrote:
>
> > Hi,
> >
> > The item is already on your page so just use its html id in the
> > javascript script you use to highlight it.
> >
> > Vitaly
> >
> > On Sun, Aug 17, 2008 at 1:22 PM, Wayne Pope
> > <wa...@googlemail.com> wrote:
> > > Hi everyone,
> > >
> > > I have a ListView that displays a list of cars (say).
> > > I have a small form on the page whereby they can add a new car using a
> > > AjaxFallbackButton.
> > > I can enter a new car and it updates the ListView
> > >
> > > However I want to highlight the newly added item, and I just can't seemt
> > to
> > > figure out how I can 'target' the item.
> > >
> > > I'd like to do something like
> > >
> > > protected void onSubmit(AjaxRequestTarget target, Form arg1) {
> > > // add new car...
> > >
> > > if (target!=null) {
> > > target.addComponent(carList);
> > > target.addCompoent(<THENEWITEM>.addJavascript(new
> > > Effect.Highlight(this).toJavascript()));
> > > }
> > >
> > >
> > > - the question is how do I get the target reference to the new item
> > added?
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: I'm adding a new item to a ListView via ajax - how to get reference to the new item?
Posted by Wayne Pope <wa...@googlemail.com>.
Hi,
But how do I get that target?
As the items are being rendered using a ListView - the only time I can get
access is during the populateItem - but thats a ListItem, I need a
AjexRequestTarget to append the javascript?
On Sun, Aug 17, 2008 at 1:28 PM, Vitaly Tsaplin <vi...@gmail.com>wrote:
> Hi,
>
> The item is already on your page so just use its html id in the
> javascript script you use to highlight it.
>
> Vitaly
>
> On Sun, Aug 17, 2008 at 1:22 PM, Wayne Pope
> <wa...@googlemail.com> wrote:
> > Hi everyone,
> >
> > I have a ListView that displays a list of cars (say).
> > I have a small form on the page whereby they can add a new car using a
> > AjaxFallbackButton.
> > I can enter a new car and it updates the ListView
> >
> > However I want to highlight the newly added item, and I just can't seemt
> to
> > figure out how I can 'target' the item.
> >
> > I'd like to do something like
> >
> > protected void onSubmit(AjaxRequestTarget target, Form arg1) {
> > // add new car...
> >
> > if (target!=null) {
> > target.addComponent(carList);
> > target.addCompoent(<THENEWITEM>.addJavascript(new
> > Effect.Highlight(this).toJavascript()));
> > }
> >
> >
> > - the question is how do I get the target reference to the new item
> added?
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: I'm adding a new item to a ListView via ajax - how to get reference to the new item?
Posted by Vitaly Tsaplin <vi...@gmail.com>.
Hi,
The item is already on your page so just use its html id in the
javascript script you use to highlight it.
Vitaly
On Sun, Aug 17, 2008 at 1:22 PM, Wayne Pope
<wa...@googlemail.com> wrote:
> Hi everyone,
>
> I have a ListView that displays a list of cars (say).
> I have a small form on the page whereby they can add a new car using a
> AjaxFallbackButton.
> I can enter a new car and it updates the ListView
>
> However I want to highlight the newly added item, and I just can't seemt to
> figure out how I can 'target' the item.
>
> I'd like to do something like
>
> protected void onSubmit(AjaxRequestTarget target, Form arg1) {
> // add new car...
>
> if (target!=null) {
> target.addComponent(carList);
> target.addCompoent(<THENEWITEM>.addJavascript(new
> Effect.Highlight(this).toJavascript()));
> }
>
>
> - the question is how do I get the target reference to the new item added?
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org