Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
906 views
in Technique[技术] by (71.8m points)

apache poi - POI 4 XPages - document generation works only once

Ok, to be honest: the headline doesn't tell the whole truth. I am using a custom control with several buttons (save, close, edit etc.) and a button that executes a POI action - it's generates a Word file. I experience a problem here: after hitting the POI-button my other buttons (and the POI one as well) won't work anymore, no click is triggered. Now the strange one: after waiting a few seconds (depending on which browser I use, Chrome is fastest) I am able to click the buttons (all of them) again so that I can e.g. leave (close) or edit my Xpage.

I don't know if that helps but here is the event code of my POI button:

<xp:button id="button5" styleClass="btn btn-sm printbutton"
            style="display:none">
            <i class="fa fa-print"></i>
            &#160;
            <xp:text>
                <xp:this.value><![CDATA[#{javascript:"Nach MS Word exportieren"}]]></xp:this.value>
            </xp:text>

            <xp:eventHandler event="onclick" submit="true"
                refreshMode="complete">
                <xp:this.action>

                    <xp:actionGroup>
                        <xp_1:generateDocument documentId="wordprint"
                            loaded="true">
                        </xp_1:generateDocument>
                    </xp:actionGroup>
                </xp:this.action>
            </xp:eventHandler>
        </xp:button>

Any ideas how to avoid this behavior or is it a bug in POI 4 XPages?

BTW: I am not able to execute another action right after getting the Word document, e.g. execute a script or open a page. That would be also an acceptable way to close the xpages after "printing".

Thanks in advance!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Oliver, add the client-side JS call XSP.allowSubmit() to your button in order to allow new submits after pressing the button:

<xp:button id="button5" styleClass="btn btn-sm printbutton" style="display:none">
        <i class="fa fa-print"></i>
        &#160;
        <xp:text>
            <xp:this.value><![CDATA[#{javascript:"Nach MS Word exportieren"}]]></xp:this.value>
        </xp:text>

        <xp:eventHandler event="onclick" submit="true"
            refreshMode="complete">
            <xp:this.action>
                <xp:actionGroup>
                    <xp_1:generateDocument documentId="wordprint"
                        loaded="true">
                    </xp_1:generateDocument>
                </xp:actionGroup>
            </xp:this.action>
            <xp:this.script><![CDATA[XSP.allowSubmit()]]></xp:this.script>
        </xp:eventHandler>
    </xp:button>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...