Server side technology with ext-js - java

I have chosen Ext-JS to develop the UI for my next application. I am wondering what is the best way for Ext-JS to interact with my server.
Should I use plain JSPs which return a JSON response? Should I use DWR or Jabsorb which provides direct remoting with backend java code. Any other solution?
I am more concerned about performance and nothing else.

You can certainly use plain JSPs or servlets, manually handling your requests and forming JSON responses. You'll make life easier on yourself using DWR or something like it to handle the plumbing for you, and the performance shouldn't be noticeably different.
Current versions of Ext JS use the Ext.Direct stack for integrating supported back ends into the UI data layer, making it much simpler to bind components like grids and forms to your back end services. Here is a grid sample that demonstrates such remoting. Here is the Ext.Direct forums -- you should have a look at what others are doing. Look at this post to see what Ext.Direct providers are currently available for Java.
Again, you can certainly make your calls manually from Ext using Ext.Ajax directly (or using the standard Store methods for making calls), but the Ext.Direct stack can make it much easier to integrate everything together.

we'r using the extdirect library for Spring MVC 3 in our Company and it works fantastic !
Extdirectspring
You can ask me when you've troubles configuring it.

Related

HTML/HTML5 website creating using Jodd(java) framework

I've been reading about Jodd(java) framework and it looks interesting to me. But I see that it seems to be jsp/servlet based. Can you develop strictly html/html5 dynamic website without jsps with it?
Absolutely. As you can see, in Jodd Madvoc you have this concept of Result : each (java) action returns it. Results are the one that defines how you are going to render the page. By default, there are JSP results, as this is a standard, right; but nothing stops you to simply have a i.e. Freemarker result or to use any other template engine. People are doing this often. Moreover, Results are made to be configured. See: http://jodd.org/doc/madvoc/results.html
Result does not need only to return HTML content. There is a JsonResult for example, or RawResult that can return a JSON or any string.
If you want REST-ish interface that only results with JSONs, you can do that as well, checkout: http://jodd.org/doc/madvoc/rest.html
Madvoc should be configurable enough to fit your needs. Just don't think of it as a 'solution-in-a-box', but a real framework, that you need to dig just a little, but you will find what you need :)
You can develop strictly html/html5 dynamic Websites without JSPs for sure, there are many ways to do it, but in my personal opinion, I believe that you can use AngularJS for your front-end development (HTML5/CSS3). This framework will allow you to implement all your client side without minor issues. It is based on HTML5, so no JSP files will be required. If you are used to MVC or MVVM, well this framework will allow you to work with any of these two approaches.
Dynamic Web Application? Need to show data from a database or store records? No problem, Angular supports AJAX calls to REST Web Services which you can implement with the programming language you feel more comfortable. If it is Java, then you can go for some REST Web Services using Jersey.
Hope this information is useful for you.
Happy coding.

How can I convert an Applets application into an Web application using JSP and Javascript?

I have a project that is built on Applets and that also comprises of Corba calls to backend (which is in C language). Now I need to remove Applets and convert it into JSP and Javascript combination. But the code seems to be complex as it also consist of backend calls. I am facing problem in figuring out what is to be converted in JSP and what in Javascript.
If I convert all the applet logic in Javascript, how will I pass the javascript data to the Java objects to pass it as input for corba calls.
I can't implement all the logic in JSP as the existing logic depends on the dynamic change of data by user.
I tried various links but couldn't find the proper solution to my problem.
I read somewhere that Google Web Toolkit (GWT) might help me converting Java Logic to Javascript, but couldn't figure out what exactly needs to be done for that.
Can anyone guide me how should I start and what exactly should I do to complete my project?
First the bad news. There is no generic and magic solution that can convert your legacy (as you are describing it) into modern n-tiers web application.
I can suggest you the following steps.
decide what kind of client and server side technologies you are going to use and learn them to become familiar enough to start coding.
learn your legacy code and re-design it. Decide which parts of the code must be re-written, what you can use as-is and what you have to change and/or re-package.
To choose client side technology try to search for "client side javascript frameworks" or something like this. Popularity of GWT that you mentioned is going down now. The most modern framework these days are AngularJS.
Concerning server side technologies I personally prefer Spring but you can take a look on Guice and EJB too. You can also implement whole server side as as collection of servlets. It is up to you.
Start learning this amazing world and come back with more concrete questions. Good luck.

Good Design for calling BRMS/Drools Logic over REST

