Inheritance 如何将带有单独标记的组件包含到另一个标记中?

Inheritance 如何将带有单独标记的组件包含到另一个标记中?,inheritance,wicket,composition,Inheritance,Wicket,Composition,我有一个面板,它定义了一个其他面板应该去的地方。不能有任何继承,因为不仅有大量的继承,而且它们将在整个应用程序中使用 我想“包括”的组件也扩展了面板本身。我希望能够在组件中使用标记1执行类似的操作,独立于组件2实现 有可能吗?我非常清楚遗产是如何运作的。但是关于构图的内容并不多 堆栈跟踪: Last cause: The component(s) below failed to render. Possible reasons could be that: 1) you have added a

我有一个面板,它定义了一个其他面板应该去的地方。不能有任何继承,因为不仅有大量的继承,而且它们将在整个应用程序中使用

我想“包括”的组件也扩展了面板本身。我希望能够在组件中使用标记1执行类似的操作,独立于组件2实现

有可能吗?我非常清楚遗产是如何运作的。但是关于构图的内容并不多

堆栈跟踪:

Last cause: The component(s) below failed to render. Possible reasons could be that: 1) you have added a component in code but forgot to reference it in the markup (thus the component will never be rendered), 2) if your components were added in a parent container then make sure the markup for the child container includes them in <wicket:extend>.

1. [BlockingAjaxSubmitLink [Component id = link_language_add]]
2. [ListView [Component id = language_placeholder]]
3. [ListItem [Component id = 0]]
4. [LanguagePanel [Component id = language]]
5. [WebMarkupContainer [Component id = container_name]]
6. [TextField [Component id = name]]
7. [Component id = feedback_name]
8. [WebMarkupContainer [Component id = container_proficiency]]
9. [TextField [Component id = proficiency]]
10. [BlockingAjaxLink [Component id = link_remove]]
11. [ListItem [Component id = 1]]
12. [LanguagePanel [Component id = language]]
13. [WebMarkupContainer [Component id = container_name]]
14. [TextField [Component id = name]]
15. [Component id = feedback_name]
16. [WebMarkupContainer [Component id = container_proficiency]]
17. [TextField [Component id = proficiency]]
18. [BlockingAjaxLink [Component id = link_remove]]
最后一个原因:以下组件未能呈现。可能的原因是:1)您在代码中添加了一个组件,但忘记在标记中引用它(因此该组件将永远不会被呈现);2)如果您的组件是在父容器中添加的,那么请确保子容器的标记中包含它们。
1.[BlockingAjaxSubmitLink[Component id=link\u language\u add]]
2.[列表视图[组件id=语言\占位符]]
3.[ListItem[组件id=0]]
4.[语言面板[组件id=语言]]
5.[WebMarkupContainer[Component id=container\u name]]
6.[TextField[Component id=name]]
7.[组件id=反馈\u名称]
8.[WebMarkupContainer[Component id=container\u]]
9[文本字段[组件id=熟练程度]]
10[BlockingAjaxLink[Component id=link\u remove]]
11[ListItem[组件id=1]]
12[语言面板[组件id=语言]]
13[WebMarkupContainer[Component id=container\u name]]
14[TextField[Component id=name]]
15[组件id=反馈\u名称]
16[WebMarkupContainer[Component id=container\u]]
17[文本字段[组件id=熟练程度]]
18[BlockingAjaxLink[Component id=link\u remove]]

所有这些组件都在表单中,或者至少应该在表单中看到。

好吧,我想这是一个相当愚蠢的错误

记住WebMarkupContainer和Panel之间的区别

面板有其自己的html文件,并将其包含在旁边

鉴于

WebMarkupContainer没有其自己的html文件,只依赖于组件添加到的文件中的标记


无论如何,谢谢:)

好吧,我想这是个相当愚蠢的错误

记住WebMarkupContainer和Panel之间的区别

面板有其自己的html文件,并将其包含在旁边

鉴于

WebMarkupContainer没有其自己的html文件,只依赖于组件添加到的文件中的标记


无论如何谢谢:)

我明白了。。。。那么,试着保持这样的模式:页面->表单->面板。另外,尽量不要将组件放在窗体或面板中

public class Page extends WebPage{

private MyForm myForm;

public Page(){
myForm = new()....;
  }

}

public class MyForm extends Form<T>{

  public MyForm(String id){
    super(id);
  }

}

public class MyPanel extends Panel{

//your components

  public MyPanel(String id){
   super(id);
  }

}

[wicket:extend]

  [form wicket:id="myForm"]

    [div wicket:id="myPanel"/]

  [form]
[/wicket:extend]

[wicket:panel]

[div wicket:id="myPanel"]

[/div]

[/wicket:panel]
公共类页面扩展网页{
私人MyForm MyForm;
公共网页(){
myForm=new()。。。。;
}
}
公共类MyForm扩展了表单{
公共MyForm(字符串id){
超级(id);
}
}
公共类MyPanel扩展面板{
//您的组件
公共MyPanel(字符串id){
超级(id);
}
}
[边门:延伸]
[表单wicket:id=“myForm”]
[div wicket:id=“myPanel”/]
[表格]
[/wicket:extend]
[边门:小组]
[div wicket:id=“myPanel”]
[/div]
[/wicket:panel]

我明白了。。。。那么,试着保持这样的模式:页面->表单->面板。另外,尽量不要将组件放在窗体或面板中

public class Page extends WebPage{

private MyForm myForm;

public Page(){
myForm = new()....;
  }

}

public class MyForm extends Form<T>{

  public MyForm(String id){
    super(id);
  }

}

public class MyPanel extends Panel{

//your components

  public MyPanel(String id){
   super(id);
  }

}

[wicket:extend]

  [form wicket:id="myForm"]

    [div wicket:id="myPanel"/]

  [form]
[/wicket:extend]

[wicket:panel]

[div wicket:id="myPanel"]

[/div]

[/wicket:panel]
公共类页面扩展网页{
私人MyForm MyForm;
公共网页(){
myForm=new()。。。。;
}
}
公共类MyForm扩展了表单{
公共MyForm(字符串id){
超级(id);
}
}
公共类MyPanel扩展面板{
//您的组件
公共MyPanel(字符串id){
超级(id);
}
}
[边门:延伸]
[表单wicket:id=“myForm”]
[div wicket:id=“myPanel”/]
[表格]
[/wicket:extend]
[边门:小组]
[div wicket:id=“myPanel”]
[/div]
[/wicket:panel]

您能显示一些代码吗?我不明白你的问题。你可以将面板加入到你心中的内容中。你是说碎片吗?这就是路吗?你能展示一些代码吗?我不明白你的问题。你可以将面板加入到你心中的内容中。你是说碎片吗?这就是路吗?这正是结构的样子。但是我缺少的是这样一个事实,即只有面板可以包含在另一个面板的单独标记中。您的意思是,将一个面板插入另一个面板的webMarkupContainer吗?在模拟的情况下,是的,您可以插入它,但不能使用相同的标记id。这正是结构的外观。但是我缺少的是这样一个事实,即只有面板可以包含在另一个面板的单独标记中。您的意思是,将一个面板插入另一个面板的webMarkupContainer吗?在模拟情况下,可以插入,但不能使用相同的标记id。