-3

我添加了一个Form提交时我必须添加更多检票口控件,如标签、文本字段和带有 Ajex 链接的按钮。但无法获得正确的 HTML。谁能帮我摆脱它?

凭证面板.html

<html xmlns:wicket>
<head>
</head>
<body>
  <wicket:panel>
    <div class="form-block">
      <div wicket:id="form">
        <wicket:message key="lbl.vouchercode" />
        <div wicket:id="list">
          <input wicket:id="word" type="text" />
        </div>
        <div wicket:id="vouchercode"></div>
      <button wicket:id="submit"><wicket:message key="submitText"/></button>   
      </div>
    </div>
  </wicket:panel>
</body>
</html>

凭证面板.java

public class VoucherPanel extends Panel
{
  private static final long serialVersionUID = 1L;

  public VoucherPanel(final String id)
  {
    super(id);

    final TextField<String> voucherCodeField = new TextField<String>("vouchercode", Model.of(""));
    voucherCodeField.setRequired(true);

    final Button button = new Button("submit");

    Form<?> form = new Form<Void>("form")
    {

      @Override
      protected void onSubmit()
      {

              numberOfFields = new ArrayList<String>();

              int noOfVocuhers = getNoOfAllowedVoucher();// just returing the number
              for (int i = 0; i < noOfVocuhers; i++) {
                numberOfFields.add(new String(""));
            }

            add(new ListView<Object>("list", numberOfFields) {
                private static final long serialVersionUID = 1L;

                @Override
                protected void populateItem(ListItem<Object> item) {
                    final String word = (String) item.getModelObject();
                    System.out.println( "word   =" +word );
                    TextField<String> textField = new TextField<String>("word",  Model.of(""));
                    textField.setOutputMarkupId(true);
                    item.add(textField);
                }
            });

        }
      }
    };

    add(form);

    form.add(voucherCodeField);
    form.add(button);
  }
}
4

1 回答 1

1
  1. 您正在尝试将 a 分配Textfield<div>元素 ( voucherCode),而您需要<input type="text">
  2. 您需要立即添加list到您的表单中,onSubmit为时已晚。只需设置在外面,类似于提交表单时button调用。myListView.setList

这是我发现的两件事……如果您仍有问题,请告诉我们您收到的错误消息。

于 2013-07-30T14:17:44.557 回答