Hello,
I’m new to SmartClient and learn to use SmartClient. I know create a visual component can use the code like this:
isc.Button.create({
ID:“button”,
title:“this is a button”
})
but,now, I want to creat a invisible object like Timer,how to create it ?
is like
isc.Timer.create({
ID:“timer”
})
Can you give me a sample code of create Timer?
thanks a lot!
That’s not it. Notice in the docs that Timer has no Instance APIs - only Class APIs. That means you won’t create an instance of Timer, just make a call to the class method. Something like:
// Refresh my form in 5 seconds
isc.Timer.setTimeout("myForm.refresh()", 5000);
I call the Timer Method to fetchdata, but it works only once,it didn’t fetchdata per second. what’s wrong with it?
<%@ taglib uri="/WEB-INF/iscTaglib.xml" prefix="isomorphic" %>
<HTML><HEAD>
<isomorphic:loadISC />
</HEAD><BODY>
<SCRIPT>
isc.DataSource.create({
ID:"restDS",
dataFormat:"xml",
recordXPath:"//item",
dataURL:"http://192.168.1.101:8182/Resource/items",
fields:[
{name:"ID", title:"ID"},
{name:"description", title:"description"},
{name:"Link", title:"link"}
]
});
isc.ListGrid.create({
ID: "restList",
left:150,top:50,
width:700, height:500, alternateRecordStyles:true,
dataSource: restDS,
fields:[
{name:"ID"},
{name:"description"},
{name:"Link"}
],
autoFetchData:false
});
isc.Timer.setTimeout("restList.fetchData()", 1000);
</SCRIPT>
</BODY></HTML>
I rewrite code like this it doesn’t work. Please provide a suggestion to overcome this problem. Thanks in Advance.
isc.Timer.setTimerout("freshdata()",1000);
function freshdata(){
for(int i=0;i<restList.getTotalRows();i++)
{
restList.refreshRow(i);
}
};
You look to be real close with the next to last post. The timer only fires once as designed. If you want it to fire again, you have to set it again in your handler. This is somewhat different from timers in other non-js frameworks.
Without full code in your last post it’s hard to tell exactly the problem but not you may need context when naming the timer callback in the string method as you did in the previous one.
the full code list below. but how to overcome this error? it always dosen’t work. I want to fire the Timer again, but how to set it again in my handler? thanks!
<%@ taglib uri="/WEB-INF/iscTaglib.xml" prefix="isomorphic" %>
<HTML><HEAD>
<isomorphic:loadISC />
</HEAD><BODY>
<SCRIPT>
isc.DataSource.create({
ID:"restDS",
dataFormat:"xml",
recordXPath:"//item",
dataURL:"http://192.168.1.101:8182/Resource/items",
fields:[
{name:"ID", title:"ID"},
{name:"description", title:"description"},
{name:"Link", title:"link"}
]
});
isc.ListGrid.create({
ID: "restList",
left:150,top:50,
width:700, height:500, alternateRecordStyles:true,
dataSource: restDS,
fields:[
{name:"ID"},
{name:"description"},
{name:"Link"}
],
autoFetchData:false
});
//isc.Timer.setTimeout("restList.fetchData()", 1000);
isc.Timer.setTimerout("freshdata()",1000);
function freshdata(){
for(int i=0;i<restList.getTotalRows();i++)
{
restList.refreshRow(i);
}
};
</SCRIPT>
</BODY></HTML>