I am developing a Java web services application that is (mostly) to be used by other SOA clients. Currently I am planning on using CXF to publish my various web services & methods using SOAP/XML.
I am now being asked to investigate a thin client web-application for this tool. I have been looking into Javascript libraries such as ExtJS and Dojo -- and they seem really straightforward. Given that this is a web application and not a web site, I really don't think I'll be creating very many static HTML pages -- maybe even just one. Mostly I plan on using an XMLHttpRequest object to hit the web services I already have and take the results and modify the DOM.
However, I have never created a browser-based UI before and in the context of a nearly 100% Javascript application I am trying to figure what role, if any, a server side MVC framwork such as Spring MVC will buy me. Is it needed for this? Whats it good for?
If you use the CXF JavaScript client generator and go for a single page JS application, I don't see what a Java MVC framework will give you (apart from extra complexity).
Spring MVC is a web-based module based on servlets and JSPs. If you're writing a JavaScript UI that calls on services directly, I'd say that you don't need Spring MVC.
Related
I am new to web development and recently came up reading about AngularJS and SpringMVC and a few other frameworks. As far as I could understand, AngularJS implements the MVC on client side and Spring implements MVC on the server side.
And in another tutorial I read about using AngularJS with SpringMVC. This confused me a little.
Why do we need to implement MVC pattern on the server side when its already done on the client side?
If spring returns a view, then how is this passed on to AngularJS? Or what is the necessity for returning a view when Angular itself has a view to present?
Also, isn't having all the controllers and services on the client side (AngularJS) lead to security issues, because there are cases of security breaches for JavaScript. And also, wouldn't having those on client side load up the client?
I am a bit confused. Please correct me if I am wrong somewhere. Thanks in advance.
In a previous job I worked extensively with AngularJS and Spring. We used our Spring for the back-end exclusively as a RESTful web application framework. AngularJS was our front-end and would do all the views and client-side logic.
I won't go into detail on how AngularJS implements MVC, but AngularJS provides very good tutorials on their website where you can get the feel for how they do things.
AngularJS is an excellent choice and a fantastic framework. They have a huge community and are continually improving/rebuilding themselves. They are backed by Google and are one of the most reliable and useful frameworks I've ever worked with.
As for security/client side. You need to use some type of authentication to protect your site. Code minification is important as well. Its important to note that the client side is much faster than it used to be. JavaScript accelerators and better browsers have made Javascript extremely fast even on mobile. You can do allot of lifting on the client side without slowing down the user experience. Its also important to design good endpoints for your back-end which will simplify the work you have to do in your front-end controllers.
Here is a good example on how to consume a RESTful API with angular resource.
Spring actually has a tutorial on their website showing how to consume a Spring Web Service with Angular JS. Here is the link. In the tutorial they show how to do this without angular resource, I suggest to not follow it explicitly, using angular-resource allows you to centralize all your API calls to one place and then inject them throughout your web-application as needed. This helps keep your code more modular and prevents the nasty refactoring process that occurs when you have endpoints scattered throughout dozens of files.
We have a project using ASP.NET MVC 4 and it is a multi page mvc web app. We are planning to use Backbone js as the front end javascript framework . What is the best practice or suggestion to organize the backbone js code for the multi page mvc web app?
How it will be organized if we use Knockout js instead of backbone js.?
Thanks,
Sarathy
In my experience, Backbone is best used for SPA's (Single page apps). It is designed to help bring structure to javascript heavy applications. You first need to tell us why you are looking to use either of these libraries and a description of the site or app you are building? Are you using MVC 4 Web API, because Backbone connects to your existing API over a RESTful JSON interface and Web API is a perfect fit for this.
The only reason I would see to use Backbone for a multi-page mvc web app, is if you are looking for the app to function with javascript disabled and progressively enhance the app with Backbone. If you are looking to use pushstate, then you would also need to serve the individual pages.
I think the best bet is to look at TODOMVC to get a feel of the different libraries. Look how they work and see which, if any, would be a good fit for your app.
I haven't done any web development for the last 6 years apart from a small silverlight project two years ago.
So 6 years ago I was working on a web project project using ASP.net and I must confess that I never liked Web Forms. Because ASP.Net
was a requirement I and because I was starting to get interested in Restfull web services, I used markup free ASP.Net pages,
each being a controller, and in each there was a big if, which was looking for the method name in xml message being sent from the front-end.
Around that time I started seeing web application using web services for the back-end and javascript only interfaces, which were using Ajax requests.
So for the last 6 years I´ve worked mainly in the Services Layers, with SOA and more recently with Event SOA, so to me I don´t understand the need for ASP.Net MVC,
I am learning it, because it seems to be a requirement everywhere this days, but in the times of SOA why do you need ASP.MVC if you are using just MSFT stack?
Say I want to build a new system, with a web front-end, and I built it in Layers, like the example bellow:
DAL -> SOA Services -> Web API (WCF) -> Front-End (JavaScript only)
Would it be better if a built it using ASP.NET MVC? I mean don't take me wrong but I just don´t see it fit anything but small non-layered projects.
ASP.Net MVC is a huge improvement over Web Forms, and I was hoping you guys could give me some insights on this; I am not trying to be cynical here, I've been
away from Web Developmental for a long, time and I just need to know why people seem to prefer ASP.Net MVC over plain JavaScript front-ends.
Thanks a lot.
This will get closed as you're really asking for opinions.
But the reasons include:
Purely javascript front-ends are still extremely hard to do well. Extremely.
ASP.net MVC came out a couple of years before you could really do that anyway
Code reuse is much easier in a server-side framework still
WCF webservice vs ASP.Net MVC is personal preference. Both have their weird black magic quirks that shows MS still doesn't quite get HTTP, HTML or javascript. They did just bring out a Web API for MVC, though it's still not clear why they did as it seems to adds very little.
I understand that major question is "where to build views and UI logic - on server side or client side" Shortly speaking - it depends on priorities. If you need quick results - use server side language to generate views and only plug in javascript into your pages. If you need to have responsive design with many dependences between components on the same page - probably javascript is your only choice.
With the creation of node.js and various other utilities for writing server side javascript and with the MongoDB using javascript as it's primary access method, it looks like all the pieces for a web framework are now in place.
Are there any frameworks now using exclusively Javascript? (This means for server side interactions, database interactions, code generation, templating, possible MVC architecture)
I came across a couple when I was looking into nodejs platform. There is expressjs and spludo. Although I haven't really used them on a project.
I would like to build a web project, using ExtJS, the famous JavaScript library. The goal is to use only ExtJS (and some CSS and HTML) to build the entire client-side web application. I also would like to apply a Model-View-Controller structure to the code of this project.
First question: is it possible and pertinent to apply such an architecture to an ExtJS project?
Second question: how can I easily apply a MVC architecture to a ExtJS project?
I already read this but it does not answer my questions.
The documentation from the ExtJS community does not provide such tips.
In all given samples, code is contained in one single file, and UI code is not separated from the application logic code. For example, listeners methods and calls to server come along with UI code.
In fact, all tips to separate application logic from user interface code are welcomed.
Edit
Another question: What do you think is the best way to design a ExtJS based web application? I did not found any good designer for ExtJS. The designers I found (this and this) don't seem to be reliable (code generation of the first sometimes fails).
In my experience, you want to think about two separate applications.
On the server side, you want to fashion a pretty typical MVC application that simply provides a web service. You're probably fine just talking JSON. Look into doing things RESTfully.
On the client side, you have a javascript application. If you're really leveraging ExtJS, you should only have an initial request/response that sets up the application. Everything from then on should just be XHR requests to your web service (and, if you're getting fancy, lazy-loading of ExtJS-driven javascript files).
This kind of architecture will pay for itself when all of a sudden you want to open up a public web service, or write some alternative client (iPhone apps, for example). These alternative clients should be able to rely on the already-running web service.
Switching gears to the client-side, ExtJS driven stuff -- MVC can help you here, but you're making a mental context switch from a request-driven system (on the server), to a more open-ended event-driven system in the browser.
Use a lot of the practices the ExtJS community talks about (smart use of factory methods, extending built-in classes, module pattern, ExtJS's template methods, etc).
While organizing your javascript application, try to think in an MVC sort of way. Learn how event bubbling and relayEvents() work. You've got your model stuff (basically, they'll derive from the built-in store classes), view stuff (Grids, Trees, etc), and controller stuff (usually attached to some container. Read Saki's stuff about inter-component communication at extjs.eu.)
There's certainly more than one way to do it when it comes to heavyweight client-side application design. But if you want to seriously leverage ExtJS's potential, it's worth it to take the time to read up on things. Look at articles or books about GUI programming in general -- writing an ExtJS app is more similar to writing a traditional desktop application than writing a web application.
In this domain, the "web" stuff gets very simple -- you're just handling data on the server side. The tricky stuff is figuring out how to organize and optimize the in-browser code.
Use some libraries which makes javascript OOP lang. Then use MVC pattern. Also you can use Ext-GWT for developing web on OOP java.