问题描述
我们有一个基于接缝/richfaces的系统.在此网页上,表格是根据动态上下文(来自多个不同的数据源,并且每个表格使用不同的布局来表示本质上相同的现实概念)呈现的.结果,该表被绑定到一个bean,并且它的列/布局是从这个bean生成的.
We have a system built on seam/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.
现在,我需要在特定列上添加一个命令链接,该链接等效于
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>
在JSF页面中.
使用
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?
谢谢!
推荐答案
HtmlAjaxCommandLink commandLink = new HtmlAjaxCommandLink();
commandLink.addActionListener(new SetPropertyActionListener(target, value));
column.getChildren().add(commandLink);
,其中target
和value
是ValueExpression
.这些可以通过以下方式创建:
where target
and value
are ValueExpression
's. These can be created with:
ExpressionFactory.getInstance().createValueExpression(ctx, expression, expectedType)
然后可以通过FacesContext.getCurrentContext().getELContext()
这篇关于如何以编程方式创建命令链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!