[英]Create commandButton in JSF using loop?
for an example in an array there is对于数组中的示例,有
Edit --> #{testBean.edit}编辑 --> #{testBean.edit}
Delete --> #{testBean.delete}删除 --> #{testBean.delete}
Copy --> #{testBean.copy}复制 --> #{testBean.copy}
is it possible to create commandbutton using loop or something是否可以使用循环或其他东西创建命令按钮
for(i=0;i<=array.length;i++)<br>
{
print '<h:commandbutton value="#{testBean.array.name}" action="#{testBean.array.action}" />'
}
so the output shld be like所以 output 应该像
<h:commandbutton value="Edit" action="#{testBean.edit}" />
<h:commandbutton value="Delete" action="#{testBean.delete}" />
<h:commandbutton value="Copy" action="#{testBean.copy}" />
That's only possible if you change the collection (map?) to look something like只有将集合(地图?)更改为类似
Edit --> edit Delete --> delete Copy --> copy
Eg例如
Map<String, String> buttons = new LinkedHashMap<String, String>();
buttons.put("Edit", "edit");
buttons.put("Delete", "delete");
buttons.put("Copy", "copy");
You can then loop over it as follows:然后,您可以按如下方式循环它:
<ui:repeat value="#{bean.buttons}" var="button">
<h:commandButton value="#{button.key}" action="#{bean[button.value]}" />
</ui:repeat>
As an alternative, you can create the components programmatically from in the bean side.作为替代方案,您可以在 bean 端以编程方式创建组件。
Have tried Facelet repeat Tag http://www.roseindia.net/jsf/repeat.shtml试过 Facelet 重复标签http://www.roseindia.net/jsf/repeat.shtml
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.