I am using ZK framework. I just want to insert lots of rows into my MySQL database. While inserting data it takes few seconds. During that time I just want to show a progress meter, which tells user about the number of rows inserted into the database.
I tried like this:
rowCount = qModel.executeInsert();
for(long j = 1; j <= rowCount; j++)
{
sum = sum + 100 / rowCount;
if (j == rowCount)
{
sum = 100;
}
progressMeter.setValue(sum);
countLabel.setValue((rowCount - 1) + " Rows inserted");
BindUtils.postNotifyChange(null, null, countLabel, "_value");
}
Here rowCount
is the total number of rows inserted into the database. I know after the inserting process the progress meter is getting updated.
But i want my progress meter updated with no busy tag.
If anyone knows the solution, help me out. All suggestions are welcome. Thanks in advance.
It's actually simple,
As long your in the same Execution, no updates will happen to your GUI.
Your only solution is working with multiple call's, achieved by a Timer or enable server push.
It all seems complicated but there is also good news.
Robert Wenzel has written a small talk about simplifying long operations and it include the whole basic for simplifying this.
Please take a look at this :
https://www.zkoss.org/wiki/Small_Talks/2015/January/Simplify_Long_Operation_Handlings