Web application using Play framework and sencha
Asked Answered
S

2

6

Ok, I have been thinking of developing a web application using the play framework as my back-end service and sencha for my front end stuff.

Now I have been also looking into sencha touch and phonegap, which can help me make a native android application. So the problem here is how do i render data to two different devices. One is a touch device and other opens in a proper desktop browser.

Should I detect from which device the request has been made and then load the appropriate controller or what ? I am really confused right now ! I am very new to the web and mobile application scene, so please if someone can explain to me how to proceed would be a great help ! Thank you.

Spore answered 18/2, 2012 at 18:2 Comment(0)
N
4

I use Sencha too, not Touch but Ext Js. What I have done is the following:

Play! Server contains my logic and provides me the Restful URLs:

POST   /user/create          AccountController.createUser
GET    /user/userid          AccountController.getUser

With Sencha I have defined a Store that retrieves JSON data from a specific URL, that URL point to my Play! urls.

In my method in Play I retrieve an Model from my database and just return the JSON that Sencha will parse/read like:

Query userQry = JPA.em().createQuery("select * from Account");
List<Article> accounts= userQry .getResultList();
renderJSON(accounts);

Cheers

Nathalie answered 18/2, 2012 at 18:54 Comment(2)
hello,Ok that is well and fine. But what if I have one application for mobile also. Then do i make the same function calls from that application too ? I have made websites using php and codeigniter and in that, I used to just load the view using , $this->load->view('view') after processing. So how to design this kind of stuff for a web application. or instead of pushing data to view, I pull it from the view ?Spore
You should not use the views from Play becuase EXT JS is your client framework. Play is there to serve the data, I would use same url's for Ext Js and Touch, but obviously Sencha Touch will generate different views with same dataset (as used for Ext Js). This should be JSON in most cases. So you should make a general index.html that detects the device and based on the device the proper .js classes are loaded. But the server (Play!) will be the same.Nathalie
G
0

Sencha Touch is not suited for desktop use. You should build different app for desktop using Ext.JS. But if you still want to go with Sencha Touch here is guide how to have different views for different devices. http://docs.sencha.com/touch/2-0/#!/guide/profiles

Grados answered 19/2, 2012 at 19:33 Comment(1)
Yes, I know that. My question is if I am catering to 2 applications, then how should my server side logic should be ?When my application loads, should I return data simply into Json format and let the front end stuff do the representation - in this case, ExtJs for desktop and sencha touch for mobile ? if so, anyone can make that url call and get the data right ? Can you please guide me how to proceed ?Spore

© 2022 - 2024 — McMap. All rights reserved.