You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by James Selvakumar <ja...@mcruncher.com> on 2017/04/21 07:38:43 UTC

Unable to retrieve row model in DataTable while running the application in Jetty

Hi all,

I have a DataTable with some ajax links in the first column. Other columns
are simple property columns. The ajax links are used to edit/delete
associated entities. The ajax links are encapsulated inside a panel.

The DataTable itself is rendered fine.

The problem I face is that the rowModel.getObject() is null when any of the
ajax link is clicked when running the application in Jetty (Maven jetty
plugin).  However, if the application is deployed on Tomcat, everything
works as expected.

Can anyone highlight my mistake, if any here?

Here's how my code looks like:

List<IColumn> columns = new ArrayList<IColumn>();
columns.add(new AbstractColumn<FooEntity,
String>(Model.of(getString("name")), "name")
{
    @Override
    public void populateItem(Item<ICellPopulator<FooEntity>> cellItem,
String componentId, final IModel<FooEntity> rowModel)
    {
        cellItem.add(new DataTableActionPanel(componentId,
rowModel.getObject().getName())
        {
            @Override
            protected void onEdit(AjaxRequestTarget target)
            {
                LOGGER.debug("Editing {}", rowModel.getObject());

                //proceed to display another panel to edit the entity

            }

            @Override
            protected void onDelete(AjaxRequestTarget target)
            {
                LOGGER.debug("Deleting {}", rowModel.getObject());

                //proceed to delete the entity

            }

        });
    }
});

//add other columns
....

//add the columns to a data table
....



-- 
Thanks & regards
James

Re: Unable to retrieve row model in DataTable while running the application in Jetty

Posted by James Selvakumar <ja...@mcruncher.com>.
Hi Francois,

Thanks again. I'll try to recreate this problem in a quickstart and will
update here.

On Tue, Apr 25, 2017 at 3:12 PM, Francois Meillet <
francois.meillet@gmail.com> wrote:

> Hi James,
>
> Please make a quickstart so I can have a better overview.
>
> François
>
>
>
> > Le 25 avr. 2017 à 03:35, James Selvakumar <ja...@mcruncher.com> a écrit
> :
> >
> > Hi Francois,
> >
> > Thank you very much for your reply.
> > I define my datatable like this:
> >
> > StandardDataTable dataTable = new StandardDataTable("dataTable",
> > columns, this.getDataProvider());
> >
> > And that's the only place I use a data provider.
> >
> > I don't override it's model.
> >
> > In my data provider I don't call detach.
> >
> >
> > On Fri, Apr 21, 2017 at 4:27 PM, Francois Meillet <
> > francois.meillet@gmail.com> wrote:
> >
> >> Hi James,
> >>
> >> Do you use the same DataProvider for your DataTable ?
> >> Do you use the same model when you override DataTable # IModel<T>
> model(T
> >> object);
> >> Do you call detach ?
> >>
> >> François
> >>
> >>
> >>
> >>> Le 21 avr. 2017 à 09:38, James Selvakumar <ja...@mcruncher.com> a
> écrit
> >> :
> >>>
> >>> Hi all,
> >>>
> >>> I have a DataTable with some ajax links in the first column. Other
> >> columns
> >>> are simple property columns. The ajax links are used to edit/delete
> >>> associated entities. The ajax links are encapsulated inside a panel.
> >>>
> >>> The DataTable itself is rendered fine.
> >>>
> >>> The problem I face is that the rowModel.getObject() is null when any of
> >> the
> >>> ajax link is clicked when running the application in Jetty (Maven jetty
> >>> plugin).  However, if the application is deployed on Tomcat, everything
> >>> works as expected.
> >>>
> >>> Can anyone highlight my mistake, if any here?
> >>>
> >>> Here's how my code looks like:
> >>>
> >>> List<IColumn> columns = new ArrayList<IColumn>();
> >>> columns.add(new AbstractColumn<FooEntity,
> >>> String>(Model.of(getString("name")), "name")
> >>> {
> >>> @Override
> >>> public void populateItem(Item<ICellPopulator<FooEntity>> cellItem,
> >>> String componentId, final IModel<FooEntity> rowModel)
> >>> {
> >>>     cellItem.add(new DataTableActionPanel(componentId,
> >>> rowModel.getObject().getName())
> >>>     {
> >>>         @Override
> >>>         protected void onEdit(AjaxRequestTarget target)
> >>>         {
> >>>             LOGGER.debug("Editing {}", rowModel.getObject());
> >>>
> >>>             //proceed to display another panel to edit the entity
> >>>
> >>>         }
> >>>
> >>>         @Override
> >>>         protected void onDelete(AjaxRequestTarget target)
> >>>         {
> >>>             LOGGER.debug("Deleting {}", rowModel.getObject());
> >>>
> >>>             //proceed to delete the entity
> >>>
> >>>         }
> >>>
> >>>     });
> >>> }
> >>> });
> >>>
> >>> //add other columns
> >>> ....
> >>>
> >>> //add the columns to a data table
> >>> ....
> >>>
> >>>
> >>>
> >>> --
> >>> Thanks & regards
> >>> James
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
> >
> > --
> > Thanks & regards
> > James
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Thanks & regards
James

