-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi guys, I have a problem with the update BindUtils.postNotifyChange (x, x, x, x) in a distributed environment. I describe to you the use case: I subscribed a queue on a listener who shall update the values of an object FlightBean () on various distributed clients. The object that is used to handle the event is:
public class FlightWatchEvent extends FlightEvent implements Runnable{
private String operationToDo;
private FlightModifiedAttributesModel flightModifyAttributes = new FlightModifiedAttributesModel();
private Thread t;
public FlightWatchEvent() {
super();
t = new Thread(this);
}
public FlightWatchEvent(String eventSource, Date generateTime, String name,
Integer oid, String flightNumber, Date operativeDate,
Integer oidNature, String nature, Integer oidFlightCarrier,
String iataCode2, String icaoCode,
HashMap<String, StatusObject> listModifyAttributes,
String operationToDo,
FlightModifiedAttributesModel flightModifyAttributes) {
super(eventSource, generateTime, name, oid, flightNumber,
operativeDate, oidNature, nature, oidFlightCarrier, iataCode2,
icaoCode, listModifyAttributes);
this.operationToDo = operationToDo;
this.flightModifyAttributes = flightModifyAttributes;
}
public void avviaThreadAggiornamento() {
t.start();
t = new Thread(this);
}
@Override
public void run() {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
this.clearListModifyAttributes();
this.resetUpdateFlag();
try{
BindUtils.postNotifyChange(null, null, this, "flightModifyAttributes");
}catch (Exception e){
e.printStackTrace();
Log.getLogger().debug("errorE");
}// final HashMap<String, Object> map = new HashMap<String, Object>();// map.put("event", this);// BindUtils.postGlobalCommand("FWQueue", null, "updateQualcosa", map);// t = new Thread(this);
}
}
//get e set methods}
The class FlightModifiedAttributesModel() contains flags that need to be reset after x seconds. To do this, use the thread t, that recalls after x seconds the clean flag method. These flags are binded on the UI and I need to update them after they are reset, so use the statement BindUtils.postNotifyChange (null, null, this, "flightModifyAttributes"); but at this point is throws exception
java.lang.IllegalStateException: Not in an execution
at org.zkoss.zk.ui.event.impl.EventQueueProviderImpl.lookup(EventQueueProviderImpl.java:43)
at org.zkoss.zkmax.ui.event.impl.EventQueueProviderImpl.lookup(EventQueueProviderImpl.java:58)
at org.zkoss.zk.ui.event.EventQueues.lookup(EventQueues.java:127)
at org.zkoss.bind.BindUtils.postNotifyChange(BindUtils.java:54)
at vis.eghos.web.ui.event.flt.FlightWatchEvent.run(FlightWatchEvent.java:77)
at java.lang.Thread.run(Unknown Source)
I wish that every distributed client which receives notification from the event queue, update the flag independently of the instance of the class FlightWatchEvent () on its own UI, but this exception does not allow me.
Hi pasqualeleone! As Chillworld said, have you tried something like that?
public class FlightWatchEvent extends FlightEvent implements Runnable{
private String operationToDo;
private FlightModifiedAttributesModel flightModifyAttributes = new FlightModifiedAttributesModel();
private Desktop _desktop;
//private Thread t;
public FlightWatchEvent() {
super();
//t = new Thread(this);
}
public FlightWatchEvent(String eventSource, Date generateTime, String name,
Integer oid, String flightNumber, Date operativeDate,
Integer oidNature, String nature, Integer oidFlightCarrier,
String iataCode2, String icaoCode,
HashMap<String, StatusObject> listModifyAttributes,
String operationToDo,
FlightModifiedAttributesModel flightModifyAttributes) {
super(eventSource, generateTime, name, oid, flightNumber,
operativeDate, oidNature, nature, oidFlightCarrier, iataCode2,
icaoCode, listModifyAttributes);
this.operationToDo = operationToDo;
this.flightModifyAttributes = flightModifyAttributes;
}
//public void avviaThreadAggiornamento() {
// t.start();
// t = new Thread(this);
//}
@Override
public void run() {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
this.clearListModifyAttributes();
this.resetUpdateFlag();
//Abilito il server push
if(!_desktop.isEnabledServerPush())
_desktop.enableServerPush(true);
//Attivo l'esecuzione del thread concorrente che aggiorna il desktop.
Executions.activate(_desktop);
try{
BindUtils.postNotifyChange(null, null, this, "flightModifyAttributes");
}catch (Exception e){
e.printStackTrace();
Log.getLogger().debug("errorE");
}
finally{
Executions.deactivate(_desktop);
}
}
}
You can pass a reference to the current desktop through:
Executions.getCurrent().getDesktop();
You have to enable serverpush to allow that.
Here is a example with threading how to do so.
If I understand correctly you want to update each client logged in => Example of chat in mvvm.
Greetz chill.
Asked: 2014-09-23 11:31:49 +0800
Seen: 55 times
Last updated: Sep 24 '14
my login/index zul page is loading twice, where as i am only calling it once
ZK Clustering, Session Replication Question [closed]
Problem binding values to a composite component
search button using validation
[Ugent please] connect Web service .net view in grid group ZK
Databinding and auto-complete on combobox
Multiple selection using ListModelMap<Key, Obj>