You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Steve Hiller <sh...@bellsouth.net> on 2010/06/30 15:29:48 UTC

Refreshing DataView fails if it was initially empty

Hi All,

I have what seems like a strange problem with refreshing a DataView.

I have a WebMarkupContainer that contains a DataView.
The DataView uses a SortableDataProvider as its DataProvider.
The WebMarkupContainer uses the DataView's SortableDataProvider 
to determine if there are any items to be displayed within the DataView.
If there any items then the WebMarkupContainer's isVisible() method
returns true, and therefore the WebMarkupContainer and DataView should
be rendered.

I am also using a ModalWindow to add new items to the DataView.
On exiting from the ModalWindow, I am using an AjaxRequestTarget
to refresh the WebMarkupContainer and therefore redraw the DataView
with the new item added to it.

This all works fine IF there were already items in the DataView when
it was first rendered during the initial loading of its page.

If the DataView is initially empty then the WebMarkupContainer 
is not rendered as expected on page load. My issue is that adding new
items via the ModalWindow does not cause the WebMarkupContainer and
DataView to be rendered. Via debugging, I can see that the
WebMarkupContainer's isVisible() method is returning true yet nothing
appears.

Any suggestions on resolving this issue would be appreciated.

Thanks so much,
Steve


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


Re: Refreshing DataView fails if it was initially empty

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
I meant something like:

=======================

import org.apache.wicket.Component;
import org.apache.wicket.markup.html.panel.Panel;

public abstract class CondiotionalPanel extends Panel {

	private static final long serialVersionUID = 1L;

	public CondiotionalPanel(String id) {
		super(id);
		setOutputMarkupId(true);
	}
	
	@Override
	protected void onBeforeRender() {
		if(getContidion())
			addOrReplace(onTrueState("child"));
		else
			addOrReplace(onFalseState("child"));
		super.onBeforeRender();
	}
	
	protected abstract Component onTrueState(String id);
	
	protected abstract Component onFalseState(String id);
	
	protected abstract boolean getContidion();

}


============================

ConditionaPanel.html

<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
    <body>
    	<wicket:panel>
    		<div wicket:id="content"></div>
	   	</wicket:panel>
    </body>
</html>

================================

CondiotionalPanel condionalPanel= new CondiotionalPanel("myid"){
        	
        	private static final long serialVersionUID = 1L;

			@Override
        	protected Component onFalseState(String id) {
        		return new EmptyPanel(id);
        	}
        	
        	@Override
        	protected Component onTrueState(String id) {
        		return new MyTablePanel(id);
        	}
        	
        	@Override
        	protected boolean getContidion() {
        		return tableHasElements;
        	}
        };

when you update this panel (condionalPanel) via AJAX request target.

Ernesto

On Wed, Jun 30, 2010 at 3:44 PM, Ernesto Reinaldo Barreiro
<re...@gmail.com> wrote:
> Hi Steve,
>
> I would do the following (which might not be the best solution;-):
>
> 1- Create panel "EmptyOrTablePanel" with setOutputMarkupId(true);
> 2- and then have a child of this panel that either displays an
> EmptyPanel or your table: depending on whether you have records or
> not. You could determine that on the onBeforeRender of
> "EmptyOrTablePanel"panel and use addOrReplace to put the table or the
> EmptyPanel.
> 3- Just tell this panel to update itself after AJAX operations.
>
> Best,
>
> Ernesto
>
> On Wed, Jun 30, 2010 at 3:29 PM, Steve Hiller <sh...@bellsouth.net> wrote:
>> Hi All,
>>
>> I have what seems like a strange problem with refreshing a DataView.
>>
>> I have a WebMarkupContainer that contains a DataView.
>> The DataView uses a SortableDataProvider as its DataProvider.
>> The WebMarkupContainer uses the DataView's SortableDataProvider
>> to determine if there are any items to be displayed within the DataView.
>> If there any items then the WebMarkupContainer's isVisible() method
>> returns true, and therefore the WebMarkupContainer and DataView should
>> be rendered.
>>
>> I am also using a ModalWindow to add new items to the DataView.
>> On exiting from the ModalWindow, I am using an AjaxRequestTarget
>> to refresh the WebMarkupContainer and therefore redraw the DataView
>> with the new item added to it.
>>
>> This all works fine IF there were already items in the DataView when
>> it was first rendered during the initial loading of its page.
>>
>> If the DataView is initially empty then the WebMarkupContainer
>> is not rendered as expected on page load. My issue is that adding new
>> items via the ModalWindow does not cause the WebMarkupContainer and
>> DataView to be rendered. Via debugging, I can see that the
>> WebMarkupContainer's isVisible() method is returning true yet nothing
>> appears.
>>
>> Any suggestions on resolving this issue would be appreciated.
>>
>> Thanks so much,
>> Steve
>>
>>
>> ---------------------------------------------------------------------
>> 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: Refreshing DataView fails if it was initially empty

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Hi Steve,

I would do the following (which might not be the best solution;-):

1- Create panel "EmptyOrTablePanel" with setOutputMarkupId(true);
2- and then have a child of this panel that either displays an
EmptyPanel or your table: depending on whether you have records or
not. You could determine that on the onBeforeRender of
"EmptyOrTablePanel"panel and use addOrReplace to put the table or the
EmptyPanel.
3- Just tell this panel to update itself after AJAX operations.

Best,

Ernesto

On Wed, Jun 30, 2010 at 3:29 PM, Steve Hiller <sh...@bellsouth.net> wrote:
> Hi All,
>
> I have what seems like a strange problem with refreshing a DataView.
>
> I have a WebMarkupContainer that contains a DataView.
> The DataView uses a SortableDataProvider as its DataProvider.
> The WebMarkupContainer uses the DataView's SortableDataProvider
> to determine if there are any items to be displayed within the DataView.
> If there any items then the WebMarkupContainer's isVisible() method
> returns true, and therefore the WebMarkupContainer and DataView should
> be rendered.
>
> I am also using a ModalWindow to add new items to the DataView.
> On exiting from the ModalWindow, I am using an AjaxRequestTarget
> to refresh the WebMarkupContainer and therefore redraw the DataView
> with the new item added to it.
>
> This all works fine IF there were already items in the DataView when
> it was first rendered during the initial loading of its page.
>
> If the DataView is initially empty then the WebMarkupContainer
> is not rendered as expected on page load. My issue is that adding new
> items via the ModalWindow does not cause the WebMarkupContainer and
> DataView to be rendered. Via debugging, I can see that the
> WebMarkupContainer's isVisible() method is returning true yet nothing
> appears.
>
> Any suggestions on resolving this issue would be appreciated.
>
> Thanks so much,
> Steve
>
>
> ---------------------------------------------------------------------
> 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: Refreshing DataView fails if it was initially empty

Posted by shetc <sh...@bellsouth.net>.
Hi vov, thanks for your reply. I discovered that function last week but
nabble was not allowing me to reply at the time. It was a good idea to go
back and read the API docs.
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Refreshing-DataView-fails-if-it-was-initially-empty-tp2273568p2279663.html
Sent from the Wicket - User 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: Refreshing DataView fails if it was initially empty

Posted by vov <vo...@mail.ru>.
Use setOutputMarkupPlaceholderTag(true) for your component
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Refreshing-DataView-fails-if-it-was-initially-empty-tp2273568p2276085.html
Sent from the Wicket - User 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