How can i refresh all the page without one component using timer of zk

2.8k views Asked by At

I'm using timer to refresh all my page zul. Is it possible to refresh all the page without one component ("progressmeter")?

<progressmeter style="span.z-progressmeter-image" 
               value="@load(item.progres)" width="110px" height="16px">
</progressmeter>
1

There are 1 answers

0
dgofactory On

Note: Assuming that you want to refresh the whole page(Desktop).

You can refresh the whole page without loosing the state of the <progressmeter>, just maintain the Item var on your session and every time the page is reloaded you can recover the last state in the ModelView class, for example:

public class MyVm{
....
    private Item item;

@Init
public void initMyVM(){
    Item item = Sessions.getCurrent().getAttribute("myItem");
    if(item == null)
        //do normal intialization
}
public Item getItem() {
    return item;
}

public void setItem(Item item) { // or wherever it changes
    this.item = item;
    Session session = Sessions.getCurrent();
    session.setAttribute("myItem", item); // or wherever it changes
}
@Command("onTimer")
pulic void comandRefresh(){
    Executions.sendRedirect("");
}

....

}

Now you can refresh your page with Executions.sendRedirect(""); any time you want, you will not lost the state of your <progressmeter/>. The whole refresh must consider the initialization of your vars on @Init.

The other way is to notify changes to all the other vars associated with your View Contenten using @NotifyChange

@Command("onTimer")
@NotifyChange({"redrawValue1","RedrawValue2","others"....})
pulic void comandRefresh(){
    Executions.sendRedirect("");
}

That means that all your content related with the values of "redrawValue1","RedrawValue2","others" will be updated on the view. If you need to force a redraw of some areas you can use templates Template and associated with fields in your VM in order to use @NotifyChange in the same manner.