0

Call zul page in java class

asked 2020-02-27 22:21:25 +0800

Romeu gravatar image Romeu
1

Hello, at the moment, I am setting up a screen in the java owner, I wanted to call a specific zul file when starting the .java file, does anyone know how to do this? zk 9.0.0

public MyPage2(Page page) {
    request = (HttpServletRequest) page.getDesktop().getExecution().getNativeRequest();

    session = (HttpSession) Executions.getCurrent().getDesktop().getSession().getNativeSession();

    contexto = page.getDesktop().getExecution().getContextPath();
    usuarioService = new UsuarioService();

    logsis = request.getParameter("logsis") != null ? Boolean.parseBoolean(request.getParameter("logsis")) : true;

    if (request.getParameter("codAudit") != null) {
        usuarioService.setIdLogon(request.getParameter("codAudit"));
        usuarioService.setIdUsuario(request.getParameter("usuario"));
        if (usuarioService.isLogado()) {
            if (this.validaLogin(Integer.parseInt(usuarioService.getIdUsuario())))
                return;
        }
    }

    page.removeComponents();
    initComponentes();

    page.setTitle(Config.INSTITUICAO);
    page.setAttribute("cacheable", false);

    org.zkoss.zul.Window body = new org.zkoss.zul.Window();
    org.zkoss.zul.Window w = new org.zkoss.zul.Window();

    body.setSclass("window_body");
    body.setClosable(false);
    body.setWidth("100%");
    body.setHeight("100%");
    body.setStyle("background: #0066A5 url('images/login/bg_login.png') no-repeat bottom left;");

    w.setTitle(Config.INSTITUICAO);
    w.setBorder("normal");
    w.setWidth("320px");
    w.setShadow(false);
    w.doOverlapped();
    w.setSclass("window_login");

    btn.setLabel("Entrar");
    btn.setId("Entrar");
    btn.addEventListener(Events.ON_CLICK, new EventListener() {
        @Override
        public void onEvent(Event event) throws Exception {
            if (Events.ON_CLICK.equals(event.getName())) {
                String id = event.getTarget().getId().toLowerCase();
                if ("entrar".equals(id))
                    validaLogin();
            }
        }

    });

    tx[1].setType("password");
    tx[1].addEventListener(Events.ON_OK, new EventListener() {
        @Override
        public void onEvent(Event event) throws Exception {
            validaLogin();
        }
    });

    sistema = request.getParameter("sistema") != null ? Integer.parseInt(request.getParameter("sistema")) : null;

    Vbox hb = new Vbox();
    hb.appendChild(new Hr());
    hb.appendChild(lb[0]);
    hb.appendChild(tx[0]);
    hb.appendChild(lb[1]);
    hb.appendChild(tx[1]);
    w.appendChild(hb);

    Separator sp = new Separator();
    sp.setHeight("10px");
    w.appendChild(sp);

    Div dv = new Div();
    dv.setStyle("text-align:right");
    dv.appendChild(btn);

    w.appendChild(dv);
    w.setParent(body);
    w.setPosition("center");
    body.setPage(page);

    tx[0].focus();
}
delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-03-02 11:14:43 +0800

hawk gravatar image hawk
2620 1 5
http://hawkphoenix.blogsp... ZK Team

updated 2020-03-02 11:16:07 +0800

It looks like you want to create components bases on a zul, you can do this like Executions.createComponents("/foo/my.zul", parent, arg);

Please read https://www.zkoss.org/wiki/ZKDeveloper%27sReference/UIComposing/ZUML/LoadZUMLinJava for details.

link publish delete flag offensive edit
Your answer
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

RSS

Stats

Asked: 2020-02-27 22:21:25 +0800

Seen: 8 times

Last updated: Mar 02

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