Hi,
I used vsphere 6.7 sdk , like this:
navigateToSummaryView(objectId): void {
const selectedTarget = this.selectedTargets;
this.storagepluginService.htmlClientSdk.app.navigateTo({
targetViewId: 'com.xxxxxxx.summary',
objectId: objectId,
customData: { objectId, selectedTarget }
});
}
and i want to get "objectId" from "targetViewId",
so i use 2 htmlClientSdk :
1. htmlClientSdk.app.getNavigationData()
2. htmlClientSdk.htmlClientSdk.app.getContextObjects()[0]
they can worked.
But 1. (getNavigationData) have probleme , they can't ued by browser's Refresh/Next Page/Back Page
they will make getNavigationData() to be undefined
so I used 2. getContextObjects()[0].
But In vSphere 7.0, [2. getContextObjects()[0]] can't work
So I need to know, have any way to fix this?
Hi Yang,
Are you trying to get the objectId of the previously selected object, namely the object from which the navigation was triggered or you are trying to get the selectedTargets ?
I just verified that after the navigateTo Api has been called and the navigation executed, the getContextObjects API returns the correct object.
Also there is a format error in the json you provided to the navigateTo API. The customData value is not a valid json { objectId, selectedTarget }.
On a side note: The Refresh/Next Page/Back Page clears the navigation data as this is not considered correct navigation (namely it is not done with the usage of navigateTo API).
Martin
Hi Martin,
Thank you for your reply.
>Are you trying to get the objectId of the previously selected object, namely the object from which the navigation was triggered or you are trying to get the selectedTargets ?
if i call the getNavigationData API , i can get the selectedTargets . But the getContextObjects API returns undefined, like this :
ERROR TypeError: ""this.xxxxxxxx.htmlClientSdk.app.getContextObjects(...)[0] is undefined""
>The customData value is not a valid json { objectId, selectedTarget }
Maybe my customData is not a valid json, so I try to make a valid json for customData , and try again , but was same wrong.
Can you give me some example of customData ?
my example : (by typeScript)
const obj = {};
this.selectedTargets.forEach(item => (obj[item.id] = item));
const selectedTargetJSON = JSON.stringify(obj);
this.xxxxxx.htmlClientSdk.app.navigateTo({
targetViewId: 'com.xxxxxxx.summary',
objectId: objectId,
customData: selectedTargetJSON
});
By the way
I checked the network in vSphere 6.7 : (Have objectId=xxx)
1.request URL:https://xxxxx/ui/navigation/data/com.xxxxxxx.summary?objectId=urn:hsp:yyy:zzz:A_B_123
Hi Yang,
There has been a small change in the architecture in the vSphere Client navigations in 7.0.
I tested on a 7.0 environment the following scenario and it worked:
1) opened a plugin view
2) from the developers console executed snipped similar to this
window.frameElement.htmlClientSdk.app.navigateTo({
targetViewId: 'com.xxxxxxx.summary',
objectId: objectId,
customData: ['a', 'b', 'c']
});
3) when the new view loaded I validated that the getNavigationData returns ['a', 'b', 'c'] and the getContextObjects()[0] returned the object to which I navigated.
Can you share the steps on how can I reproduce the scenario when the GET navigation request does not have an objectId ?
Namely this one:
request URL: https://ssssssss/ui/navigation/leaf/com.xxxxxxx.summary
Also can you share information about the vCenter Server, what build number is it ?
Thanks,
Martin
Hi Martin
Thanks!