0

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

我想要“包含”的组件也扩展了面板本身。我希望能够在带有标记 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]]

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

4

2 回答 2

2

好吧,我猜这是一个非常愚蠢的错误。

请记住 WebMarkupContainer 和 Panel 之间的区别。

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

然而

WebMarkupContainer没有自己的 html 文件,仅依赖于添加组件的文件中的标记。

无论如何谢谢 :)

于 2013-08-13T14:26:58.320 回答
1

我明白了....好吧,尝试保持这样的模式:页面->表单->面板。此外,尽量不要将您的组件放在表单或面板中。

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]
于 2013-08-13T17:33:06.170 回答