Re: Unable to retrieve row model in DataTable while running the application in Jetty

Posted by Francois Meillet <fr...@gmail.com>.
Hi James,

Please make a quickstart so I can have a better overview.

François



> Le 25 avr. 2017 à 03:35, James Selvakumar <ja...@mcruncher.com> a écrit :
> 
> Hi Francois,
> 
> Thank you very much for your reply.
> I define my datatable like this:
> 
> StandardDataTable dataTable = new StandardDataTable("dataTable",
> columns, this.getDataProvider());
> 
> And that's the only place I use a data provider.
> 
> I don't override it's model.
> 
> In my data provider I don't call detach.
> 
> 
> On Fri, Apr 21, 2017 at 4:27 PM, Francois Meillet <
> francois.meillet@gmail.com> wrote:
> 
>> Hi James,
>> 
>> Do you use the same DataProvider for your DataTable ?
>> Do you use the same model when you override DataTable # IModel<T> model(T
>> object);
>> Do you call detach ?
>> 
>> François
>> 
>> 
>> 
>>> Le 21 avr. 2017 à 09:38, James Selvakumar <ja...@mcruncher.com> a écrit
>> :
>>> 
>>> Hi all,
>>> 
>>> I have a DataTable with some ajax links in the first column. Other
>> columns
>>> are simple property columns. The ajax links are used to edit/delete
>>> associated entities. The ajax links are encapsulated inside a panel.
>>> 
>>> The DataTable itself is rendered fine.
>>> 
>>> The problem I face is that the rowModel.getObject() is null when any of
>> the
>>> ajax link is clicked when running the application in Jetty (Maven jetty
>>> plugin).  However, if the application is deployed on Tomcat, everything
>>> works as expected.
>>> 
>>> Can anyone highlight my mistake, if any here?
>>> 
>>> Here's how my code looks like:
>>> 
>>> List<IColumn> columns = new ArrayList<IColumn>();
>>> columns.add(new AbstractColumn<FooEntity,
>>> String>(Model.of(getString("name")), "name")
>>> {
>>> @Override
>>> public void populateItem(Item<ICellPopulator<FooEntity>> cellItem,
>>> String componentId, final IModel<FooEntity> rowModel)
>>> {
>>>     cellItem.add(new DataTableActionPanel(componentId,
>>> rowModel.getObject().getName())
>>>     {
>>>         @Override
>>>         protected void onEdit(AjaxRequestTarget target)
>>>         {
>>>             LOGGER.debug("Editing {}", rowModel.getObject());
>>> 
>>>             //proceed to display another panel to edit the entity
>>> 
>>>         }
>>> 
>>>         @Override
>>>         protected void onDelete(AjaxRequestTarget target)
>>>         {
>>>             LOGGER.debug("Deleting {}", rowModel.getObject());
>>> 
>>>             //proceed to delete the entity
>>> 
>>>         }
>>> 
>>>     });
>>> }
>>> });
>>> 
>>> //add other columns
>>> ....
>>> 
>>> //add the columns to a data table
>>> ....
>>> 
>>> 
>>> 
>>> --
>>> Thanks & regards
>>> James
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>> 
>> 
> 
> 
> -- 
> Thanks & regards
> James


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


Re: Unable to retrieve row model in DataTable while running the application in Jetty

Posted by James Selvakumar <ja...@mcruncher.com>.
Hi Francois,

Thank you very much for your reply.
I define my datatable like this:

StandardDataTable dataTable = new StandardDataTable("dataTable",
columns, this.getDataProvider());

