Developing JavaScript APIs by using Third-Party Librarys - javascript

I currently want to make my project accessible not only via back-end code (C#, Python, PHP, etc.), so I decided to write an easy and simple JS API, every developer can easily integrate within their website / project.
Since the whole thing is a service driven system, most of the stuff runs via RPC encoded as JSON.
My problem is, that if I want to make this API I got the following two options:
Writting raw RPC functions from ground up
Using jQuery as third-party library
The big problem with option number 2, which is by far the best option, is that I have to say "dear developer, you need to use jQuery to access my API", which is striking me, since I do not want to dictate what ppl should or should not use by restricting their opportunities.
Is there a way implementing jQuery's RPC stuff without breaking any other potential JS framework the final developer will use?

if you're worried about the conflict between jquery and other libraries, use jQuery.noConflict() and it solves your problem!
more info at : http://docs.jquery.com/Using_jQuery_with_Other_Libraries

Related

Rich web application (HTML5 +JS) with Java on the backend?

There are lots of great Javascript libraries out there these days for creating rich web applications and I would like to use one of them for the frontend of a website I'm working on as they seem to provide a way better interface than what you usually see with JSF, Facelets, PrimeFaces, etc...I read so many complaints about the presentation layer for Java EE and on the other hand things seem to be getting better and better when it comes to Javascript and HTML5.
I am wondering how to go about doing this? One JSP and Facelets you can have items in the presentation layer directly mapped to objects on the server. How would you deal with this when instead you use a Javacript library for your frontend?
I will use Java EE on the server but what is the best way of integrating this with a Javascript RIA library on the frontend?
If your question is only about mapping objects from the back-end to the JavaScript front-end, then I suggest using a JAX-RS implementation (RESTEasy, Restlet, Apache CXF, ...) in combination with Jackson (JSON provider).
This combination allows you to publish a REST API with your domain objects converted to JSON, so you can easily access these objects through JavaScript by using AJAX requests.
But of course this leaves a lot of communication handling open to the developer, if you want to have a more complete package, frameworks like Google Web Toolkit are probably a better solution.
A Google Web Toolkit frontend would be easiest to combine with a Java EE backend as it supports this out of the box with it's own communication system. Otherwise RESTful services are easy to communicate with from javascript and are easy to create in Java EE especially with the aid of an IDE like netbeans.
You can create a front end using JavaScript Libraries like JQuery, ExtJS, Dojo etc with HTML/ HTML5.
To communicate with a Java EE server, you can use an Ajax request with the response in xml/json format.

Dilemma... Which Program & Language to develop my Android and iOS App

I'm developing an app for both the android and ios platform. I'd like to take a route that allows me to only have to code once for both platforms. There are 2 options I've come across:
Develop in Flash builder 4.5 with flex (actionscript, or I've heard javascript also?)
Develop using Phonegap (javascript)
The app is very simple - it will use the google api and the phone's geolocation function, then also display more information about the business listings from google map's api. Downloaders of the app will also have to register to become free members. All of this information will have to be put into a mysql database on my server.
So my question is, which is the best route to take with what I am hoping to accomplish? If using Flash builder, is it best to learn actionscript or javascript? What's the best way to connect with the mysql server if I'm writing in javascript, ajax?
If you are serious about it and want to create other apps as well in the future, you should learn the native frameworks/languages for each of the platforms. If not, and you just want to make one quick app I would choose Phonegap rather than Flex/Flash.
Firstly, get familiar with HTML and Javascript to understand what they are even capable of. There's no point in trying to complete a project with tools that you don't understand. As for the options you named, I'd definitely go with the Phonegap method as it is much simpler.
However, you also need a backend for your solution if you're trying to use a MySQL or other database to store any data. For this you'd need some server-side language like PHP, JSP (or you could use NodeJS, if you want Javscript on the server too) etc, that retrieves information from the database according to the requests received from your app.
In conclusion, I'd suggest you to read more about PHP/MySQL, Javascript and making webpages, since this is what you are actually trying to do if you use Phonegap, even though you might look it as an app. Do some tutorials, get to know the languages before you try to take on something that surpasses your skill level just yet.
For a nice small db-interface I'd rather suggest using ruby (with sinatra as mvc-framework and activerecord on top of mysql, or just use rails) than using php!
http://guides.rubyonrails.org
http://www.sinatrarb.com/

rapidly create webpage front end

Exposition:
I'm familiar with C/C++/Scheme & OpenGL. I have this client/server program written in Clojure that serves as a todo-list/wiki/forum. The server is written in Clojure. The client is written in Clojure and uses SWT.
Question:
I want to rapidly create a web client version of this. What is the best way to do this? (I Don't use anything complicated, like OpenGL rendering in SWT; just standard widget stuff) I just want something accessible via Safari/Firefox -- and no, I don't want to run it as a Java Applet.
Thanks!
Take a look at Ruby on Rails, allows you to create very basic CRUD applications quickly. Personally I am looking more a Grails a very similiar framework but for a Java platform
Ruby On Rails - http://rubyonrails.org/
Failing either of those PHP is a good alternative and very quick to get started with
Adobe Flex/Actionscript is a pretty good approach for applications that require rich user interaction.
Google Web Kit allows writing of Java code (since server is in Clojure) to create AJAX api.

What is strophe and how to use it with JQuery?

Can somebody explain what strophe is?
I believe it has something to do with XMPP?
How can I incorporate it into a site using Jquery?
Strophe is not a Jabber Client, and its not an XMPP client. Its a library that allows you to easily write either of these. You could (with great difficulty) write a Jabber/XMPP Client from scratch using Javascript or Jquery, but this would be very difficult imagine generating and sending XML like this:
<body xmlns='http://jabber.org/protocol/httpbind' sid='e4fcc09444a61059e88296a106e86e1ff1454f9b' wait='60' requests='2' inactivity='30' maxpause='120' polling='2' ver='1.8' from='localhost' secure='true' authid='1027072784' xmlns:xmpp='urn:xmpp:xbosh' xmlns:stream='http://etherx.jabber.org/streams' xmpp:version='1.0'><stream:features xmlns:stream='http://etherx.jabber.org/streams'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/>
Strophe is a library of Javascript functions that makes the process of writing an XMPP client easier. It has methods to allow you to connect to a server, to send a message to a user, to add a contact - and it knows about the XML that needs to be sent to the server to carry out these actions. It basically does all the difficult stuff - the XML generating, sending, connecting and communicating stuff for you. Which makes your life a whole lot easier.
Strophe is a XMPP client, written in Javascript. More specifically, it is a Javascript library that lets you write real-time web applications that have full XMPP capabilities. It is "real-time" because is uses a "Comet-like" technique known as "BOSH" http://xmpp.org/extensions/xep-0124.html.
Once you learn the basics of Strophe, using it with jQuery will "just work" as there is no conflicting code, named functions, or dependencies.
The API documentation for the library can be found here -> str<>phe API
It's a javascript library that's separate to jQuery but obviously you can call any javascript library from any other so I don't believe you'll have any requirement for a specific jQuery integration.
Strophe already uses jQuery. In fact, the Strophe builder APIs borrow the $() syntax from jQuery. Take a look at the echobot example that comes with the source. Definitely check out the Strophe Google group (http://groups.google.com/group/strophe), where you would find Jack Moffitt (creator of Strophe) promptly answers questions himself.

Can you use Silverlight with AJAX without any UI element?

I know you can just use CSS to hide the DIV or Silverlight Plugin, but is there a way to instantiate a Silverlight Component/App using JavaScript that doesn't show any UI element at all?
There is alot of great functionality in Silverlight, like MultiThreading and compiled code, that could be utilized by traditional Ajax apps without using the XAML/UI layer of Silverlight at all.
I would like to just use the standard HTML/CSS for my UI layer only, and use some compiled .NET/Silverlight code in the background.
Yes you can, and some of the reasons you make makes perfect sense. I did a talk on the HTML bridge at CodeCampNZ some weeks back, and have a good collection of resources up on my blog.
I also recommend checking out Wilco Bauwers blog for lots of detail on the HTML bridge.
Some other scenarios for non visual Silverlight:
Writing new code in a managed language (C#, Ruby, JScript.NET, whatever) instead of native (interpreted) JavaScript.
Using OpenFileDialog to read files on the client, without round-tripping to the server.
Storing transient data securely on the client in isolated storage.
Improving responsiveness and performance by executing work in the background through a BackgroundWorker or by using ordinary threads.
Accessing cross-domain data via the networking APIs.
Retrieving real-time data from the server via sockets.
Binding data by re-using WPF's data-binding engine.
Yes. I think this is particularly intriguing when mixed with other dynamic languages -- but then, I'm probably biased. :)
Edit: But you'd need to use the managed Javascript that's part of the Silverlight Dynamic Languages SDK and not the normal Javascript that's part of the browser.
Curt, using Managed JavaScript would still require you to have some Silverlight/XAML display layer being visible on the page, correct? Is there a way to entirely get rid of any Silverlight/UI element from being displayed?

Categories

Resources