That's what I did when the component has to be overriden in subclasses.
But how does it work when the component is common to every concrete page? I
would not want to redefine common component in every concrete page. 

Let's see my example, In my parent page :

public abstract class TestForm extends WebPage {
   
    public TestForm() {
        add(new Label("myDiv", "my div from test form")); => common to every
concrete page
        add(createDivWithComponent("myNewPanel")); => has to be redefine by
each concrete page
        add(createDivWithComponent2("myNewPanel2")); => has to be redefine
by each concrete page
        
    }
    
    protected abstract WebMarkupContainer createDivWithComponent(String
divId);
    
    protected abstract WebMarkupContainer createDivWithComponent2(String
divId);
}

<body>
          
        <div wicket:id="myNewPanel"></div>
        <div wicket:id="myNewPanel2"></div>
</body>

And, the concrete page :
public class TestFormOne extends TestForm {

    
    public TestFormOne() {
       super();
    }
    
    @Override
    protected WebMarkupContainer createDivWithComponent(String divId) {
        WebMarkupContainer container = new WebMarkupContainer(divId);
        container.add(new Label("label","My very good label 1"));
        return container;
    }

    @Override
    protected WebMarkupContainer createDivWithComponent2(String divId) {
        WebMarkupContainer container = new WebMarkupContainer(divId);
        WebMarkupContainer container2 = new WebMarkupContainer("div1");
        container2.add(new Label("label2","My very good label 2"));
        container.add(container2);
        return container;
    }

}

<body>
          
        <div wicket:id="myNewPanel"></div>
        <div wicket:id="myNewPanel2"></div>
</body>

And this is the error message I get : WicketMessage: The component(s) below
failed to render. A common problem is that you have added a component in
code but forgot to reference it in the markup (thus the component will never
be rendered).1. [Component id = myDiv]

What did I miss?

Thank you.


Ilja Pavkovic-3 wrote:
> 
> 
> public abstract class MyPage extends WebPage {
> 
>       public MyPage() {
>               add(createMyDiv("myDiv"));
>        }
> 
>       public abstract Component createMyDiv(String markuId);
> }
> 
> public MyConcretePage extends MyPage {
> 
> 
>       public createMyDiv(String markupId) {
>               return new Label(markupId);
>       }
> }
> 
> Am Montag, 25. Januar 2010 11:24:55 schrieb Wilhelmsen Tor Iver:
>> > So in my parent html :
>> > <body>
>> >    
>> >    <div wicket:id="myNewPanel"></div>
>> >    <div wicket:id="myNewPanel2"></div>
>> > </body>
>> >
>> > And add a label with id "myDiv" in related parent java. This part is
>> > common to all classes.
>> >
>> > But when I render the TestFormOne, that doesn't work because,
>> > apparently the label "myDiv" must be define in subclass.
>> 
>> You should add a default component for it in the parent class then use
>>  replace() in subclasses as needed.
>> 
>> - Tor Iver
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>> 
> 
> -- 
> binaere bauten gmbh · tempelhofer ufer 1a · 10961 berlin
> 
>    +49 · 171 · 9342 465
> 
> Handelsregister: HRB 115854 - Amtsgericht Charlottenburg
> Geschäftsführer: Dipl.-Inform. Ilja Pavkovic, Dipl.-Inform. Jost Becker
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Override-fragments-in-subclasses-tp27271408p27306708.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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

Reply via email to