开发者

is it possible to abort <f:ajax> with "return false"?

开发者 https://www.devze.com 2023-03-20 21:09 出处:网络
If you do this: <h:commandButton action=\"...\" onclick=\"return false\" /> The action will not occur.

If you do this:

<h:commandButton action="..." onclick="return false" />

The action will not occur.

The same does not work for <f:ajax>开发者_JAVA技巧, meaning this doesn't work:

<f:ajax event="click" onevent="return false" listener="#{mrBean.doSomething()}" >
    <h:commandLink value="A Link"  \>
</f:ajax>

Or more correctly, the ajax action runs and I get this error in the javascript console:

Uncaught SyntaxError: Unexpected token return
myfaces._impl.core._Runtime.singletonExtendClass.chainjsf.js.jsf:7491
chainjsf.js.jsf:7696
(anonymous function)file.jsf
onclick

Is there a way abort the <f:ajax> action through a javascript in a similar fashion to the h:commandbutton example?


I did this:

<f:ajax event="click" onevent="doTheRefreshingPart()" listener="#{mrBean.doSomething()}" >
    <h:commandLink value="A Link" onclick="return doTheConfirmationPart" \>
</f:ajax>

I moved the part that is confirmation dependent to the actual commandlink and left the part that takes part of refreshing the page in the <f:ajax> part

0

精彩评论

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