Some help with Sencha Touch Database connectivity please - database-connection

I am a beginner in Sencha Touch.
I am stuck with connecting my web pages(Sencha Touch) to the database(MySQL).
There are submit buttons in various pages which when clicked should send data to the database. But in my case sending data to the DB is possible only from the first page.I should comment the submit button handler of all other pages to send data to DB from any particular page.
Also sending data or retrieving data- only one of them is possible in a single execution.
Problem might be silly, but please I'm really desperate now trying to solve this.
Can someone help me please.........
Thanks in advance...

I'm guessing you have some server code in the mix too, since I don't know how else you would get a JavaScript app to read from and write to a database server directly.
You should be using the Ext.data.* package to bind your app's model stores to some sort of server interface (e.g. AJAX, REST, XML, etc etc) and all the proxies for these have full CRUD implementations.
See: http://dev.sencha.com/deploy/touch/docs/?class=Ext#namespace?class=Ext.data.RestProxy for example
If your server provides an API that provides results in response to an update, I think it would be simple to adapt a proxy to use that response to keep the two data stores (on server and client) strongly in sync.
But would need to know more about what you are trying to do.

Related

Binding a irregular URL encoded POST request with Nancy

I'm supposed to make an old sqlite database editable trough a Sketchup Plugin in its WebDialog. Sketchups Ruby is not able to install the sqlite3 gem and since I already need to display the table in a WebDialog, I opted for a micro service with the help of Nancy. The existing Plugin already uses the dhtmlxSuite and its Grid Component is exactly what I need. They even offer a Connector that can send requests based on the actions of the user in the grid.
They also offer a connector for the server side, but that too does not work with sqlite. I already managed to connect to my database, used Dapper to bin the result of an SQL query to an object and return that data with a manually crafted JSON object. Very hacky, but it populates the data successful.
Now the client-Connector sends data manipulated by the user (delete and insert is forbidden) back with an url encoded POST request that looks quite weird:
4_gr_id=4&4_c0=0701.041&4_c1=Diagonale%20f%3Fr%202.07%20X%201.50%20m&4_c2=AR&4_c3=8.3&4_c4=380&4_c5=38.53&4_c6=0&4_c7=0&4_!nativeeditor_status=updated&ids=4
I'm not sure exactly why the hell they would use the row index inside the key for the key-value pairs, but this just makes my life that much harder. The only thing that comes to my mind is extracting the data I'm interested in with a regex, but that sounds even worse than what I did before.
Any suggestions for me how I could map that POST request to something usable?

Best way to check for data updates on webserver

I have an application which uses the data from web server. When you first launch the app, it downloads the data and then work with it. But what if the data on web site was changed. How can I know from the application that the data was changed, and if so, what data should I download?
My first idea was each time when you run the application to check the number of entries in the local database on your phone and the number of entries on web server, and if they are not equal, delete all data in local database and then download all data again. But I think that it will take more time than if the application just loads 5-10 needed records instead of all data.
The second idea was when the information on the site changes, website somehow has to inform the application to load some records. But I don’t know if it is possible to do(
Another idea was to compare the id of the last entry in the application database with last id on website. And if they are not equal download the information from the next id.
Are there any suggestions how can I accomplish this?
I am not sure that you have any database or web services but my suggestion is parsing data from the web with JSON or XML.
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSXMLParser_Class/
this class reference is will be clear for you.
Also in my opinion, if you are new in swift and want to choose easy way for this operation search for iOS package managers.
If you want to use a package manager for your project, e.g Pod
https://cocoapods.org/pods/Alamofire
would be a good startig point.
Alamofire is an HTTP networking library written in Swift.
Hope to helped you

How to get User Data from the App?

Is there a way to get data from the user while they use my app on their device (iPhone/iPad). For example, if the app fills a dictionary during the runtime about which avatar is used most of the time and which avatar not, is there a way to transfer that dictionary to me? Do I need a server?
This is my first time thinking about data transfers over the internet. I don't have any idea or any experience on how to do that. Somehow I feel it is impossible for some security reasons. I found the NSURLConnection class, but this seems to be only one way to move data from a server to the app.
Thanks.
Not sure if I fully understand the question, but I am assuming you would like to get information about how the user is using your application?
This is definitely possible; and yes, you will need a server to send, retrieve or store the information that you require, or else there is no way to get the data from the application to you! You will need to learn how server side and client side web scripting works (if you do not know already) as this is how the application will communicate with your server.
Depending on the kind of information you are trying to retrieve, there may be security issues and Apple may not accept your application. However, if your data is specific to your application features, there should be no issue of this kind.
HTH

rails 3 - generate a preview for a new post on the fly

For a rails 3 app I am building, a user gets to share a post which has numerous different parameters. Some parameters are optional, others are required. While the user is filling out the parameters, I want to generate a preview for how the post will look on the fly. Some parameters are URLs which need to be sent back to the server to process, so basically, the preview cannot be 100% generated client side.
I was wondering what it the best way to go about this. Since it could be a lot of data, I don't want to send all the data back to the server every time something changes to regenerate the preview. I would rather only like to send the data that has changed. But in this case, where is the rest of the data stored? In a session, perhaps? Also, I would prefer to not rebuild the model object with all the data every time. Is there a way to persist the model object that represents the post as it is being created?
Thanks.
How big is that "a lot of data"? If you send it all, does it have a noticeable impact on performance, or are you just imagining that it would?
As you provided not too much information, here's basic info on what I would do:
process client-side. As much as possible.
data that can't be processed on the client - send to the server (only that part, not the rest of it). Receive result of processing and incorporate into what you already built.
no sessions, partially built models and any other state on the server. Stateless protocols are simple. Simplicity is prerequisite for reliability.

How to wipe out all forms/grid data in Silverlight?

I have a Silverlight 3 business app set up with RIA Services. I use a domain datasource to connect to the backend and fetch the data and populate a series of dataforms and grids bound to this datasource.
The issue is that we require tight security and currently when a user logs out and another logs back in on the same machine the forms/grids briefly display information from the last login before the DDS gets the new set.
What's the best approach to wiping out all the data when the user logs out in Silverlight? For legal reasons we can't chance any data hanging around, so is there a way to tell Silverlight to go back to its initial state?
Thanks,
Found my solution: turns out that by simply removing the NavigationCacheMode="Enabled" from each of the pages, logging out now correctly clears out all the form/grid data cleanly and simply.
Before finding this solution though I did run across this method to clear all the form/grid data on a page but for my case, the solution above works much better.

Resources