You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by kshitiz <k....@gmail.com> on 2012/09/16 14:44:15 UTC

Need help in refreshing panel..

Hi,

I am facing a problem in refreshing a panel. The requirement is I have a
panel A which has Panel B. Panel A carries list of LDM which is being passed
to Panel B. 

public class PanelA {

       private LoadableDetachableModel<List&lt;PostDomain>>
*detachablePostDomainList *= new
LoadableDetachableModel<List&lt;PostDomain>>() {

		
		protected List<PostDomain> load() {
			return new ArrayList<PostDomain>();
		}
	};

public PanelA() {
*this.setOutputMarkupId(true);*
detachablePostDomainList = new
LoadableDetachableModel<List&lt;PostDomain>>() {
			/**
				 * 
				 */
			private static final long serialVersionUID = 1L;

			@Override
			protected List<PostDomain> load() {
				return new List();
			}
		};

}

*final PanelB panelB= new PanelB("B",
				detachablePostDomainList, PanelA.this);
		showPostPanel.setOutputMarkupPlaceholderTag(true);
*

IndicatingAjaxButton ajaxPostSubmitButton = new IndicatingAjaxButton(
				"submitPost", postForm) {
                         // some operations

			public void onSubmit(AjaxRequestTarget target, final Form<?> form) {
				if (target != null) {
					target.add(PanelA.this);

				}

			}


		};


}

In the above scenario, when I refresh panelA from itself by pressing
ajaxPostSubmitButton, LDM list is getting updated but when I refresh PanelA
from PanelB, nothing happens. What is the reason? I am refreshing PanelA
from PanelB using the same manner. 



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Need-help-in-refreshing-panel-tp4652014.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: Need help in refreshing panel..

Posted by Sven Meier <sv...@meiers.net>.
It depends whether the LDM is accessed *before* you change something in 
the backing list.

Note that events handled by components in a ListView will trigger 
loading of the LDM as soon as you access the component's model.

Sven

On 09/16/2012 05:48 PM, kshitiz wrote:
> Hey...that worked....but still I didn't understand how it worked. I am not
> calling detach method in ajaxPostSubmitButton of PanelA. So how come it is
> getting refreshed. I am just trying to understand the concept
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Need-help-in-refreshing-panel-tp4652014p4652018.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


Re: Need help in refreshing panel..

Posted by kshitiz <k....@gmail.com>.
Hey...that worked....but still I didn't understand how it worked. I am not
calling detach method in ajaxPostSubmitButton of PanelA. So how come it is
getting refreshed. I am just trying to understand the concept



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Need-help-in-refreshing-panel-tp4652014p4652018.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: Need help in refreshing panel..

Posted by Sven Meier <sv...@meiers.net>.
You have to remember that a LDM is loaded once per request cycle only.

If you change the backing list (e.g. on delete of an item) *after* the 
LDM was already accessed (e.g. a link in a ListView), you have to detach 
the model once, so it is loaded again:

    // some operation calling getObject() on the LDM
    ...

    ldm.detach();

    target.add(component)

Hope this helps
Sven


On 09/16/2012 04:08 PM, kshitiz wrote:
> The problem is now even more complicated as PanelA is not getting refreshed
> from PanelB at once. But when I do some operation in PanelB again, PanelA is
> then refreshed...
>
> Here is PanelB:
>
> Public class PanelB{
>
>
> public PanelB(PanelA panelA) {
> PostDeleteButtonPanel postDeleteButtonPanel = new PostDeleteButtonPanel(
> 						"postDeleteButtonPanel", postForm) {
>
> 					
> 					protected void onConfirm(AjaxRequestTarget target) {
> 						try {
> //							some operation
> 							if (target != null)
> 								*target.add(panelA);*
>
> 						} catch (Exception exception) {
> 							exception.printStackTrace();
> 						}
>
> 					}
>
> 				};
>
> }
> }
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Need-help-in-refreshing-panel-tp4652014p4652016.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


Re: Need help in refreshing panel..

Posted by kshitiz <k....@gmail.com>.
The problem is now even more complicated as PanelA is not getting refreshed
from PanelB at once. But when I do some operation in PanelB again, PanelA is
then refreshed...

Here is PanelB:

Public class PanelB{


public PanelB(PanelA panelA) {
PostDeleteButtonPanel postDeleteButtonPanel = new PostDeleteButtonPanel(
						"postDeleteButtonPanel", postForm) {

					
					protected void onConfirm(AjaxRequestTarget target) {
						try {
//							some operation
							if (target != null)
								*target.add(panelA);*

						} catch (Exception exception) {
							exception.printStackTrace();
						}

					}

				};

}
}



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Need-help-in-refreshing-panel-tp4652014p4652016.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