0

Trying to asychronously load UI component using Event Queues properly?

asked 2018-05-16 05:20:59 +0800

tonys03 gravatar image tonys03
1

updated 2018-05-16 05:30:27 +0800

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

delete flag offensive retag edit

Comments

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
Be the first one to answer this question!
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2018-05-16 05:20:59 +0800

Seen: 3 times

Last updated: May 16 '18

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More