You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by saty <sa...@gmail.com> on 2013/01/19 03:30:29 UTC
How to change the model of an panel and refresh it
I have a Datagrid and i am trying to populated a panel below the grid with
the data model of selected row on grid (for editing).
The panel is initially hidden but made visible with the row selected and
some other conditions met. The panel does appear but not the data on its
fields, what is the most appropriate way to do this in wicket.
The code that i have currently is below.
global variable..
IModel<SomeType> model;
Initially..
model= new Model<SomeType>(new SomeType());
EditPanel ep = new EditPanel("editPanel", model);
ep.setOutputMarkupPlaceholderTag(true);
ep.setVisible(false);
form.add(ep);
Than based on ajax events from data grid below method is invoked, it does
get invoked but nothing is displayed on UI.
//sometype is actual Object with data
private void showEditPanel(AjaxRequestTarget target, SomeType someType)
{
editPanel.modelChanging();
model = new Model<SomeType >(someType);
editPanel.modelChanged();
editPanel.setOutputMarkupPlaceholderTag(true);
editPanel.setVisible(true);
target.add(editPanel);
logger.info("refreshed editPanel");
}
Thanks!!
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-change-the-model-of-an-panel-and-refresh-it-tp4655524.html
Sent from the Users forum 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: How to change the model of an panel and refresh it
Posted by Sven Meier <sv...@meiers.net>.
You have to change the object *in* the model, since EditPanel still
holds a reference to the old model:
private void showEditPanel(AjaxRequestTarget target, SomeType someType)
{
model.setObject(someType);
// it's too late to tell editPanel to render a placeholder,
// if it doesn't already have a markup tag in the browser,
// it won't be updated anyway
// editPanel.setOutputMarkupPlaceholderTag(true);
editPanel.setVisible(true);
target.add(editPanel);
logger.info("refreshed editPanel");
}
Sven
On 01/19/2013 03:30 AM, saty wrote:
> I have a Datagrid and i am trying to populated a panel below the grid with
> the data model of selected row on grid (for editing).
> The panel is initially hidden but made visible with the row selected and
> some other conditions met. The panel does appear but not the data on its
> fields, what is the most appropriate way to do this in wicket.
>
> The code that i have currently is below.
>
> global variable..
> IModel<SomeType> model;
>
> Initially..
>
> model= new Model<SomeType>(new SomeType());
> EditPanel ep = new EditPanel("editPanel", model);
> ep.setOutputMarkupPlaceholderTag(true);
> ep.setVisible(false);
> form.add(ep);
>
>
> Than based on ajax events from data grid below method is invoked, it does
> get invoked but nothing is displayed on UI.
>
> //sometype is actual Object with data
> private void showEditPanel(AjaxRequestTarget target, SomeType someType)
> {
> editPanel.modelChanging();
> model = new Model<SomeType >(someType);
> editPanel.modelChanged();
> editPanel.setOutputMarkupPlaceholderTag(true);
> editPanel.setVisible(true);
> target.add(editPanel);
> logger.info("refreshed editPanel");
> }
>
> Thanks!!
>
>
>
>
>
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-change-the-model-of-an-panel-and-refresh-it-tp4655524.html
> Sent from the Users forum 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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org