I am working on an application which is built in .NET and Java. The Java component contains the complete Rule base using Redhat BRMS suite. The .NET client (UI and desktop based applications) will be consulting the Java Rule engine and sending/receiving the JSON data. The decision which has been taken is to expose the Rules engine (Redhat BRMS 6.0.0 using Drools) as a REST based API. I have come-up with the following design approaches:
Write a REST controller in Spring framework and service classes for calling BRMS.
Write a simple REST controller using JBOSS proprietary RESTSY or JAXRS.
Write a Camel adapter and wrap the REST calls behind the Camel and let the Camel talk to Drools.
Wrap REST behind SOAP based webservices.
I want to ask which one would be the better approach for designing such as System.
Any other thoughts are welcome.
As might be obvious from https://github.com/gratiartis/sctrcd-payment-validation-web and https://github.com/gratiartis/qzr my general preference is for exposing my Drools business rules using REST APIs in a Spring application.
The only alternative I consider in the above list is 4, where the API is exposed through a SOAP web service. Albeit definitely not wrapping a JSON REST service! A well-designed Spring application can expose functionality through both REST and SOAP APIs with very little effort.
I have usually exposed via SOAP when working with .NET clients. Firstly, the .NET tooling has excellent support for generating proxies based on WSDL that you have defined. Secondly, the WSDL forms a well-defined contract which both you and the client developers must obey. Having a strict contract can be very useful in preventing arguments. Although if your interface is simple, it may not be so much of a benefit.
The other key reason is that the WSDL does not change unless you change it deliberately. A REST JSON API may seem quick to develop, thanks to Jackson generating everything for you. However, it can expose your internal object model (and dependencies!), meaning that unless you are careful, what seems like a trivial change to an internal model can make private data visible and can break clients.
All that said, if you can keep the API reasonably simple and have a good relationship with the .NET devs (perhaps you're one of them), then going with the Spring REST API would be my recommendation. Feel free to steal code from the github repos if it can help you get started!
btw - If you were to consider Camel, it's worth noting that there is a Drools-Camel component which does quite a bit of the work for you.
In my view,
I would go with the option 1. This is the simplest and easiest approach.
Option 2 may be second choice.
Option 3 - Looks like if there are some routing rules you could choose. Again its could make it complex.
And definitely not option 4 to make it complicated with SOAP.

Integrating Javascript Frameworks with Java Web Frameworks

I have what I think might be a strange question to ask.
Recently I was playing with some java web frameworks (jsf with primefaces) and I noticed that it's quite good at handling form data or when you play along with the jsf components. I also did a project using grails and again it was useful for form data.
But the moment you want to do something which requires a little deviation; then I found myself doing weird things (examples are tag clouds with large strength values using primefaces and single page webapp forms with grails).
This resulted in some very messy html+javascript code for my grails things(which I blame on my inexperience with javascript). This was done because I was using expression language (grails in this case) to populate some of the javascript. The worst part was that I had a bunch of custom javascript code inline with my server pages (I could of refactored a little out but I think one would still have alot of javascript calls inside a single page).
So now to the question(s) :)
[main question] Are there any resources that demonstrates how to design or at least implement maintainable javascript with server pages (gsp, xhtml, etc) ?
The reason is that I find that there are some neat javascript frameworks, but using them with server pages seems a bit unnatural if one takes into account the expression languages for server side frameworks? Unless it's normal to do this type of thing :) ?
Are there appropriate frameworks for Single page webapps using java?
My current answer is that GWT, Vaadin (based off GWT) and perhaps JavaFX qualify. Maybe ZK, Flex and (Grails/Roo + Flex/GWT) also qualify as well?
Are java web frameworks still useful for presentation layers?
My current answer is that they might be when you are dealing with portal type webapps or Web 1.0 apps for lack of a better word. The other case is that they could be when you use alot of role based security and you want to filter things out based on roles, but even that has counter arguments.
My other answer to this is that it might be better to use a java server to provide your web services and then rely on something else to do the front end?
This might be OP, but for single page apps, it's easier to serve up data from the server via JSON(P)/XML/whatever and then use things like Backbone to process and modify the view(s) accordingly. That way, the server can use REST/SOAP/websockets/whatever, and the browser app becomes a full-fledged app.
I haven't actually done this, so don't quote me, but I imagine that it should make sense.

Converting Java app into a web app, will i benefit from using a framework?

I have created a Java desktop application, and have decided to turn it into a web app. The app carries out basic statistical tests on data and is fairly small around 1000 lines for main functions.
So far i have created the interface using Jquery UI with all requests sent via Ajax. I am now ready to start developing the back end, the plan was to code basic Servlets to link my interface to the core Java classes.
Would this be a ok approach for a small app? or is there a specific framework i should follow?
I have looked over struts but it seems massive and also spring mvc, but again i am not sure if that would work with my one page interface.
(This whole app is for learning purposes, so i am always willing to extend my knowledge, however looking for that doesn't take too long to learn.)
I've started building my webapps as Jersey + Jackson backends, offering up a REST API to a static HTML/JQuery/Angular front end.
It's worked out to be really scalable as you can heavily cache the front end and stick it on Amazon Cloud Front, and the backend can scale horizontally as needed. The need is much lower than traditionally as it's only actual operations that hit the Java server.
If your program is only 1000 lines, you will probably spend more time learning a framework then the time it will save you. You can make a well designed MVC server without a fancy framework.
There are some APIs that might be useful though, like a logging API or Hibernate if you need a database.
I agree with the other answers that REST is a good idea.
A framework can get routine off you shoulders. The JAX-RS mentioned above will handle URL-to-service mapping and conversion from JSON to your types and back.
Now, what to choose is entirely up to you. For a small application, the time you spend learning the framework can be so huge that you won't care about the benefits any more. On the other hand, frameworks give you a code which is easier to read and thus easier to maintain.
I would suggest to expose a RESTful API using some JAX-RS framework (e.g. Jersey) instead of pure servlets.
Also, as a representation I suggest to use JSON, which is very conveniently used in Javascript with/or without JQuery .

Categories

Resources