igor.vaynberg wrote:
> 
> c.replacewith(a) is the same as c.getparent().replace(a)
> 

I want to extend this example and replace the panel but inside the ListView.
But I've found another problem.

I did like you wrote but the panel isn't replaced. The new panel is being
added at the top of the table.
Why?

The Page:
public class TestPage extends MyPage {

        private static final List<String> params = Arrays.asList( new
String[] { "one", "two", "three", "four"} );

        public TestPage(PageParameters parameters) {
                super(parameters);

                ListView view = new ListView("list", params) {
                        protected void populateItem(ListItem item) {
                                String s = (String) item.getModelObject();
                                item.add(new TestPanel("panel", s));
                        }
                };
                add(view);
        }
}

<wicket:extend>
    <table>
        <tr wicket:id="list">
            <span wicket:id="panel">[panel]</span>
        </tr>
    </table>
</wicket:extend>

The Panel:
        public TestPanel(String id, String param) {
                super(id);
                setOutputMarkupId(true);
                AjaxLink link = new AjaxLink("link") {
                        public void onClick(AjaxRequestTarget target) {
                                TestPanel newOne = new 
TestPanel(TestPanel.this.getId(), "another
param");
                                TestPanel.this.replaceWith(newOne);
                                target.addComponent(newOne);
                        }
                };
                link.add(new Label("label0", "click"));
                add(link);
                add(new Label("label1", param.toUpperCase()));
                add(new Label("label2", param.toLowerCase()));
        }

<wicket:panel>
    <td><a href="#" wicket:id="link"><span
wicket:id="label0">["label0"]</span></a></td>
    <td><span
wicket:id="label1">[label1]</span></td>    
    <td><span
wicket:id="label2">[label2]</span></td>
</wicket:panel>


Artur
-- 
View this message in context: 
http://www.nabble.com/Can-Panel-replace-itself---tf4318533.html#a12300076
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to