[英]How to create commandlink programmatically
We have a system built on seam/richfaces. 我们有一个基于接缝/ richfaces的系统。 There's this webpage where the tables are rendered from dynamic context (from multiple different datasources, and each of them uses a different layout to represent essentially the same real world concept).
在此网页上,表是根据动态上下文(来自多个不同的数据源,并且每个表使用不同的布局来表示本质上相同的现实概念)呈现的。 As a result, this table is binded to a bean, and it's columns/layout are generated from this bean.
结果,该表被绑定到一个bean,并且它的列/布局是从这个bean生成的。
Now I need to add a command link on a specific column, equivalent to 现在我需要在特定列上添加一个命令链接,相当于
<a4j:commandLink value="#{actBean.Ids}" action="#{actBean.genDetails}">
<f:setPropertyActionListener target="#{actBean.Ref}" value="#{cont}"/>
</a4j:commandLink>
in a JSF page. 在JSF页面中。
The table is binded to a managed bean with 该表通过以下方式绑定到托管bean:
HtmlDataTable dataTable = new HtmlDataTable();
HtmlColumn column = new Column();
//some code to setup column name, value etcs
dataTable.getChildren().add(column);
//What do I do here to bind a commandlink with a property action
//listener to column?
My question is, how do I do this programmatically? 我的问题是,如何以编程方式执行此操作?
Thanks! 谢谢!
HtmlAjaxCommandLink commandLink = new HtmlAjaxCommandLink();
commandLink.addActionListener(new SetPropertyActionListener(target, value));
column.getChildren().add(commandLink);
where target
and value
are ValueExpression
's. 其中
target
和value
是ValueExpression
的。 These can be created with: 这些可以通过以下方式创建:
ExpressionFactory.getInstance().createValueExpression(ctx, expression, expectedType)
And the required ELContext
can be obained via FacesContext.getCurrentContext().getELContext()
并且可以通过
FacesContext.getCurrentContext().getELContext()
创建所需的ELContext
FacesContext.getCurrentContext().getELContext()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.