dW: IBM Datapower gatewayscript - ibm-datapower

I'm new to Datapower Gateway script. In my script I try to get value of context variable like var://context/WSM/identity/credentials.
I try something like:
session.input.getVariable('var://context/WSM/identity/credentials');
session.input.getVar('var://context/WSM/identity/credentials');
session.name('WSM');
But I alway have 'undefined' response.
My question how can I access from gatewayscript to a context variable ? And globaly, is these the right way to get user crenter code hereedentials or there is another way ?
Thank you for your help.

You need to use the session object:
var ctx = session.name('WSM') || session.createContext('WSM');
var value = ctx.getVar('identity');
Else you can use the service-metadata object:
var sm = require('service-metadata');
var value = sm.getVar('var://context/WSM/identity/credentials');

Related

Get quickshare url with javascript

I want to share a document with JavaScript and get its share_id programatically.
There is a REST API that can do that but I didn't know how to call it from script.
Any clues?
The following hack will do the trick. (edit: Must be executed from the classpath in the repository)
var ctx = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext();
var qsService = ctx.getBean("QuickShareService");
var sId = document.properties['qshare:sharedId'];
if (!sId) {
sId = qsService.shareContent(document.nodeRef).id;
}
PS: It looks even more ugly on 5.0.a due to rhino-1.7.

How to set Cookie name and value with TideSDK?

How to set Cookie name and value with TideSDK ?
I try from this api:
http://tidesdk.multipart.net/docs/user-dev/generated/#!/api/Ti.Network.HTTPClient
when I check value from set cookie.Is null. And this code:
var httpcli;
httpcli = Ti.Network.createHTTPClient();
httpcli.setCookie("test","testAA");
alert(httpcli.getCookie("test"));
This image after run:
http://i.stack.imgur.com/anRKX.png
How about trying this:
var httpcli;
httpcli = Ti.Network.createHTTPCookie();
httpcli.setName(cname);
httpcli.setValue(cvalue);
alert("COOKIE value: "+httpcli.getValue());
I used local storage instead of cookies, and it worked fine.
window.localStorage.test='this is test';
And get the value:
var item=window.localStorage.test;
alert(item);
Hope that helped you.

Multiple instances of views in PureMVC: Am I doing this right?

What I'm doing NOW:
Often multiple instances of the view component would be used in multiple places in an application. Each time I do this, I register the same mediator with a different name.
When a notification is dispatched, I attach the name of the mediator to the body of the notification, like so:
var obj:Object = new Object();
obj.mediatorName = this.getMediatorName();
obj.someParameter = someParameter;
sendNotification ("someNotification", obj);
Then in the Command class, I parse the notification body and store the mediatorName in the proxy.
var mediatorName:String = notification.getBody().mediatorName;
var params:String = notification.getBody().someParameter;
getProxy().someMethod(params, mediatorName);
On the return notification, the mediatorName is returned with it.
var obj:Object = new Object();
obj.mediatorName = mediatorName;
obj.someReturnedValue= someReturnedValue;
sendNotification ("someReturnedNotification", obj);
In the multiple mediators that might be watching for "someReturnedNotification," in the handleNotification(), it does an if statement, to see
if obj.mediatorName == this.getMediatorName
returns true. If so, process the info, if not, don't.
My Question is:
Is this the right way of using Multiton PureMVC? My gut feeling is not. I am sure there's a better way of architecting the application so that I don't have to test for the mediator's name to see if the component should be updated with the returned info.
Would someone please help and give me some direction as to what is a better way?
Thanks.
I checked with Cliff (the puremvc.org guy) and he said it's fine.

How to transform a string in function and concatenate with an object?

I have the following code in actionscript 3:
var async:AsyncToken;
async = bridge.retornamenu();
The bridge is a remote object, instantiated.
The retornamenu() is the function that I want the remote object open in amfphp.
However the retornamenu() is a dynamic function, which turns another function, but I can not run it at runtime,
example
var stringfunction:String = "retornamenu()" // this name is dynamic.
var async:AsyncToken;
async = bridge.stringfunction;
But this way does not work, not perform the function retornamenu();
someone could help me?
I am a few days behind the solution, my project stopped,
Thanks in advance
Use getOperation() and send() it.
var stringfunction:String = "retornamenu" // this name is dynamic.
var async:AsyncToken;
async = bridge.getOperation(stringfunction).send();
If there are arguments to the function, you can pass it through send(args)

how can i retrieve the variable i am getting through urlRequest in Flex

Hi I am sending userID through urlRequest like below code,
var urlStr:String = "http://[server]/main.jsp";
var urlReqest:URLRequest= new URLRequest(urlStr);
var variables:URLVariables = new URLVariables();
variables.userID = 12;
urlReqest.method = URLRequestMethod.POST;
urlReqest.data = variables;
navigateToURL(urlReqest,"_blank");
Now when new window is opening in that new swf is opening(new project) that is also in flex only. There I need to retrieve userID when initializing only. How can I retrieve?
If any one can help it would be helpful.
Thanks in advance.
In Flex 4 you can use
if (FlexGlobals.topLevelApplication.parameters.hasOwnProperty("userID"))
{
userID = FlexGlobals.topLevelApplication.parameters.userID;
}
In Flex 3 you can use
if (mx.core.Application.application.parameters.hasOwnProperty("userID"))
{
userID = mx.core.Application.application.parameters.userID;
}
You would have to rewrite the JSP page to write the POST values to the flashVars parameter. The POST variables are not accessible to the Flex app.
Once they are passed in through flashVars on the page, you would use Jason W's method for reading them:
if (mx.core.Application.application.parameters.hasOwnProperty("userID"))
{
userID = mx.core.Application.application.parameters.userID;
}

Resources