VMware {code} Community
naveen_askquest
Enthusiast
Enthusiast

Inventory Refresh or Global Refresh event on webclient UI

hi laurentsd,

i am trying to invoke global refresh Event with DataRefreshInvocationEvent from Flex UI in action script but any how its not working as expected .or i am not following the proper steps.

can u provide sample code snippet to invoke global refresh with DataRefreshInvocationEvent or is there any other approach for the same.

Thanks in Advance.

Tags (2)
9 Replies
rdey
Enthusiast
Enthusiast

Most likely you are not putting the appropriate tag ... Here is some code snippet in the mediator class that handles that event and request data from the back end

   [EventHandler(name="{com.vmware.core.events.DataRefreshInvocationEvent.EVENT_ID}")]

   public function onGlobalRefreshRequest(event:DataRefreshInvocationEvent):void {

      requestData();

   }

0 Kudos
naveen_askquest
Enthusiast
Enthusiast

Thanks for quick and positive response.

i will try to get it done from samples.Smiley Happy

0 Kudos
laurentsd
VMware Employee
VMware Employee

BTW, I noticed that our current samples are not entirely correct 😞

Method onGlobalRefreshRequest will be called even if the view is not active, so it should check first to see if _contextObject is not null before calling requestData(), or you can put that check inside requestData too.

[EventHandler(name="{com.vmware.core.events.DataRefreshInvocationEvent.EVENT_ID}")]

   public function onGlobalRefreshRequest(event:DataRefreshInvocationEvent):void {

     if (_contextObject != null) {

          requestData();

      }

   }

naveen_askquest
Enthusiast
Enthusiast

Seems it is not available in 5.1 SDK.?

i tried with suggested EventHandle but control not comes there.

..............................................................................................................................................

[EventHandler(name="{com.vmware.core.events.DataRefreshInvocationEvent.EVENT_ID}")]

  

   public function onGlobalRefreshRequest(event:DataRefreshInvocationEvent):void {

      

      Alert.show("onGlobalRefreshRequest");

      

   }

..............................................................................................................................................

----------------------------------------------------------------

i am using 5.1 SDK please suggest is it will be not supported in 5.1 SDK..?

0 Kudos
laurentsd
VMware Employee
VMware Employee

I tested this code with SDK 5.1 by adding it to chassis-ui ChassisSummaryViewMediator.as and it works fine for me:

import com.vmware.core.events.DataRefreshInvocationEvent;

...

   [EventHandler(name="{com.vmware.core.events.DataRefreshInvocationEvent.EVENT_ID}")]

   public function onGlobalRefreshRequest(event:DataRefreshInvocationEvent):void {

      requestData();

   }

0 Kudos
naveen_askquest
Enthusiast
Enthusiast

hi laurent,

As i understand from the discussion above, mention code is the handler of global butoon click (either manually or internally when View is changed ).

please correct me if i am wrong.

But how to call or invoke pragmatically the global refresh button click event which triggers above Handler.?

0 Kudos
abhishekdubey
Enthusiast
Enthusiast

Hi Laurent

It seems naveen is  trying to Invoke global refresh button from flex mediator class.

I also have similar use case and did not found any Metadata or SDK Event  for such invocation.

can you  please help to achieve such invocation or confirm it is not supported by SDK.?

Thanks in Advance.......

0 Kudos
rahul3n
Contributor
Contributor

Hi Guys,

    Following is the solution to invoke global refresh event from action script class (DataRefreshInvocationEvent)

Sample Code :

package com.flex.views.actions

{

  [Event(name="{com.vmware.core.events.DataRefreshInvocationEvent.EVENT_ID}", type="com.vmware.core.events.DataRefreshInvocationEvent")]

  /**

  * Command class to handle the actions defined in plugin.xml.

  * It uses a <code>RequestHandler</code> for each <code>ActionSpec</code>'s uid

  */

  public class VMActionCommand extends EventDispatcher implements IContextObjectHolder

  {

          public function onRunInCloudVM():void

          {

               dispatchEvent(new DataRefreshInvocationEvent(DataRefreshInvocationEvent.EVENT_ID)); // This line will fire your global refresh event.

          }

   }

}

Note : Please don't miss things marked as bold in above sample code.

Thanks and Regards,

Rahul Naiknaware.