JavaScript frameworks

User interface is the only part with which masses interact that is why It should always be built immaculately. UI has to be amicable and eye catching as well as easy to manage for a naïve and expert. Interaction part is not just the graphic layout or visible items for almost all type of web applications, simple or advance. Here a problem arises.
What is the best method to build front end of the web application while there are numerous frameworks available for building simple text page to complicated forms. In this article we shall discuss the different available java script frameworks which provide ease in building web forms. We shall also discuss right approach to use the frameworks discussed beneath.

1- Google Web Toolkit

Is initially built for the ease java developers who want to write UI in simple java based framework. GWT has its own compiler which converts code into browser readable html and JavaScript while the coder only write in Java language. It means GWT is a fully object oriented solution. Google prefers MVP pattern for writing apps under-discussion framework. Additionally developers can download GWT SDK and eclipse plugin from GWT site. Moreover GWT Designer can help creating forms quickly.
It provides more productive and comprehensive Ajax solution without writing a single of Ajax. However, coders can embed native JavaScript code into GWT using different techniques. In addition with that plugin provides debug facility which is rarely available at this level of simplicity.
One of the basic problem developer’s confront with GWT is slowness of it. It takes a while to compile. Google presents a solution for this that is development mode for programmers. JUnit can be used for testing that is exception but using mock testing is not easier anymore.
Another problem could be for some, creating new widgets or styling them is not easy. It also forces to look like Desktop application for some it is not right requirement. Additionally for intellectual programmers compiled ajax code is dingy, not readable.

2- JQuery

Second on our list is JQuery, which is the most compressive and comprehended JavaScript framework till today. Complete solution for those who want to write less and do more. Hundreds of readymade plugins are already available while coders can write their own as per their needs. It gives the right rich application development experience especially to those who are not afraid of writing new widgets and customize plugins.
Jquery library is as small as 5-6 kb. For browsers, easy to download and manage events but little more complicated for heavy client interaction applications with complicated forms. Managing code is easy but needs right practices of MVC.
Jquery is not exceptionally amicable with all browsers. It concerns sometime but not in all rich client applications.

3- YUI Library

YUI is another open source robust javascript and CSS framework. Licenced under BSD, Built by Yahoo engineers at Yahoo office which guarantees the proven experience. Especially developed to full fill rich interface needs. Comes with own Testing framework as well.
Some of YUI components do not support all browsers, various conflicts with other JS libraries are some of the shared issues with YUI frame work.

articles-on-current-ethical-issues-in-business-news

A few moral values regarding business make a book of business ethics.There are many things to do many not to do. Business leaders need to have a thoughtful conversation about these values. Everywhere you look, there is no convincing evidence that single-minded pursuit of wealth often leads to more intelligent people to do amazingly stupid things, destroying things that money can not buy.
If money is so attractive, how is it that so many people of great wealth also seem so unhappy? Money may be the root of all evil, but only if you’re not honest about what it means to you.

Money is about love and relationships,” Needleman explained in his book MONEY AND MEANING OF LIFE . “It has a wonderful power to bring people together as well as tear them apart. You can’t escape money. If you run from it, it will chase you and catch you. If we don’t understand our relationship to money in this culture, then I think we’re ruined. If you don’t know how you are toward money and really understand that relationship, you simply don’t know yourself.

Being rich does not mechanically lead to a rich life. “There is a difference between money and success. To be victorious means to have developed character. You should be looking for the delight, the struggle, and the challenge of work. What you bring forth from your own guts and heart. The happiness of hard work. Cannot be bought by any amount of money. Those are things of the spirit.

Although there are several approaches to business ethics.Business conduct can be analyzed much as we analyze human conduct. Businesses, like human beings, can be seen as agents who make decisions (French, 1984, Brown, 1990). There are also significant differences between businesses and human beings. Businesses, for example, do not have individual motives or desires. They are structured collectives and communities. These differences, however, do not prevent us from evaluating “business condut.Profit making is the purpose of every business and this also determines the ethics of every business personality.

Profit does not have to be an opponent of business ethics. We do not have to be confined by the false dilemma of “people or profit.” We do need to put profit in its place, in an ethical framework that encompasses the key elements of human action. In order to accomplish this, we need to develop an ethics of purpose, or teleology, that allows us to analyze corporate activities in terms of their normative function in society. This function may change as society changes, but if a business becomes good-for-nothing, why should it exist? The tobacco industry today is facing just this problem. At the same time, business decision makers need more than an ethic of purpose. They also need to explore relevant principles and probable consequences. If we remember that businesses, like most of us, should eat to live, rather than live to eat, then the place of profit in a comprehensive ethic will be less of a mystery.

