[英]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.