简体   繁体   English

如何为多个对象创建表单输入字段?

[英]How to make form input fields for a many objects?

I am making an administrating interface for an mobile application that I made. 我正在为自己制作的移动应用程序创建管理界面。 I have a question entity and a answer entity. 我有一个问题实体和答案实体。 Multiple answer objects (between 3-5) belongs to a single question object. 多种答案对象之间(3-5)属于一个问题对象。

I am making a interface where I can register a new question with answers, how do I do that? 我正在创建一个界面,可以在其中注册带有答案的新问题,该怎么做? In the backing bean I have a Question object and then I bind the properties to the input fields, but I don't know what to do with the Answers? 在支持豆我有一个问题对象,然后我的属性绑定到输入字段,但我不知道用什么样的答案呢? And is it possible to make let say 4 input fields and have a button saying "Add answer" which makes a new input html tag? 是否可以让我们说4个输入字段,并有一个说“添加答案”的按钮,它会产生一个新的输入html标签?

(I am using Java EE 6 with all reference implementations). (我用的Java EE 6与所有的参考实现)。

The answers are specific to a question, right? 答案是针对特定问题的,对吗? Make the answers a property of the question. 使答案成为问题的属性。

public class Question {

    private List<Answer> answers;

    // ...
}

In your admin interface you could use an iterating component such as a <h:dataTable> to present multiple answers and add/remove them. 在您的管理界面中,您可以使用诸如<h:dataTable>类的迭代组件来呈现多个答案并添加/删除它们。 See also How to dynamically add JSF components 另请参见如何动态添加JSF组件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在弹簧中保存许多物体<form:form> - How to save many objects in a spring <form:form> 如何传递对象列表以在输入字段中动态查看和填充它们 - How to pass an list of objects to view and populate them in input fields dynamically 如何在android中创建对象的listview并通过单击listitems访问对象字段? - how to make a listview of objects in android and access the object fields by clicking listitems? 如何制作可以迭代许多类型对象的迭代器 - How to make an Iterator that can Iterate many types of objects 如何将 Struts 2 push 标签用于表单输入字段? - How to use Struts 2 push tag for form input fields? 如何选择模态表单并使用Java将数据输入到输入字段 - How to select a Modal form and enter data to the input fields using Java 如何在表单上一次验证所有输入字段 select 选项 - How to validate all input fields, select options at a time on a form Java Play-如何制作一个具有2个字段的简单表单并将值发送到Controler? - Java Play - how to make a simple form with 2 fields and send values to Controler? 我怎样才能使我的表格需要某些字段 - How can I make it so that my form requires certain fields 此类中有多少个对象? - How many objects in this class?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM