0

windows can not displaying by pressing button , having an issue on event

asked 2019-05-28 18:29:24 +0800

musedanny gravatar image musedanny
1

updated 2019-06-10 16:22:39 +0800

cor3000 gravatar image cor3000
4546 2 7
ZK Team

Here is my code for register Ticket .zul file

<?init class="org.zkoss.zk.ui.util.Composition" arg0="/template/template.zul"?>

<zk>
    <div self="@define(content)" apply="org.danny.ticketSelling.controller.TicketController">
            <window>
                <caption src="/imgs/ticketReg.png" label="Register new Ticket"/>
                <vbox>
                    <grid>
                        <columns>
                            <column label=""/>
                            <column label=""/>
                        </columns>
                        <rows>
                            <row>   
                                <cell>Title:</cell>
                                <cell>
                                    <textbox id="txtTitle" constraint="no empty"></textbox>
                                </cell>
                            </row>
                            <row>   
                                <cell>Description:</cell>
                                <cell>
                                    <textbox id="txtDesc" constraint="no empty"></textbox>
                                </cell>
                            </row>
                            <row>   
                                <cell>Date Added:</cell>
                                <cell>
                                    <datebox id="dateAdd"></datebox>
                                </cell>
                            </row>
                            <row>   
                                <cell>Location:</cell>
                                <cell>
                                    <textbox id="txtLocation" constraint="no empty"></textbox>
                                </cell>
                            </row>
                            <row>   
                                <cell>Ticket Quantity:</cell>
                                <cell>
                                    <textbox id="txtTicketQte" constraint="/[0-9]+/ : Invalid value Enter a number"></textbox>
                                </cell>
                            </row>
                            <row>   
                                <cell>Price:</cell>
                                <cell>
                                    <textbox id="txtPrice" constraint="/[0-9]+/ : Invalid value Enter a number"></textbox>
                                </cell>
                            </row>
                        </rows>
                    </grid> 
                    <hbox>
                        <button id="btnCancel" label="Cancel"></button>
                        <button id="btnCreate" label="Create"></button>
                    </hbox>     
                </vbox>
            </window>

    </div>
</zk>

BELOW IS code for ControllerTicket

package org.danny.ticketSelling.controller;

import java.util.Date;

import org.danny.ticketSelling.model.Ticket;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.select.SelectorComposer;
import org.zkoss.zk.ui.select.annotation.Listen;
import org.zkoss.zk.ui.select.annotation.Wire;
import org.zkoss.zul.Button;
import org.zkoss.zul.Datebox;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Textbox;
import org.zkoss.zul.Window;

public class TicketController extends SelectorComposer<Component>{

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    @Wire
    private Textbox txtTitle;

    @Wire
    private Textbox txtDesc;

    @Wire
    private Datebox dateAdd;

    @Wire
    private Textbox txtLocation;

    @Wire
    private Textbox txtTicketQte;

    @Wire
    private Textbox txtPrice;

    @Wire
    private Button btnCancel;

    @Wire
    private Button btnCreate;

    @Listen("onClick = #btnCreate")
    public void createData(Event event){
        Messagebox.show("hello");
        Ticket ticket= new Ticket();
        ticket.setTitle(txtTitle.getText());
        ticket.setDescription(txtDesc.getText());
        ticket.setDate(new Date(dateAdd.getValue().getYear(),dateAdd.getValue().getMonth(),dateAdd.getValue().getDay()));
        ticket.setLocation(txtLocation.getText());
        ticket.setAmount(Integer.parseInt(txtTicketQte.getText()));
        ticket.setPrice(Double.parseDouble(txtPrice.getText()));

        Messagebox.show(ticket.toString());
        clear();
    }

    public void clear(){

        txtTitle.setText("");
        txtDesc.setText("");
        txtLocation.setText("");
        txtTicketQte.setText("");
        txtPrice.setText("");

    }



}

SO WHEN CLICK ON CREATE BUTTON THE LISTENER EVENT IS NOT POP UP THE WINDOWS CAN ANYBODY HELP

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2019-05-31 16:40:35 +0800

musedanny gravatar image musedanny
1

i have created a java class controller class , not in zul , however i found a solution , it was just because i have used applied the package at div level instead of window level , but now it is solved . thanks with this code it worked

<window apply="org.danny.ticketSelling.controller.TicketController">

link publish delete flag offensive edit
0

answered 2019-06-06 01:20:11 +0800

RyanSmithhhh gravatar image RyanSmithhhh
1

I like this idea!

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
1 follower

RSS

Stats

Asked: 2019-05-28 18:29:24 +0800

Seen: 13 times

Last updated: Jun 10

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