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
<[email protected]> 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 <[email protected]> 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: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to