What GUICE (juice) do..

What Guice do.

while working in layers their are several ways to connect presentation classes to service and data classes.
one ways is direct Constructor calls. for example in our scenario.

if we have serverside class PurchaseHandler.java which performs different functions for on purchasing an item, like delete, add, etc. we need it to access a class which connects database and perform db operations.

Image Upload using GWT/GUICE/GIN/Servlets

In previous blog entry We learnt about upload simple file to google blob store using Guice and GIN with GWT.
Now in this I shall describe a technique for uploading image to blob store and displaying it back on the gwt page. Example Code can be downloaded from http://code.google.com/p/gwt-image-file-upload/.

While uploading file into blobstore use ImageService to handle image. By writing following code in servlet UploadBlobServlet.java Image URL can be obtained.

  1. ImagesService imagesService = ImagesServiceFactory.getImagesService();
  2. String imageURL = imagesService.getServingUrl(blobKey);

So return this imageURL back to GWT page and set as image source.

Thank you for reading.

Basics of Google Datastore

Datastore provides a query engine and transaction. Its storage capacity grows with growth of data just like web server grows with your traffic.
Unlike relational databases datastore is schema less. Basically Datastore is built on basis of a big table. Every row in a big table can have different number and type of columns than any other row. Google says,

GWT blob upload Exception

  1. Uncaught exception from servlet
  2. java.lang.IllegalStateException: Must be called from a blob upload
  3. callback request.

This is because Upload Url should be generated from Server on run time and form submitted on that action. for example, you need to get file upload through blobstoreService.createUploadUrl(“/data/upload”). what ever it returns submit file on that URL.

GWT/GAE File Upload Using Guice and Gin

Client Side:

1- create Upload form in new dialog box

  1. public class UploadDialog extends DialogBox {
  2.        
  3.         private void createForm(){
  4.                 VerticalPanel panel = new VerticalPanel();
  5.  
  6.                 form = new FormPanel();
  7.  
  8.                 form.setEncoding(FormPanel.ENCODING_MULTIPART);
  9.  
  10.                 form.setMethod(FormPanel.METHOD_POST);
  11.  
  12.                 fileField = new FileUpload();
  13.  
  14.                 fileField.setName("datafile");
  15.                 panel.add(fileField);
  16.  
  17.                 panel.add(new Button("OK", new ClickHandler() {
  18.  
  19.                         @Override
  20.                         public void onClick(ClickEvent event) {
  21.  
  22.                                 uploadFile();
  23.                         }
  24.                 }));
  25.  
  26.                 panel.add(new Button("Cancel", new ClickHandler() {
  27.  
  28.                         @Override
  29.                         public void onClick(ClickEvent event) {
  30.  
  31.                                 hide();
  32.                         }
  33.                 }));
  34.  
  35.                 // Add an event handler to the form.
  36.                 form.addFormHandler(new FormHandler() {
  37.                         public void onSubmit(FormSubmitEvent event) {
  38.  
  39.                         }
  40.  
  41.                         public void onSubmitComplete(FormSubmitCompleteEvent event) {
  42.                                 hide();
  43.                                 Window.alert(event.getResults());
  44.                         }
  45.                 });
  46.  
  47.                 form.add(panel);
  48.                 setWidget(form);
  49.         }
  50.         private void uploadFile() {
  51.                 doUpload();
  52.         }
  53.  
  54.         private void doUpload() {
  55.  
  56.                 dispatch.execute(new GetUploadUrl(), new AsyncCallback<uploadurl>() {
  57.                         public void onFailure(Throwable throwable) {
  58.                                 onGetUploadUrlFailure(throwable);
  59.                         }
  60.  
  61.                         public void onSuccess(UploadUrl uploadUrl) {
  62.                                 form.setAction(uploadUrl.getUrl());
  63.                                 form.submit();
  64.                                
  65.                         }
  66.                 });
  67.         }
  68.  
  69. }</uploadurl>

Assert in GWT

Asserts are removed when compiled to javascript.
Use asserts for things that are so wrong that it’s a programming error that
ought to be caught in development mode, and you don’t want to pay any
overhead in production for it.

