开发者

How to create commandlink programmatically

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}"/&g开发者_StackOverflow社区t;
</a4j:commandLink>

in a JSF page.

The table is binded to a managed bean with

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. These can be created with:

ExpressionFactory.getInstance().createValueExpression(ctx, expression, expectedType)

And the required ELContext can be obained via FacesContext.getCurrentContext().getELContext()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