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.
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();
}
You can also see how it is done in the 5.5 SDK samples/chassis-app/chassisRackVSphere-ui/swf/src/main/flex/com/vmware/samples/chassisrackvsphereui/ChassisActionCommand.as and samples/chassis-app/chassisRackVSphere-ui/swf/src/main/flex/com/vmware/samples/chassisrackvsphereui/views/ChassisSummaryViewMediator.as
Thanks for quick and positive response.
i will try to get it done from samples.
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();
}
}
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..?
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();
}
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.?
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.......
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.