I am looking for a clean vanilla example of the play framework with ajax. I would like to build a a dependent dropdown and a chained select. All the tutorials on the web I have found uses php.
The only sample that has ajax makes use of coffee script.
Is there one out there somewhere?
You don't really need a Scala tutorial for that, you can follow the PHP ones.
The difference is that your data (responses) will be returned by Scala routes instead of PHP scripts.
To learn more about AJAX calls in Play just examine a zentasks sample delivered to you together with Play's code. There are samples for both Scala and Java versions and all you have to test them is to go to the folder of selected sample via commandline and run/start it as a common Play's application.
Preview
Related
I'm trying to integrate backend code into a Wix site. Im not too picky about how I want to do this, or what language to write in (ideally, I have a locally-hosted Java code that I'd love to simply call). I wouldn't mind re-writing it in JavaScript though, or another language. But before I decide that I'm confused about my options. I can code but I'm new to the concepts like modules, APIs, & servers.
According to my research, back-end code with Wix is supposed to be easy (or at least do-able and not THAT complicated)....
From this webpage https://support.wix.com/en/article/corvid-calling-server-side-code-from-the-front-end-with-web-modules,
"Web modules are exclusive to Corvid and enable you to write functions that run server-side in the backend, and easily call them in your client-side code. With web modules you can import functions from backend into files or scripts in public, knowing they will run server-side. Corvid handles all the client-server communication required to enable this access."
And from this: https://www.sitepoint.com/what-is-wix-code/
"It’s serverless: All this added functionality comes in a serverless environment that lets you get your work done without any of the normal full-stack development headaches.
Just code and go: Wix Code has a built-in, online IDE and backend so you can just add the code you need to your page or your site, publish, and you’re live."
So, I thought they have a backend IDE where I can write backend code directly, or I could call my Java program. But, as I tried doing this and finding tutorials, it seems I can really only do this by calling a public API from the backend...?
https://youtu.be/tuu0D1izrUU
But ive also read (and someone who supposedly has done it before told me this) that Wix integrates with node.js, which is a backend version of JavaScript.
Can I use a Wix domain for a NodeJS app?
But, when I go into my Wix site I cannot find any option for using Node JS, and doing research on that gives me no useful results.
So, I'm thoroughly confused on what the capabilities are here. Can someone help me make sense of this?
Why are there no tutorials showing explicit code in the Corvid backend module? What's stopping me from simply writing my Java program there in a module? Do I really need an API endpoint to call and pass to the front end?
Is Node JS supported or not - has anyone done this before?
Also, in one link above they said everything is "serverless". But if I have to set up my own API endpoint won't I need to set up my own server??
There are basically two ways to go about this, which you seem to have already discovered.
Write your backend code in your Wix site. Indeed, the backend is built on Node.js as you can see here. Using this approach you will have to use JavaScript. As you seem to have found, you write this code in the Backend section of your site in a Web Module. Pros: you don't need to worry about managing a server and all your code is in one place.
Expose your already existing Java code as an API that your Wix site can call using the wix-fetch API. Pros: you don't need to rewrite your code.
I am considering php framework Codeigniter & Cakephp for small site I would be developing but I am open to using pretty much any framework does fullfill the following requirements. requirements are:
A simple pre-build user authentication system or login system as a plugin, something long
the lines of php-login-script.
Allows Easy integration with third-part excel/spreadsheet generation library or
has some plugin.
Should support PHP 5.2, hence symfony2 can't be considered
Bonus points if the framework
has integration with twitter
bootstrap
Looking for framework which can fullfill all of the above points, so I can save some time. Else, I would prefer framework which does most of the requirements & would write rest myself.
So, based on above requirements; which php framework/script would you suggest?
CakePHP2
User plugin https://github.com/cakedc/users
Twitter Bootstrap https://github.com/slywalker/TwitterBootstrap
There are plenty of different xls export helpers. Just google it and review them I can not recommend any of them because I have not used them. We have our own but we did not open source it.
Overall I would recommend to use CakePHP2 in any case over Codeigniter. I've recently had to convert a project from CI to Cake and now I know why... ;)
I don't know codeIgniter very well, but for Cakephp I can tell you that:
Authentifiaction is easy to implement.
It's easy to generate xml (which Excel can open), for .xls you'll have to do all by yourself.
supports 5.2
there is a helper for twitter bootstrap, but I've never used it.
For me the deal breaker concerning CodeIgniter is the lack of built-in ORM. You should consider if you need one or not.
Doing anything in the terminal, git, etc multiplies my learning curve in attempting to quickly develop an app using CodeIgniter. I realize the need for a Javascript framework and would like to use AngularJS - is there any way around the terminal?
All you need to do is to download the AngularJS source files (.js files) and get coding. I am new to it too and am fairly impressed with it. However it seems to me that is is designed for different things than CodeIgniter.
Angular JS basically moves your MVC from the back end to the front end, my limited experience tells me that it is for simpler apps than what CodeIgniter would be for. You can certainly still have some logic in your MVC back end, but the idea is that Angular becomes the application and you use a back end primarily for data storage.
There may be a way to mix the two together by making limited scope Angular pages that are worked within a superstructure of the CodeIgniter MVC, but I have not figured this out yet.
AngularJS can certainly work with Code Igniter, and you don't need to use the terminal for either.
You're probably going to want to write a RESTful API with Code Igniter that AngularJS can communicate with. Check out this article for RESTful services with CI: http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2/
(a little old, but the basic concept is the same)
Then, with AngularJS, you'd use $http to make requests back to the API you wrote with CI: http://docs.angularjs.org/api/ng.$http
I have a project which is heavily JavaScript based (e.g. node.js, backbone.js, etc.). I'm using hashbang urls like /#!/about and have read the google ajax crawlable spec. I've done a wee bit of headless UI testing with zombie and can easily conceive of how this could be done by setting a slight delay and returning static content back to the google bot. But I don't really want to implement this from scratch and was hoping there was a pre-existing library that fits in with my stack. Know of one?
EDIT: At time of writing I don't think this exists. However, rendering using backbone (or similar) on server and client is a plausible approach (even if not a direct answer). So I'm going to mark that as answer although there may be better solutions in the future.
Just to chime in, I ran into this issue too (I have very ajax/js heavy site), and I found this which may be of interest:
crawlme
I have yet to try it but it sounds like it will make the whole process a piece of cake if it works as advertised! it's a piece of connect/express middleware that is simply inserted before any calls to pages, and apparently takes care of the rest.
Edit:
Having tried crawlme, I had some success, but the backend headless browser it uses (zombie.js) was failing with some of my javascript content, likely because it works by emulting the DOM and thus won't be perfect.
Sooo, instead I got hold of a full webkit based headless browser, phantomjs, and a set of node linkings for it, like this:
npm install phantomjs node-phantom
I then created my own script similar to crawlme, but using phantomjs instead of zombie.js. This approach seems to work perfectly, and will render every single one of my ajax based pages perfectly. the script I wrote to pull this off can be found here. to use it, simply:
var googlebot = require("./path-to-file");
and then before any other calls to your app (this is using express but should work with just connect too:
app.use(googlebot());
the source is realtively simple minus a couple of regexps, so have a gander :)
Result: AJAX heavy node.js/connect/express based website can be crawled by the googlebot.
There is one implementation using node.js and Backbone.js on the server and browser
https://github.com/Morriz/backbone-everywhere
crawleable nodejs module seems to fit this purpose: https://npmjs.org/package/crawlable and example of such SPA that can be rendered server-side in node https://github.com/trupin/crawlable-todos
Backbone looks interesting:
http://documentcloud.github.com/backbone/
http://lostechies.com/derickbailey/2011/09/26/seo-and-accessibility-with-html5-pushstate-part-1-introducing-pushstate/
I am writing a webapp in Clojure.
I almost want to use Google Web Toolkit for the frontend -- since I can just write Clojure/Java code, and have the library automatically generate the Javascript/AJAX.
However, for some reason, GWT does not sem to be used much in the real world.
Is there something that is similarly tied into Java (like GWT is) but more popular?
Thanks!
There is JWT.
GWT is used in the real world!!! A lot! And google is doing some pretty huge things with it so I don't think popularity is a valid concern.
I don't want to start a flame war so I won't elaborate any more on this.
Also, remember that GWT is a java - javascript compiler. No bytecode will run on the client. Hence, you can only use java, not clojure code when writing client-side code.
GWT is not particularly useful with Clojure, because it (GWT) uses a custom compiler that reads Java source code (not bytecode). Unless you want to write all your user-interface code in Java, GWT will not help you.
Now ClojurescriptOne is a good way on an alternative to GWT. The things I found missing so far are full source optimization, and of course some customized libraries.
Also for instance clojurescriptone does only compile javascript to one file, does not yet create cached html-files to further speed up load times like GWT does.
The support for Google Closure is not fully wrapped yet so you have to use interops. That said, I still think this is an equivalently good alternative compared to java-programming in GWT.
You might also want to check out my micro-framework supporting development of AJAX apps with Clojure/Ring/Compojure/lib-noir stack:
http://ganelon.tomeklipski.com
It does not copy execution model of GWT, but rather works like Vaadin or Weblocks (but without session-statefulness or complicated UI components): it simply lets your XHR handlers return side effects to be applied to a page client-side through thin (and extendable) JavaScript layer.
For example: response from XHR handler can update part of a page by #id or display Bootstrap's Modal or redirect browser to a new url - but you can really easy add own operations.
I realise this question was asked long ago, but there is now a direct answer - ClojureScript. It allows you to directly compile clojure code into javascript, and supports most of the common clojure idioms.