0

Calling 3rd Javascript function is not working with the window.doModal() way

asked 2016-06-11 15:31:03 +0800

mannwo gravatar image mannwo
1

updated 2016-06-11 15:32:31 +0800

Dear All,

I have 2 zul files; one is the main page (main.zul) and the other one is the widget page (amstockchartwidget.zul). The widget is intended to be called using the doModal() way from inside the main page.

Everything is perfect when I tested the widget page by going to amstockchartwidget.zul directly. I can see the alert popup as expected.

However when I tried to test things by using the doModal() way in the main page (i.e. main.zul), error was encountered. The window seems keep waiting to process after I clicked the "DIsplay it" button.

Please help and billions appreciate for any actions taken.

Thank you very much.




MainPage.java

package com.ta.web;

import org.zkoss.bind.annotation.AfterCompose;
import org.zkoss.bind.annotation.ContextParam;
import org.zkoss.bind.annotation.ContextType;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.select.Selectors;
import org.zkoss.zk.ui.select.annotation.Wire;
import org.zkoss.zul.Button;
import org.zkoss.zul.Window;

public class MainPage {

    @Wire
    Window mainWindow;

    @AfterCompose
    public void afterCompose(@ContextParam(ContextType.VIEW) Component component) {
        Selectors.wireEventListeners(component, this);
        Selectors.wireComponents(component, this, false);

        Button amChartModal = new Button();
        amChartModal.setLabel("Display it");
        amChartModal.setImage("/img/amcharts.png");
        amChartModal.addEventListener("onClick", event -> {
            Window window = (Window) Executions.createComponents("/widgets/amstockchartwidget.zul", null, null);
            window.doModal();
        });

        amChartModal.setParent(mainWindow);
    }


}




main.zul

<?page title="Stock-Signal Analysis" contentType="text/html;charset=UTF-8"?>
<zk>
    <window id="mainWindow" apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('com.ta.web.MainPage')"></window>

</zk>




AmStockChartWidget.java

package com.ta.web.viewmodels.widgets;

import org.zkoss.bind.annotation.AfterCompose;
import org.zkoss.bind.annotation.ContextParam;
import org.zkoss.bind.annotation.ContextType;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.select.Selectors;

public class AmStockChartWidget {

    @AfterCompose
    public void afterCompose(@ContextParam(ContextType.VIEW) Component component) {
        Selectors.wireEventListeners(component, this);
        Selectors.wireComponents(component, this, false);
    }
}




amstockchartwidget.zul

<zk>
    <window id="amStockChartWindow" viewModel="@id('vm') @init('com.ta.web.viewmodels.widgets.AmStockChartWidget')" position="center,center" closable="true" action="show: slideDown;hide: slideUp" width="1200px" sizable="true" border="normal">
        <style src="/amcharts/style.css" />
        <script src="/amcharts/amcharts.js" type="text/javascript" />
        <script src="/amcharts/serial.js" type="text/javascript" />
        <script src="/amcharts/amstock.js" type="text/javascript" />

        <script type="text/javascript">
            zk.afterMount(function() {
                AmCharts.ready(function() { window.alert('AmChart Ready!!'); });
            });
        </script>
    </window>
</zk>
delete flag offensive retag edit
Be the first one to answer this question!
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2016-06-11 15:31:03 +0800

Seen: 17 times

Last updated: Jun 11 '16

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More