-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I currently have a custom composer/controller class that extends GenericForwardComposer. Inside this class I have some methods that are being used to initialize components with data. This initialization process is a very long operation and takes time to complete. Due to performance issues I am trying to asynchronously load this data using Event Queues. This way it will not block users from accessing other functions while the process runs in the background.
In my custom class there is an init method that starts the processing. This method invokes several other methods that handle the majority of the processing.
My thinking was that I can use Event Queues something as such:
public class MyWidgetController extends GenericForwardComposer
public void init(final Component comp)
{
super.init(comp);
//other logic
final EventQueue evtQ = EventQueues.lookup("eventQ", EventQueues.SESSION, true);
evtQ.subscribe(this); //not sure
evtQ.publish(new Event("onInitPrimaryLoad", componentA, ""));
evtQ.publish(new Event("onInitSecondaryLoad", componentB, ""));
}
// other class logic
@ViewEvent(componentID = "componentA", eventName = "onInitPrimaryLoad")
public void onInitPrimary( final Event event)
{
//
}
@ViewEvent(componentID = "componentB", eventName = "onInitSecondaryLoad")
public void onInitSecondary( final Event event)
{
//
}
}
But wasn't sure as my class is not explicitly defining a onEvent() which is being inherited. Not sure if this is all correct. Don't really need a callback method as the Events (publish) themselves are loading the UI components with data. The application runs with no issue but I'm not sure if I'm implementing this correctly.
Any advice or corrections are appreciated :) Thanks
Asked: 2018-05-16 05:20:59 +0800
Seen: 3 times
Last updated: May 16 '18
What is this @ViewEvent annotation in your example, where do you import it from?
If you want to perform asynchronous operations you should subscribe with an async listener.
It also looks like you only want to initialize components of a single Desktop so a desktop scoped event queue is enough.
cor3000 ( 2018-05-28 09:45:02 +0800 )edit