开发者

How to detect in JSF when the backing bean method returns

开发者 https://www.devze.com 2023-02-11 04:19 出处:网络
I need to detect when the backing bean method returns so that I can execute a javascript function. Alternatively, calling javascript code directly from within开发者_高级运维 java source code would be

I need to detect when the backing bean method returns so that I can execute a javascript function. Alternatively, calling javascript code directly from within开发者_高级运维 java source code would be helpful. Is there an example of how this is done?

Here, when this command button is clicked, both the action and onclick execute simultaneously. I need to execute the processAfterSave after the save method in the backing bean executes.

<h:commandButton id="saveButton" value="Save" type="submit" action="#{copyScript.save}" onclick="processAfterSave();" style="width: 75px;"/>


Just execute the JS code in the result page. If the bean action returns to the same page, then you need to conditionally print the piece of JS code.

<f:verbatim rendered="#{bean.saved}">
    <script>processAfterSave();</script>
</f:verbatim>

In combination with

private boolean saved;

public void save() {
    // Business logic here.
    // ...
    saved = true;
}

public boolean isSaved() {
    return saved;
}
0

精彩评论

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