如何使用 JSF 2.0 复合组件实现动态列表?
我问了这个问题,尽管答案直接满足了我的需求我感觉必须有一个更简单的解决方案来解决这个特定问题。
我想要一个接受项目列表的复合组件(商定的项目类型,以便可以在复合组件中自由使用成员)
CC(复合组件)显示项目列表并允许添加和项目的减法。
我想以最简单、最有效的方式做到这一点。
为了说明这个问题,举个例子:
定义应该相当简单(当然,除非它不是: -) ):
<special:dynamicFieldList value="#{bean.fieldList} />
Field
对象最抽象的形式是:
public class Field{
String uuid;
String value;
}
我想就是这样。 您将如何以简单的方式实现这一点?
谢谢!
I asked this question and although the answer directly satisfied my needs I am left with a feeling that there has to a simpler solution for this specific problem.
I would like to have a composite component that accepts a list of items (The type of the items agreed upon so the members can be used freely within the composite component)
The CC (composite component) display the list of items and allows for addition and subtraction of items.
I would like to do this in the most simple and efficient manner.
To illustrate the problem, an example:
The definition should be rather simple (unless of course, its not :-) ):
<special:dynamicFieldList value="#{bean.fieldList} />
The most abstract form of a Field
object would be:
public class Field{
String uuid;
String value;
}
I guess that's it.
How would you implement this in a simple manner?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我将在带有支持
UIComponent
的复合组件中使用
,您可以通过componentType
属性进行绑定代码><复合:接口>。然后,您可以在支持UIComponent
中维护DataModel
并定义操作。dynamicFieldList.xhtml
(如有必要,
可以是您的复合字段组件)com.example.DynamicFieldList< /code>
按如下方式使用:
仅使用此
和
I'd use a
<h:dataTable>
in a composite component with a backingUIComponent
which you can bind bycomponentType
attribute of the<composite:interface>
. In the backingUIComponent
you can then maintain theDataModel
and define the actions.dynamicFieldList.xhtml
(the
<h:inputText>
can if necessary be your composite field component)com.example.DynamicFieldList
Use it as follows:
with just this
and