How to access ZK components from JavaScript

2k Views Asked by At

I want to set value of a zk datebox from javascript. Actually I can set the value but when I want to access its value, it is throwing a null pointer exception. More generally, some abilities of the zk components can be manupulated but others not. For example I can fire a button onclick event but I can not set an attribute of that button by javascript.

For example these two work :

zk.Widget.$('$startDateProxy').setValue(start);
zk.Widget.$('$addEventBtn').fire('onClick');

But these two not:

zk.Widget.$('$startDateProxy').setAttribute("startDate",start) -> cutting the operation

alert(startDateProxy.getValue().toString()) -> null pointer

Thanks

PS: I am trying to use FULLCALENDAR (arshaw.com/fullcalendar)

2

There are 2 best solutions below

0
On

Try it instead

alert(this.$f('addEventBtn').getLabel());

The Class Calendar does not have a setAttribute method (see the docs).

0
On

Thank you for your answer. startDateProxy component is Datebox, not Calendar. Sorry for missing information. I solved the problem by using AuService. I defined a hidden button. Fired its onClick with the parameters. Sample usage:

Client Side:

zk.Widget.$('$eventBtn').fire('onClick',{start : start ,end : end});

Server Side:

public void service(AuRequest request, boolean everError) {


    if (Events.ON_CLICK.equals(request.getCommand())) {
        Map data = request.getData(); // can be read start,end parameters from here
        //dosomething here
    }