如何在JSF中动态添加字段? [英] How to Dynamically adding fields in JSF?
问题描述
大家好,
我急切地希望获得有关使用JSF添加和删除字段和行的帮助.我将ICE Faces用于丰富的UI外观.以下是我的问题:
I am desperately looking for the assistance on adding and removing the fields and rows using JSF. I am using ICE Faces for the rich UI look. The following is my problem:
- 我必须连续添加一个文本框和两个按钮(+)和(-).
- 当用户单击+按钮时,应在上面添加带有上述组件的新行.
- 当用户单击-按钮时,应从显示中删除相应的行.
我能够添加文本框之类的各个组件并将其删除.但是,在这里,我的挑战在于,要连续添加和删除.如何从UI视图根中删除该特定行(实例).
I am able to add the individual components like text box and remove it. But, here my challenging point is to add and remove as a row. How would I remove that specific row (instance) from the UI View Root.
我已经尝试了好几次,但是直到现在我都找不到解决方案.请给我建议可能的解决方案.
I have tried several times, but till now I could not find a solution. Please suggest me the possible solutions.
预先感谢, 克里希纳
推荐答案
而是使用h:dataTable
(或与IceFaces等效的ice:dataTable
),该h:dataTable
由List<Data>
连续对象支持,每个对象均表示单个数据排.在添加上,只需将一个新的Data
项添加到列表中即可.在删除上,只需从列表中删除选定的Data
项即可.
Rather use a h:dataTable
(or the IceFaces equivalent ice:dataTable
) which is backed by a List<Data>
contining objects which each represents the data of a single row. On Add just add a new Data
item to the list. On Remove just remove the selected Data
item from the list.
- 如何动态地向其中添加新行表格?-类似问题的详细答案
- 使用数据表-逐步显示了如何使用数据表在JSF 1.x中.
- 使用@ViewScoped的CRUD数据表 -JSF 2.0 CRUD的简单示例
- How to dynamically add new row to table? - detailed answer to similar question
- Using Datatables - shows step by step how to use datatables in JSF 1.x.
- CRUD datatable using @ViewScoped - simple example of JSF 2.0 CRUD
这篇关于如何在JSF中动态添加字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!