我经常使用,但我有这个问题。 如果有一个动作是删除某个实体,但我想通知用户点击这个命令链接一个javascript函数确认(str);如果confirm()回答为false,则不会触发ajax函数。所以我开始使用jsf.ajax.request函数;我的代码就像这样。
<h:commandLink value="ajax" onclick="return ask(this,event,null,'page');" actionListener="#{test.ajax}"/>
<h:inputText value="#{test.page}" id="page"/>
这是我的javascript代码
function ask(element,event,exec,target){
if(confirm("are you ready to delete it"))
{
try{
jsf.ajax.request(element,event,{execute:exec,render:target});
}catch(ex){
alert(ex);
return false;
}
}else
return false;
}
,但它可以成功执行,但我发现它不是ajax.back bean的其他值也会更新! 如果某人能告诉我的话!不胜感激!
答案 0 :(得分:1)
您无需接管<f:ajax>
的工作。只需返回onclick。
<h:commandLink value="ajax" action="#{test.ajax}" onclick="return confirm('Are you sure?')">
<f:ajax execute="@this" render="page" />
</h:commandLink>
<h:inputText value="#{test.page}" id="page"/>
并使用action
代替actionListener
。您可以在那里返回null
或void
。
答案 1 :(得分:0)
我已经解决了我的问题。这是因为我不理解jsf.ajax.request
。如果我希望在支持中调用actionListener
,我还会执行其所有者 - dom对象的actionListener
。