如何在JSF中动态添加字段? [英] How to Dynamically adding fields in JSF?

查看:85
本文介绍了如何在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:

  1. 我必须连续添加一个文本框和两个按钮(+)和(-).
  2. 当用户单击+按钮时,应在上面添加带有上述组件的新行.
  3. 当用户单击-按钮时,应从显示中删除相应的行.

我能够添加文本框之类的各个组件并将其删除.但是,在这里,我的挑战在于,要连续添加和删除.如何从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:dataTableList<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.

  • 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