You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Lorenzo Bolzani <l....@gmail.com> on 2009/07/15 11:33:44 UTC

Accessing the rowItem from the populateItem of a column

Hi all,
I need to do an ajax refresh of a whole line of a table.

On the left of the table there is a dropdown and when the selection is
changed the other fields of the table should be refreshed accordingly.

So I have a column where the dropdown is defined and here I add an
"onchange" behaviour where I should add the entire row to the ajax
target.

But in the populateItem of ICellPopulator I have no access to the rowItem.

With this hack

         Object repeatingView =
ReflectionUtil.getPrivateField(cellItem, "parent");
         return (Item) ReflectionUtil.getPrivateField(repeatingView, "parent");

I can reach the rowItem and everything works perfectly.

Now I was looking for a cleaner way to do this.

The item I need is the one that is received from the
populateItem(Item) of AbstractDataGridView so I could override this
call super and add the tracking of the current rowItem making it
available, as a field, in subsequent ICellPopulator.populateItem
calls. Not very nice anyway.

Do you have any suggestion? Could a getParent method added to cellItem
to access to the rowItem it belongs to?

Thanks, bye

Lorenzo
-- 
It has to start somewhere, It has to start sometime.
What better place than here, what better time than now?

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


Re: Accessing the rowItem from the populateItem of a column

Posted by Iain Reddick <ia...@beatsystems.com>.
That should work fine in 1.3.3.

I thought this was what you were looking for:

public class SomeColumnClass extends AbstractColumn {
    public void populateItem( Item cellItem, String componentId, IModel 
rowModel ) {  
        MarkupContainer rowItem = cellItem.getParent().getParent();
        rowItem.add( new SomeBehaviour() );
    }
}

?

Lorenzo Bolzani wrote:
> 2009/7/15 Iain Reddick <ia...@beatsystems.com>:
>   
>> cellItem.getParent().getParent() will get the row component, but it's not a
>> very clean solution.
>>
>>     
>
> Hi, thanks for the replies.
>
> I'm using wicket 1.3.3 and this method was not yet present. I'm not
> upgrading due to some problems with ajax tests and WicketTester.
>
> Anyway I cannot see many other options, other than using a ListView
> instead of a table or the one described above.
>
>
> Bye
>
> Lorenzo
>
> ---------------------------------------------------------------------
> 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: Accessing the rowItem from the populateItem of a column

Posted by Lorenzo Bolzani <l....@gmail.com>.
2009/7/15 Iain Reddick <ia...@beatsystems.com>:
> cellItem.getParent().getParent() will get the row component, but it's not a
> very clean solution.
>

Hi, thanks for the replies.

I'm using wicket 1.3.3 and this method was not yet present. I'm not
upgrading due to some problems with ajax tests and WicketTester.

Anyway I cannot see many other options, other than using a ListView
instead of a table or the one described above.


Bye

Lorenzo

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


Re: Accessing the rowItem from the populateItem of a column

Posted by Iain Reddick <ia...@beatsystems.com>.
cellItem.getParent().getParent() will get the row component, but it's 
not a very clean solution.

Pierre Goupil wrote:
> Hello,
>
> Can't you just make the parent's field final and use : Parent.this.cellItem
> ?
>
> HTH,
>
> Pierre
>
>
> On Wed, Jul 15, 2009 at 11:33 AM, Lorenzo Bolzani <l....@gmail.com>wrote:
>
>   
>> Hi all,
>> I need to do an ajax refresh of a whole line of a table.
>>
>> On the left of the table there is a dropdown and when the selection is
>> changed the other fields of the table should be refreshed accordingly.
>>
>> So I have a column where the dropdown is defined and here I add an
>> "onchange" behaviour where I should add the entire row to the ajax
>> target.
>>
>> But in the populateItem of ICellPopulator I have no access to the rowItem.
>>
>> With this hack
>>
>>         Object repeatingView =
>> ReflectionUtil.getPrivateField(cellItem, "parent");
>>         return (Item) ReflectionUtil.getPrivateField(repeatingView,
>> "parent");
>>
>> I can reach the rowItem and everything works perfectly.
>>
>> Now I was looking for a cleaner way to do this.
>>
>> The item I need is the one that is received from the
>> populateItem(Item) of AbstractDataGridView so I could override this
>> call super and add the tracking of the current rowItem making it
>> available, as a field, in subsequent ICellPopulator.populateItem
>> calls. Not very nice anyway.
>>
>> Do you have any suggestion? Could a getParent method added to cellItem
>> to access to the rowItem it belongs to?
>>
>> Thanks, bye
>>
>> Lorenzo
>> --
>> It has to start somewhere, It has to start sometime.
>> What better place than here, what better time than now?
>>
>> ---------------------------------------------------------------------
>> 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: Accessing the rowItem from the populateItem of a column

Posted by Pierre Goupil <go...@gmail.com>.
Hello,

Can't you just make the parent's field final and use : Parent.this.cellItem
?

HTH,

Pierre


On Wed, Jul 15, 2009 at 11:33 AM, Lorenzo Bolzani <l....@gmail.com>wrote:

> Hi all,
> I need to do an ajax refresh of a whole line of a table.
>
> On the left of the table there is a dropdown and when the selection is
> changed the other fields of the table should be refreshed accordingly.
>
> So I have a column where the dropdown is defined and here I add an
> "onchange" behaviour where I should add the entire row to the ajax
> target.
>
> But in the populateItem of ICellPopulator I have no access to the rowItem.
>
> With this hack
>
>         Object repeatingView =
> ReflectionUtil.getPrivateField(cellItem, "parent");
>         return (Item) ReflectionUtil.getPrivateField(repeatingView,
> "parent");
>
> I can reach the rowItem and everything works perfectly.
>
> Now I was looking for a cleaner way to do this.
>
> The item I need is the one that is received from the
> populateItem(Item) of AbstractDataGridView so I could override this
> call super and add the tracking of the current rowItem making it
> available, as a field, in subsequent ICellPopulator.populateItem
> calls. Not very nice anyway.
>
> Do you have any suggestion? Could a getParent method added to cellItem
> to access to the rowItem it belongs to?
>
> Thanks, bye
>
> Lorenzo
> --
> It has to start somewhere, It has to start sometime.
> What better place than here, what better time than now?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Sans amis était le grand maître des mondes,
Eprouvait manque, ce pour quoi il créa les esprits,
Miroirs bienveillants de sa béatitude.
Mais au vrai, il ne trouva aucun égal,
Du calice du royaume total des âmes
Ecume jusqu'à lui l'infinité.

(Schiller, "l'amitié")