Coding Basics – Compatibility with the Java Language and Libraries – Google Web Toolkit – Google Code

Language support

GWT supports most of the core Java language syntax and semantics, but there are a few differences you will want to be aware of.

Note: As of GWT 1.5, GWT compiles the Java language syntax that is compatible with J2SE 1.5 or earlier. Versions of GWT prior to GWT 1.5 are limited to Java 1.4 source compatibility. For example, GWT 2.0 supports generics, whereas GWT 1.4 does not.

It is important to remember that the target language of your GWT application is ultimately JavaScript, so there are some differences between running your application in development mode and production mode (previously known as hosted mode and web mode, respectively):

  • Intrinsic types: Primitive types (boolean, byte, char, short, int, long, float, and double), Object, String, arrays, user-defined classes, etc. are all supported, with a couple of caveats.
    • Arithmetic: In JavaScript, the only available numeric type is a 64-bit floating point value. All Java primitive numeric types (except for long, see below), are therefore implemented in production mode as if on doubles. Primarily, that means overflowing an integral data type (byte, char, short,int) will not wrap the underlying value as Java specifies. Instead, the resulting value will outside of the legal range for that data type. Operations onfloat are performed as double and will result in more-than-expected precision. Integer division is implemented to explicitly round to the correct value.
    • long: JavaScript has no 64-bit integral type, so long needs special consideration. Prior to GWT 1.5, the long type was was simply mapped to the integral range of a 64-bit JavaScript floating-point value, giving long variables an actual range less than the full 64 bits. As of GWT 1.5, longprimitives are emulated as a pair of 32-bit integers, and work reliably over the entire 64-bit range. Overflow is emulated to match the expected behavior. There are a couple of caveats. Heavy use of long operations will have a performance impact due to the underlying emulation. Additionally, long primitives cannot be used in JSNI code because they are not a native JavaScript numeric type.
  • Exceptions: try, catch, finally and user-defined exceptions are supported as normal, although Throwable.getStackTrace() is not meaningfully supported in production mode.

Note: Several fundamental exceptions implicitly produced by the Java VM, most notably NullPointerException,StackOverflowError, and OutOfMemoryError, do not occur in production mode as such. Instead, a JavaScriptExceptionis produced for any implicitly generated exceptions. This is because the nature of the underlying JavaScript exception cannot be reliably mapped onto the appropriate Java exception type.

 

  • Assertions: assert statements are always active in development mode because it’s a great way for GWT libraries to provide lots of helpful error checking while you’re debugging. The GWT compiler removes and ignores all assertions by default, but you can enable them in production mode by specifying the -ea flag to Compiler.
  • Multithreading and Synchronization: JavaScript interpreters are single-threaded, so while GWT silently accepts the synchronized keyword, it has no real effect. Synchronization-related library methods are not available, including Object.wait(), Object.notify(), and Object.notifyAll(). The compiler will ignore the synchronized keyword but will refuse to compile your code if the Object‘s related synchronization methods are invoked.
  • Reflection: For maximum efficiency, GWT compiles your Java source into a monolithic script, and does not support subsequent dynamic loading of classes. This and other optimizations preclude general support for reflection. However, it is possible to query an object for its class name using Object.getClass().getName().
  • Finalization: JavaScript does not support object finalization during garbage collection, so GWT is not able to be honor Java finalizers in production mode.
  • Strict Floating-Point: The Java language specification precisely defines floating-point support, including single-precision and double-precision numbers as well as the strictfp keyword. GWT does not support the strictfp keyword and can not ensure any particular degree of floating-point precision in translated code, so you may want to avoid calculations in client-side code that require a guaranteed level of floating-point precision.

GAE – upload file blobstore exception

When I run the GAE local server, the BlobStorage service works fine.

When I run the GWT/GAE project in GWT development mode, however, the blob
store service doesn’t work:

Problem accessing
/_ah/upload/aglhbHRhaXN0YXRyGwsSFV9fQmxvYlVwbG9hZFNlc3Npb25fXxgBDA. Reason:

Must call one of set*BlobStorage() first.
Caused by:

java.lang.IllegalStateException: Must call one of set*BlobStorage() first.
at

Solution
I’ve been able to resolve this problem, which was occuring because the gwt-maven-plugin is copying the appengine testing libraries into the WEB-INF/libs folder. When the stubs and testing libraries are removed, everything works.