-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi all,
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)
Assuming startDateProxy
is a ZK Datebox component, First, there is no startDate attribute for Datebox. Second, zk.Widget.$('$startDateProxy').setAttribute("startDate",start)
fails because there is no setAttribute JS API for ZK Widgets. You have to call attribute's corresponding setter method.
For null pointer exception it is expected. If you are updating Widget values by custom code it is your job to also sync it with server side. Check this sample code
<zk xmlns:w="client">
<label id="tb" width="250px" value="hello" >
<custom-attributes org.zkoss.zk.ui.updateByClient="true"/>
</label>
<button label="chage at client-side">
<attribute w:name="onClick"><![CDATA[
var tb = zk.Widget.$(jq('$tb')),
val = 'world';
tb.setValue(val);
tb.smartUpdate('value', val);
]]></attribute>
</button>
<button label="get at server-side" onClick="alert(tb.value)"/>
</zk>
Hope this helps.
Asked: 2013-12-06 15:55:57 +0800
Seen: 53 times
Last updated: Dec 09 '13
Facing issue in masking on phone [closed]
coerceFromString_ override no longer works from 6.5.1 [closed]
Execute Javascript on component visible
Is there a way to resolve view model properties as input to client side javascripts?
scrollbar listner for 2 grid [closed]
Theme javascript wpd file not found