JSF的高手快进来呀..MethodBinding的问题

动态创建一个表格,在UIColumn组件上,通过ValueBinding可以实现值绑定..但是我想在UIColumn上绑定CommandLink组件,然后在往CommandLink上实现方法绑定,就不行啦..不报错,但是方法没绑定上去.....
private void addCommandColumnToTable(FacesContext context,
String columnName, String commandName, String bindingCommand,
UIData table) {
// 新建数据列
UIColumn column = new UIColumn();
column.setId("col_" + columnName);
// 新建header项
HtmlOutputText header = new HtmlOutputText();
header.setId("hdr_" + columnName);
header.setValue(columnName);
// header.setStyleClass("outputText");
// 新建文本链接项
HtmlCommandLink commandlink = new HtmlCommandLink();
// 绑定动作
Class[] clas={ActionEvent.class};
MethodBinding mBinding = context.getApplication().createMethodBinding(
"#{dynamicCreate.clickpln}",clas);
commandlink.setAction(mBinding);
// commandlink.setType("submit");
// 新建命令文本
HtmlOutputText text = new HtmlOutputText();
text.setId("output_" + columnName);
// text.setStyleClass("outputText");
text.setValue(commandName);
// 逐加入命令中
commandlink.getChildren().add(text);
// 逐个添加项
column.setHeader(header);
column.getChildren().add(commandlink);
// 逐加入表中
table.getChildren().add(column);
}
高手,,帮我看下这段问题...


下面这段我是直接绑定panelGrid上面,,这段就行..
public HtmlPanelGrid getPanelGrid(){
FacesContext facesContext = FacesContext.getCurrentInstance();
Application application = facesContext.getApplication();
HtmlPanelGrid panelGrid = (HtmlPanelGrid) application
.createComponent(HtmlPanelGrid.COMPONENT_TYPE);
//建立一个文本.
HtmlOutputText outText = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE);
outText.setTitle("try_UIC_1");
outText.setValue("Bind");
panelGrid.getChildren().add(outText);
// 建立一个按钮....
//FacesContext context = FacesContext.getCurrentInstance();
MethodBinding mb = (MethodBinding) facesContext.getApplication().createMethodBinding("#{dynamicCreate.clickpln}", null);
HtmlCommandButton newOne=new HtmlCommandButton();
newOne.setValue("DynaButton");
newOne.setAction(mb);
panelGrid.getChildren().add(newOne);
panelGrid.setColumns(1);
return panelGrid;
}

[b]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值