How to set Cookie name and value with TideSDK? - 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.

Related

How to get the type of a field via Javascript : Google App Maker

How do I get the field type of a field in Google App Maker?
I have tried to find it via:
app.models.MODEL_NAME.fields.date
but there isn't a property type for a field.
So the question is how can I find the type of a field via Javascript?
Many thanks
Interesting question. Here is how I do it; Suppose I want to know what are all the field types of a model. I use this:
var allFields = app.models.MODEL_NAME.fields._values;
for( var f=0; f<allFields.length; f++) {
var field = allFields[f];
var fieldType = field.__gwt_instance.b.B.j;
console.log(fieldType);
}
So, in summary, all you have to do is get the field:
var field = app.models.MODEL_NAME.fields.DESIRED_FIELD
Then you just get the type like this:
var fieldType = field.__gwt_instance.b.B.j;
As I say, this works for me. I hope this works for you too!
There is also a less cryptic attribute that will give you the field type (although it only works in server scripts):
app.metadata.models.MODEL_NAME.fields.DESIRED_FIELD.type;

dW: IBM Datapower gatewayscript

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');

xpages session scope AND document data binding

I have a value that I get from a picklist. I set this value as a sessionScope variable.
I then want to use this value, do a lookup, and set the value of an input field - which is working.
However, I am doing the lookup code in the fields data binding section using SSJS, and as such am not too sure how to save this value (normally my data binding would just be document1.FIELDNAME)
I've tried setting the value as part of my code, but the change is not saved in the backend doc.
I've also tried doing the lookup code in the fields "Default value" property, but this always just returns nothing.
Does anyone know how I can display on the xpage the value from my lookup AND also save this value to the backend document?
I fear I am missing something simple and maybe getting tunnel vision!
The code I am using for my data binding value is below.
Thanks
try{
var key1 = sessionScope.PLProspectiveAssured;
var dbName:NotesDatabase = session.getDatabase(database.getServer(),"CIR2001.nsf");
if (key1==""){
returnVal = "Not found";
}else {
var vwOrgs:NotesView = dbName.getView("OrgDocID");
var doc:NotesDocument = vwOrgs.getDocumentByKey(key1);
returnVal = doc.getItemValueString("OrgCountry");
}
// set our field
var doc:NotesDocument = document1.getDocument();
doc.replaceItemValue("ProspectiveAssured", returnVal);
return returnVal;
}catch(e){
openLogBean.addError(e,this);
}
Use your datasource and set the value using .setValue(field, value). In your case:
// set our field
document1.setValue("ProspectiveAssured", returnVal);
Make sure that you save your datasource somewhere (else).

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.

Retriving the url of a Hyperlink column which is in a sharepoint list, using Client object model

function IfModuleSucceded(sender, args) {
var existingCount = existingItems.get_count();
var existEnumerator = existingItems.getEnumerator();
while (existEnumerator.moveNext()) {
var currentmodule = existEnumerator.get_current();
var URL = currentmodule.get_item("Request_URL");
alert(URL);
}
}
In this Code i am trying to Retrieve the url of a Hyperlink column which is in a SharePoint list, using Client object model, but i have received an object. How could i get the Url out of this received object ????
when this code is executed, it gives the alert as "[Object Object]".
would anyone help me to sort this out ??
The answer will be alert(url.url) as it's an object.
It will also have a property called description
The Hyperlink field has two properties: Description and Url.
You can access the properties like this: ObjectName.PropertyName
So for your URL object in your example, you can reach the properties like this: URL.Url and URL.Description
I found that Url and Description are case sensitive, so make sure you capitalize where necessary.
This worked great for me.

Resources