user3077760
user3077760

Reputation: 19

How to access ZK components from JavaScript

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)

Upvotes: 0

Views: 2131

Answers (2)

user3077760
user3077760

Reputation: 19

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
    }

Upvotes: 1

Sitansu
Sitansu

Reputation: 3327

Try it instead

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

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

Upvotes: 0

Related Questions