SV: Override fragments in subclasses

2010-01-25 Thread Wilhelmsen Tor Iver
 So in my parent html :
 body
   span wicket:id=myDiv/span
   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



Re: SV: Override fragments in subclasses

2010-01-25 Thread Ilja Pavkovic

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
  span wicket:id=myDiv/span
  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



Re: SV: Override fragments in subclasses

2010-01-25 Thread aurelie.boiteux

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



Re: SV: Override fragments in subclasses

2010-01-25 Thread aurelie.boiteux

Ok,

There was a problem when copy/paste html, sorry about that:

TestForm.html (parent html):
body
  
div wicket:id=myNewPanel/div
div wicket:id=myNewPanel2/div
/body

and TestFormOne.html(subclass html):
body
wicket:fragment wicket:id=myNewPanel

/wicket:fragment

wicket:fragment wicket:id=myNewPanel2
div wicket:id=div1/div
/wicket:fragment
/body


aurelie.boiteux wrote:
 
 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
 wicket:fragment wicket:id=myNewPanel
 
 /wicket:fragment
 
 wicket:fragment wicket:id=myNewPanel2
 div wicket:id=div1/div
 /wicket:fragment
 /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-tp27271408p27306736.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



Re: SV: Override fragments in subclasses

2010-01-25 Thread Ilja Pavkovic
Hi,

I think you should provide component classes that are responsible for sub 
elements


class TestFormPanel extends Panel {
public TestFormPanel(String markupId) {
super(markupId);
add(new Label(label,My very good label 1));
}
}

TestFormPanel.html:
body
div wicket:id=label[label]/div
/body

and use it in TestFormOne
public class TestFormOne extends TestForm {
@Override
protected Component createDivWithComponent(String divId) {
return new TestFormPanel(divId);
}   


But maybe I don't quite understand your problem.

Best Regards,
Ilja



 There was a problem when copy/paste html, sorry about that:
 
 TestForm.html (parent html):
 body
 
   div wicket:id=myNewPanel/div
   div wicket:id=myNewPanel2/div
  
 /body
 
 and TestFormOne.html(subclass html):
 body
 wicket:fragment wicket:id=myNewPanel
 
 /wicket:fragment
 
 wicket:fragment wicket:id=myNewPanel2
   div wicket:id=div1/div
 /wicket:fragment
 /body
 
 aurelie.boiteux wrote:
  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
  wicket:fragment wicket:id=myNewPanel
 
  /wicket:fragment
 
  wicket:fragment wicket:id=myNewPanel2
  div wicket:id=div1/div
  /wicket:fragment
  /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



SV: SV: Override fragments in subclasses

2010-01-25 Thread Wilhelmsen Tor Iver
 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);
 }

An alternative is to have these either provide default/null components or throw 
WicketRuntimeExceptions.

 
 body
 
   div wicket:id=myNewPanel/div
   div wicket:id=myNewPanel2/div
 /body
 


 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

That markup is missing the div1 and label2 markup, but it does not get that 
far because

 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]

... this means that there is no markup for the component you added at the start 
of the parent constructor:
add(new Label(myDiv, my div from test form));

- Tor Iver