0

In wicket 1.4.x I have custom Container + panel for my pages:

example:

MyPage.java

public class MyPage extends WebPage {
     public MyPage(){
         add(new CustContainer, "custContainer");
     }

}

MyPage.html

<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<head></head>
<body>
     <div wicket:id="custContainer"></div>
</body>
</html>

Custcontainer.java

public class CustContainer extends WebMarkupContainer {
     private Component comp;
     public CustContainer(String id){
          super(id);
          this.comp = new CustPanel("custPanel");
     }

     @Override
     protected void onRender(MarkupStream markupStream) {
          comp.render(getMarkupStream());
     }
}

CustPanel.java

public class CustPanel extends Panel {
     public CustPanel(String id){
          super(id);
          add(new Label("label1","This is my Label"));
     }
}

CustPanel.html

<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
     <div><span wicket:id="label1"></span></div>
</wicket:panel>
</html>

In wicket 1.4.x this code (which is simplified) works very well, but in wicket 9 Component.render() method have removed MarkupStream as param. And when I'm trying to just Component.render() it does not understand anymore that it needs to take custPanel.html <div><span wicket:id="label1"></span></div> part and insert into MyPage.html markup inside <div wicket:id="custContainer"> HERE </div>

Question: anyone have idea how to solve this issue ? because adding <div wicket:id="custPanel"></div> into custContainer div block is not a option because I need to add these panels/component id's dynamically from db:

example:

<div wicket:id="custContainer"> <div wicket:id="custPanel"></div> </div>

So I somehow need to add <div wicket:id="custPanel"> into custContainer div block before rendering markup.

BTW:

@Override
public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag)

is not a solution, its only changes markup after markup render and exception is thrown.

Long story short: I want all CustPanel.html wicket body included into MyPage.html div block with wiket id = custContainer

<div wicket:id="custContainer">HERE I need CustPanel.html wicket content to be rendered/included</div>

1 Answer 1

0

since Wicket 1.5 you can set component markup explicitly with Componet.setMarkup or use interface IMarkupResourceStreamProvider to generate it.

2
  • yes but i do not need to generate, i need to read it from Markup files -> MyPage.html and CustPanel.html Componet.setMarkup() sets markup but still at that point it does not want to read/load existing markup file. Can you please provide with some short example how to use IMarkupResourceStreamProvider ?
    – eman
    Commented Jun 17 at 6:53
  • You can find an example for IMarkupResourceStreamProvider in the user guide: nightlies.apache.org/wicket/guide/10.x/… . See if it can fit your needs. Commented Jun 18 at 20:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.