And that's the only place I use a data provider.

I don't override it's model.

In my data provider I don't call detach.


On Fri, Apr 21, 2017 at 4:27 PM, Francois Meillet <
francois.meillet@gmail.com> wrote:

> Hi James,
>
> Do you use the same DataProvider for your DataTable ?
> Do you use the same model when you override DataTable # IModel<T> model(T
> object);
> Do you call detach ?
>
> François
>
>
>
> > Le 21 avr. 2017 à 09:38, James Selvakumar <ja...@mcruncher.com> a écrit
> :
> >
> > Hi all,
> >
> > I have a DataTable with some ajax links in the first column. Other
> columns
> > are simple property columns. The ajax links are used to edit/delete
> > associated entities. The ajax links are encapsulated inside a panel.
> >
> > The DataTable itself is rendered fine.
> >
> > The problem I face is that the rowModel.getObject() is null when any of
> the
> > ajax link is clicked when running the application in Jetty (Maven jetty
> > plugin).  However, if the application is deployed on Tomcat, everything
> > works as expected.
> >
> > Can anyone highlight my mistake, if any here?
> >
> > Here's how my code looks like:
> >
> > List<IColumn> columns = new ArrayList<IColumn>();
> > columns.add(new AbstractColumn<FooEntity,
> > String>(Model.of(getString("name")), "name")
> > {
> >   @Override
> >   public void populateItem(Item<ICellPopulator<FooEntity>> cellItem,
> > String componentId, final IModel<FooEntity> rowModel)
> >   {
> >       cellItem.add(new DataTableActionPanel(componentId,
> > rowModel.getObject().getName())
> >       {
> >           @Override
> >           protected void onEdit(AjaxRequestTarget target)
> >           {
> >               LOGGER.debug("Editing {}", rowModel.getObject());
> >
> >               //proceed to display another panel to edit the entity
> >
> >           }
> >
> >           @Override
> >           protected void onDelete(AjaxRequestTarget target)
> >           {
> >               LOGGER.debug("Deleting {}", rowModel.getObject());
> >
> >               //proceed to delete the entity
> >
> >           }
> >
> >       });
> >   }
> > });
> >
> > //add other columns
> > ....
> >
> > //add the columns to a data table
> > ....
> >
> >
> >
> > --
> > Thanks & regards
> > James
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Thanks & regards
James

Re: Unable to retrieve row model in DataTable while running the application in Jetty

Posted by Francois Meillet <fr...@gmail.com>.
Hi James,

Do you use the same DataProvider for your DataTable ?
Do you use the same model when you override DataTable # IModel<T> model(T object);
Do you call detach ?

François



> Le 21 avr. 2017 à 09:38, James Selvakumar <ja...@mcruncher.com> a écrit :
> 
> Hi all,
> 
> I have a DataTable with some ajax links in the first column. Other columns
> are simple property columns. The ajax links are used to edit/delete
> associated entities. The ajax links are encapsulated inside a panel.
> 
> The DataTable itself is rendered fine.
> 
> The problem I face is that the rowModel.getObject() is null when any of the
> ajax link is clicked when running the application in Jetty (Maven jetty
> plugin).  However, if the application is deployed on Tomcat, everything
> works as expected.
> 
> Can anyone highlight my mistake, if any here?
> 
> Here's how my code looks like:
> 
> List<IColumn> columns = new ArrayList<IColumn>();
> columns.add(new AbstractColumn<FooEntity,
> String>(Model.of(getString("name")), "name")
> {
>   @Override
>   public void populateItem(Item<ICellPopulator<FooEntity>> cellItem,
> String componentId, final IModel<FooEntity> rowModel)
>   {
>       cellItem.add(new DataTableActionPanel(componentId,
> rowModel.getObject().getName())
>       {
>           @Override
>           protected void onEdit(AjaxRequestTarget target)
>           {
>               LOGGER.debug("Editing {}", rowModel.getObject());
> 
>               //proceed to display another panel to edit the entity
> 
>           }
> 
>           @Override
>           protected void onDelete(AjaxRequestTarget target)
>           {
>               LOGGER.debug("Deleting {}", rowModel.getObject());
> 
>               //proceed to delete the entity
> 
>           }
> 
>       });
>   }
> });
> 
> //add other columns
> ....
> 
> //add the columns to a data table
> ....
> 
> 
> 
> -- 
> Thanks & regards
> James


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