小编jun*_*per的帖子

如何使用停止按钮停止运行Java代码

我有一个按钮从调用Bean调用方法.此方法允许从解析html代码中提取数据.当该方法运行时,我有一个显示进度条和命令按钮的对话框Cancel.我需要当用户单击取消按钮时,提取按钮调用的方法停止.

这是我的HTML代码:

<p:commandButton
    value="Start" style="width: 12%;height: 100%"
    update=":confirmPurchase, :confirmPurchaseTest, :mainform" id="extractbutton"
    ajax="true" widgetVar="ButtonExtract"
    actionListener="#{mailMB.searchEmails()}" 
    icon="ui-icon-disk" styleClass="ui-priority-primary"
    onstart="blockUIWidget1.show();" oncomplete=" blockUIWidget1.hide();" />

<p:dialog  widgetVar="blockUIWidget1" header="Hitonclick" modal="true"
    resizable="false" closable="false">
    <table border="0" style="width: 500px">
        <tbody > 
            <tr>  
                <td>
                    <p:graphicImage url="pictures/loading81.gif" width="200" height="200" alt="animated-loading-bar"/>
                </td>
                <td>
                    <h:outputLabel value="Extracting is in progress. Please wait..."/>
                    <div align="center">
                        <p:commandButton value="Cancel" title="Cancel" />
                    </div>
                </td>
            </tr>
            <div align="right">

            </div>
        </tbody>
    </table>
</p:dialog>
Run Code Online (Sandbox Code Playgroud)

这是我的sessionScoped Bean中的searchEmails方法

 public void searchEmails() throws Exception {
        idCustomer = (String) session.getAttribute("idCustomer");
        System.out.println(idCustomer + " …
Run Code Online (Sandbox Code Playgroud)

java java-ee primefaces cancellation

11
推荐指数
1
解决办法
2116
查看次数

如何为扩展特定类的所有类指定单个切入点

我有来自不同包的多个类,它们扩展了一个类 Super。我想创建一个 AOP 切入点来匹配所有扩展 Super 的类中的所有方法。我试过这个:

@Around("within(com.mypackage.that.contains.super..*)")
public void aroundAllEndPoints(ProceedingJoinPoint joinPoint) throws Throwable {
        LOGGER.info("before Proceed ");
        joinPoint.proceed();
        LOGGER.info("after Proceed");
}
Run Code Online (Sandbox Code Playgroud)

但它不起作用。有什么建议?

java spring-aop pointcut

5
推荐指数
1
解决办法
3428
查看次数

同时播放声音和显示警报javascript

这是我的 JavaScript 代码,我尝试播放声音然后显示警报,但我总是先收到警报,当我单击“确定”时,就会播放声音。

 <script>
            function play() {
                var audio = document.getElementById("audio");
                audio.play();
                alert('Extraction is finished');
            }
  </script>
Run Code Online (Sandbox Code Playgroud)

我在 oncomplete 命令按钮中调用此函数。我需要先播放声音,然后显示警报或同时显示两者。我怎样才能让这个工作???

javascript audio alert simultaneous-calls

1
推荐指数
1
解决办法
3373
查看次数