Display array in sencha touch 2 - sencha-touch-2

I prepare a web service returns an array:
i need to display this list in sencha touch 2.Can someone help me to display the list?

I am a developer with SIMpalm (http://www.simpalm.com), you can use Ext.Ajax.request method (http://docs.sencha.com/touch/2.3.0/#!/guide/ajax), or you can directly use web service URL (Store -> proxy -> URL) with your store, Store should be JsonP, and don't forget to set rootProperty (like result/address) in your store -> proxy -> reader ->rootProperty.

Related

Pushwoosh, how do I send 'open app' push notifications with custom data via the API?

I having trouble send a Pushwoosh notification using the API that matches what I can do in the web interface.
In the web interface, I navigate to the Action tab and select 'Open App' and enter custom json in the data field. This sends a notification that when clicked, triggers an even in my app and passes in custom data.
I have tried to recreate this using the createmessage API by passing in custom data. Using the Ruby client API I run
Pushwoosh.notify_devices("test", device_ids, { data: { foo: 1 } }). This triggers a push but when the user taps on the push notification it opens the app but does not pass any data or call any of the callbacks in my app when the app opens.
Am I using the wrong API or missing parameters?
Do you use "data" parameter in createMessage?
It will be passed as "u" parameter in the push payload.
"data": {"key":"value"}, // JSON string or JSON object, will be passed as "u" parameter in the payload (converted to JSON string)
If you want to modify the payload at any level you can use "ios_root_params"/"android_root_params" which is a JSON object and will be merged at the root level of the push payload.

How to do a listener on every page load

I'm trying to limit the session access to a Struts application so the users will only be able to use 1 tab at the time. To do this, I have to create an ID everytime a new page is loaded and assign that ID to the user's session. By doing so, if the user uses a page with a different ID than the one registered in his session, the action will be rejected.
How can I do a listener on every page load? Which interface should I use?
Or do you have any other idea of how I could manage multiple tabs?
I'm Using Struts 1 and Java 4.
You could use Spring MVC Interceptors and override the preHandle method.
Returning false inside should cancel your request for not allowed additional tabs.
You can use an interceptor to do this. You will need to define it on your interceptor stack in your struts.xml and code the interceptor to check the JEE role information provided by your web application server. The interceptor can be coded to give a redirect result on the other tab if there was recently an action called however you will probably need to coordinate it via JS generated ids and AJAX.
https://struts.apache.org/docs/interceptors.html

Communication Between WebView and WebPage - Titanium Studio

I am working in a Mobile project (using Titanium Studio), in which i have the below situation
1) My Mobile app contacts Rails backend to check some data, say check validity of a
user id.
2) I found a way to load web pages in Mobile app, i.e., WebView
3) I could able to load the desired url, ex http://www.mydomain.com/checkuser?uid=20121
which would return data like status:success
But i need to read this data to show whether the response from server is a success or failure, how do i achieve this?
NOTE : The above mentioned scenario is an usecase, but actually what happens is i load a third party url in WebView and when user enters the data and submits, the result will be posted back to my website url.
EDIT : So the process is like below
1) WebView loaded with third party url like http://www.anyapiprovider.com/processdata
2) User will enter set of data in this web page and submits the page
3) The submitted data will be processed by the apiprovider and it returns data to my web page say http://www.mydomain.com/recievedata
This is the reason why i am not directly using GET using HTTPClient
FYI : I tried to fire Ti.APP events right from the actual web page as suggested by few articles, but most of them says this will work only if the file loaded is in local and not a remote file. Reference Link
Please suggest me if my approach has to be improved.
Thanks
If you don't want to follow Josiah's advice, then take a look at the Titanium docs on how to add a webview.addEventListener('load',... event listener and use webview.evalJS() to inject your own code into the third party HTML.
Maybe you can inject code to trap the submit event and fire a Ti event to trigger the downloading of data from your website.
Communication Between WebViews and Titanium - Remote Web Content Section
I found a solution for my problem
1) Load the http://www.mydomain.com/checkuser?uid=20121 in a webview
2) Let user enter and submit data to third party url
3) Recieve the response from third party url and print only <div id="result">status:success</div> in http://www.mydomain.com/recievedata page.
4) Add event listener for the web view as follows
webView.addEventListener('load', function(data)
{
//Add condition to check if the loaded web page has any div with id = result (to check if this is /recievedata page)
alert(webView.evalJS("document.getElementById('result').innerHTML"));
});
The above alert would print the result status:success, read it in webview load event
and take actions in web accordingly.
It works fine for me.
Instead of loading it in a WebView why not just GET it using a HTTP Client? This is much cleaner, and more standards based:
var xhr_get = Ti.Network.createHTTPClient({
onload : function(e) {
// Here is your "status:success" string
var returnValue = this.responseText;
},
onerror : function(e) {
Ti.API.info(this.responseText);
Ti.API.info('CheckUserProgressOnActivity webservice failed with message : ' + e.error);
}
});
xhr_get.open('GET', 'http://www.mydomain.com/checkuser?uid=20121');
xhr_get.send();

facebook dialog to add facebook tab app - returns - tabs_added[pageId]=1

It seems the new dialog to tab app to a page -> https://developers.facebook.com/docs/reference/dialogs/add_to_page/ - calls the app url with a GET (redirect_uri?tabs_added[nnnnn]=1) (where nnnn - pageId of page the app is being added to)
I can't find the documentation around whether when the app is removed from the page, the same url will be called with a GET (redirect_uri?tabs_added[nnnnn]=0) ?
I am keen to process the uninstall of the app from the page, if possible. (I have tried to test this, but don't get a trigger to my redirect_uri upon an installed, unlike the one that is called upon an install..)
My question is - whether there is a way to get a delete page callback into the app (when a page uninstalls/deletes the app from the page) ? From the syntax on install GET call (?tabs_added[nnn]=1, it seems that this might have been designed with an intention to call a GET with ?tabs_removed[nnnn]=1 or tabs_added[nnnn]=0 when the app is deleted from the page ?
Empirically, the answer to your question is No. Nothing on my server gets called by Facebook when the Page Tab is removed.
Go to the advanced tab on the facebook app settings, and put a URL of your choice into the 'Deauthorize Callback URL' field. You will receive a callback on that and you need to parse the signed request.
Example in php:
$helper = $fb->getPageTabHelper();
$signedRequest = $helper->getSignedRequest();
if ($signedRequest) {
$payload = $signedRequest->getPayload();
//trace(print_r($payload, true));
$pageId = $payload['profile_id'];
//You can now update your records using $pageId
}

Chrome extensions: How can I pass form variables to a url in a newly created tab?

I'm working on my first chrome extension, and using an image-based context menu item to capture the URL of a given image, and want to then display that image at a specific URL in a new tab. So, I need to pass the URL of the image clicked on (using srcUrl) to a specific script that can then render it on that page. Is it possible to perform an HMLHttpRequest from within a chrome.tabs.create() call, or must this be done some other way?
Thanks for any help.
You would need to create an HTML page containing that script and put it into your extension folder. Then you can just pass image url to it as GET parameter:
chrome.tabs.create({url: "local.html?img_url=...");
If url parameter is not enough, you would be also able to communicate with that page using chrome.tabs.sendRequest():
chrome.tabs.create({url: "local.html", function(tab){
chrome.tabs.sendRequest(tab.id, {img_url: "local.html?img_url=...");
));
With the request listener in that page:
chrome.extension.onRequest.addListener(function(request) {
console.log(request.img_url);
});