日期:2014-05-18  浏览次数:20590 次

jsf超难的问题,再现等
<h:commandLink> 标签没有onclick方法,请问我如果想点击这个连接产生一个对话框怎么办?



------解决方案--------------------
谁说没有呀?????这样写:
<h:commandLink id= "sub2 " action= " " onclick= "alert( 'hello ');return false; ">
<h:outputText value= " 读卡11 " />
</h:commandLink>

------解决方案--------------------
是没有onclick方法.但 <h:commandLink> 有一个onclick 属性.
JSF1.2以前h:commandLink指定了onclick 属性为内部使用. 因此你不可以使用她了, 该问题已经在JSF1.2中修复了,对于JSF1.2以前的版本,你可以使用另一个onmousedown 的属性.
如:
<script language= "javascript ">
function ConfirmDelete(link) {
var del = confirm( 'Do you want to Delete? ');
if (del == true) {
link.onclick();
}
}
</script>
...
<h:commandLink action= "delete " onmousedown= "return ConfirmDelete(this); ">
<h:outputText value= "delete it "/>
</h:commandLink>

------解决方案--------------------
zzll_love(liliang) 其實不管什么標簽,它其實最終都是HTML標簽,我不是說了嗎,你看看

<h:commandLink value= "#{msgs.commandText} "
action= "#{user.verify} "/>
产生的HTML输出范例如下:
<a href= "# " onclick= "document.forms[ '_id3 '][ '_id3:_idcl '].value= '_id3:_id13 '; document.forms[ '_id3 '].submit(); return false; "> Submit </a>

你在 <h:outputlink> 類似h:commandLink 在onclick提交對應表單就好了,如果要重定向的話用
document.location.replace( "...... ")之類的方法;