Hi,


On Wed, Jul 16, 2014 at 11:12 PM, Mihir Chhaya <mihir.chh...@gmail.com>
wrote:

> Hello,
>
> I am using inMethod data grid with Wicket 1.5.
>
> I have a page to show master grid (MasterPanel). MasterPanel has child grid
> (ChildPanel) to display child records. ChildPanel accepts MasterBean as one
> of the arguments of the Constructor to retrieve child records using Master
> PK id.
>
> Now, on selection of row in Master grid, I want to ajaxically refresh child
> panel.
> I don't want to use Modal Window.
>
> Following is code snippet:
>
> public class MasterPanel extends Panel{
>
> public MasterPanel(String id, IModel<SomeBean>) {
>  MasterBean masterBean = <<get Master Bean from service method>>;
>  //form
> Form<MasterBean> form = new Form<MasterBean> ("form", new
> CompoundPropertyModel<MasterBean>(masterBean));
> form.setOutputMarkupId(true);
>  //Child Panel added into MasterPanel
> ChildPanel childPanel = new ChildPanel("child", form.getModel());
>

Here you a new reference to the form's model.
One way to solve the issue is to use a wrapped/delegating model:
new IModel<MasterBean>() {
  public MasterBean getObject() { return form.getModel().getObject();}
  public void setObject(MasterBean mb) { return
form.getModel().setObject(mb);}
  public void detach() { return form.getModel().detach();}
}


> childPanel.setOutputMarkupId(true);
>
> form.add(childPanel);
>  DataGrid<GridList<MasterBean>, MasterBean> grid = masterGrid("grid",
> childPanel);
> grid.setOutputMarkupId(true);
> form.add(grid);
> }
>
> private DataGrid<GridList<MasterBean>, MasterBean> masterGrid(String
> property, final ChildPanel childPanel) {
> ....
> ....
> ....
> //OnRowClicked in Databgrid
> @Override
> protected void onRowClicked(AjaxRequestTarget target, IModel<MasterBean>
> rowModel) {
> getForm().setDefaultModel(rowModel);
>

Another way to solve it is to do: childPanel.setModel(rowModel);


> target.add(childPanel);
> }
> }
> }
>
>
> Above code is not refreshing the child as the ChildPanel is already created
> at the time of adding into MasterPanel. I want ChildPanel to be re-rendered
> using selected MasterBean from Master grid.
>
> Any help/suggestions?
>
> Thanks,
> -Mihir.
>

Reply via email to