为什么不接受super(id)?

问题描述 投票:1回答:2

我正在使用下拉菜单对网站进行编码。下拉菜单具有HTML面板和Java。

下拉菜单面板的Java

 package website.fgto.royals_of_britain.view.houses;

 import org.apache.wicket.markup.html.WebPage; import
 org.apache.wicket.settings.MarkupSettings; import
 org.apache.wicket.markup.html.link.BookmarkablePageLink; import
 org.apache.wicket.markup.html.link.Link; import
 org.apache.wicket.markup.repeater.RepeatingView; import
 org.apache.wicket.model.Model; import
 org.apache.wicket.request.mapper.parameter.PageParameters; import
 org.apache.wicket.spring.injection.annot.SpringBean;

 import website.fgto.royals_of_britain.service.HousesService;

 public class HousesDropdown extends WebPage {
      public HousesDropdown(String id) {
     super(id);

     add(buildDropdownLinks());   }

首页的Java

     package website.fgto.royals_of_britain.view.houses;

     import org.apache.wicket.markup.head.CssHeaderItem; import org.apache.wicket.markup.head.IHeaderResponse; import
 org.apache.wicket.markup.html.WebPage; import
 org.apache.wicket.markup.html.basic.Label; import
 org.apache.wicket.request.mapper.parameter.PageParameters; import
 org.apache.wicket.request.resource.CssResourceReference; import
 website.fgto.royals_of_britain.WicketApplication; import
 website.fgto.royals_of_britain.view.Apology; import
 website.fgto.royals_of_britain.view.Footer; import
 website.fgto.royals_of_britain.view.houses.intros.*; import
 website.fgto.royals_of_britain.view.kings.KingsTableRows;

     public class HouseInformationPage extends WebPage {   private static final long serialVersionUID = 1L;

       public HouseInformationPage(final PageParameters parameters) {
         super(parameters);

         String houseName = parameters.get("houseName").toString();

         add(new Label("houseName", houseName));
         add(new HousesDropdown("housesDropdown"));
         add(new Footer("footerPanel"));

所以问题是,如果我保持这样,IntelliJ表示id缺少字符串的Java方法。但是,如果我取出super(id),则表示实际参数和形式参数之间的长度有所不同。

java html wicket
2个回答
2
投票

WebPage提供了3个构造函数:

https://ci.apache.org/projects/wicket/apidocs/6.x/org/apache/wicket/markup/html/WebPage.html

默认值,一个接受IModel实例,另一个接受PageParameters作为参数。

字符串不是此构造函数调用的有效参数。

由于类扩展了WebPage,因此,如果在构造函数中调用super();super(x);,则实际上是在尝试调用WebPages构造函数之一,并且必须提供正确的参数。


0
投票

因此,我的错误是在构造函数中用WebPage替换了Panel。所以我的质询有争议。但是,由于我坚持使用面板来构建我的“下拉菜单”,所以仍然存在一些问题。如果您有兴趣,请在线程中为我的next问题发表评论!

© www.soinside.com 2019 - 2024. All rights reserved.