在wicket的listview中添加通用多文本字段

在wicket的listview中添加通用多文本字段,listview,wicket,textfield,Listview,Wicket,Textfield,我需要在网页中动态填充文本字段,我已经使用了listview Form <BenificiaryFormModel> registerForm = new Form<BenificiaryFormModel>("registerForm",Model.of(new BenificiaryFormModel())); ListView listView = new ListView("registerListView", benificiaryRegFieldsL

我需要在网页中动态填充文本字段,我已经使用了listview

Form <BenificiaryFormModel> registerForm = new Form<BenificiaryFormModel>("registerForm",Model.of(new BenificiaryFormModel()));

    ListView listView = new ListView("registerListView", benificiaryRegFieldsList) {

                    @Override
                   protected void populateItem(ListItem item) {

                    LOG.debug("Increamenter value {}",incrementer);


                    BenificiaryRegFieldsBean listViewBean = (BenificiaryRegFieldsBean )item.getModelObject();

                     item.add(new Label("beneficiaryLabel", listViewBean .getLabel())); 


                        item.add(new TextField("beneficiaryTextField", new PropertyModel(benificiaryFormModel,"textFieldData."+incrementer)));//,"textFieldData."+incrementer)));
                     incrementer++;
                    }
            };
formregisterform=新表单(“registerForm”,Model.of(new BenificiaryFormModel());
ListView ListView=新建ListView(“registerListView”,BenificiaryRegfieldList){
@凌驾
受保护的void populateItem(列表项){
debug(“incrementer value{}”,incrementer);
BenificiaryRefieldBean listViewBean=(BenificiaryRefieldBean)项。getModelObject();
添加(新标签(“受益人标签”,listViewBean.getLabel());
添加(新文本字段(“受益人文本字段”,新属性模型(benificiaryFormModel,“文本字段数据”。+incrementer));/,“文本字段数据”。+incrementer));
递增器++;
}
};
我参考了链接并做了相同的操作,但我收到了警告消息,并且控件没有出现onSumit警告消息,如下所示: 2015-07-16 12:17:50484[http-bio-8082-exec-9]WARN org.apache.wicket.markup.html.form.AbstractTextComponent:166-无法解析模型的模型类型:classname=[org.apache.wicket.model.PropertyModel]:nestedModel=[com.sybase365.mobiliser.web.beans]。BenificiaryFormModel@bde32]:expression=[textFieldData.0]表示[MarkupContainer][Component id=BenegiaryTextField]],请自行设置类型


将有多个文本框和标签,并且只有一个提交按钮来更新所有字段,因此请帮助我如何在SUMIT上获取文本字段的值。

尝试使用
item.setModel(新的CompoundPropertyModel(item.getModelObject());


如果您使用的是PropertyModel,那么您需要在页面类中定义setter/getter。对于CompoundPropertyModel,您的bean的setter/getter将完成这项工作。

@John Carpenter,在提交时如何获取组件的值例如,我需要在文本字段中输入的值没有getter方法我如何获取这些值而且,对于多个文本字段,只有一个提交按钮,我需要更新submit()上一个按钮上的所有值。我的操作与链接中的相同,但控件本身并没有出现Submit按钮,显示如下警告消息:WARN org.apache.wicket.markup.html.form.AbstractTextComponent:166-无法解析模型的模型类型:classname=[org.apache.wicket.model.PropertyModel]:nestedModel=[com.sybase365.mobiliser.web.beans]。BenificiaryFormModel@bde32]:expression=[textFieldData.0]表示[MarkupContainer[Component id=BenegiaryTextField]],请自己设置类型。您需要使用bean.someRecordList作为复合属性模型,才能将这些值设置到列表中。一旦有了列表,请将其从服务层保存到数据库,或者以任何方式保存。为消除可能的混淆,进行了一些小的更正:您需要将bean.someStringList作为文本字段的属性名设置/获取“someStringList”将存储这些文本字段的值。