Skip to main content

Home/ GWT - Samples/ Group items tagged gwt

Rss Feed Group items tagged

Esfand S

GWT fu, Part 1: Going places with Google Web Toolkit - 0 views

  • Summary:  Google Web Toolkit (GWT) lets you use the Java™ language to implement rich client user interfaces that run in a browser. In this two-part article, David Geary brings you up to speed on the latest version of GWT and shows you how to implement a desktop-like Web application.
  •  
    GWT is best suited for creating desktop-like applications that are replete with amenities such as drag-and-drop, windows and dialogs, and interactive widgets such as viewports. Although it's a simple application, the places application illustrates the potential for building such an application with GWT. So far I've shown you some fundamentals of GWT, including RPCs and database access, implementing composite widgets, event handling, and Ajax testing. In Part 2, you'll learn about some advanced GWT features, including sinking events, implementing GWT modules, and using event previews.
Esfand S

Maven and GWT - a never ending story? - 0 views

  • One of the cool things on GWT is, that you cannot just use Java as a programming language, you can also use all your cool and great tools, like Eclipse, JUnit, or build tools like Ant, Gradle or Maven. Sure you can, but this Maven thing seems not to be so easy. So lets take a look on how to solve it.
  • keep the structure clean by separating client (GWT) and server (maybe Java or even any other language) code in a strict way. This means, that your GWT code will not be in the same project as your Java EE web descriptor (web.xml).
  • If you have done the import, our photo-album-server module will be a Dynamic Web Project in Eclipse and you can add it to your Tomcat, JBoss or whatever server runtime. You can start it and run it as you like.
  • ...2 more annotations...
  • the GWT compiler configuration is done in the web application project. This is the best place, since you can just change the dependency and the GWT module and the compiler will compile a completly different GWT client. With other words, the web application pulls the right JAR out from the Maven space and uses it. This is much better than letting another project compile some JavaScript and than copy the JavaScript to your web application, or whatever solution you might find. So just add the GWT Maven plugin configuration and dependency below to the photo-album-server module’s POM.
  • our project is just a simple Java project.
Esfand S

Can anyone provide a step by step maven + gwt mvp tutorial? - 0 views

  • There is an outdated archetype which creates a very simple Gwt project without tests nor RPCs. Unfortunately the generated pom.xml is for old gwt versions and needs that you do a bunch of changes by hand.   mvn archetype:generate  -DarchetypeGroupId=org.codehaus.mojo \    -DarchetypeArtifactId=gwt-maven-plugin  -DarchetypeVersion=1.1 \    -DgroupId=com.foo  -DartifactId=myApplication - Lately I have sent a patch to gwt which adds the ability to generate pom.xm to webAppCreator. But the patch is under review and it wont be available until a new gwt version (in the case it is included). http://gwt-code-reviews.appspot.com/397801/show - So, I recommend you to get the pom.xml from a working application and use it as a template for your project. Some days ago, I  ported the google contacts example application in order to use available libraries for MVP and add tests for all the code. I think It should be a good point for starting your project: http://gwt-workshop.googlecode.com/files/GwtWsMvpContacts.zip
Esfand S

Google Web Toolkit (GWT 2.0) with Eclipse - Tutorial - 0 views

  • The standard approach in Java is to have separated projects for separate purposes. For example the domain model of the application is usually defined in its own project.
  • This chapter describes how you can make these projects available to the GWT compiler as modules.
  • GWT need to have access to the source files to compile them into Javascript code. If you add the project or the jar file to your GWT classpath then the Java compiler will not complain if you use the classes from the included project / jar but the GWT compiler will not be able to compile them. To make the Java files available to the GWT compiler you need to Create a gwt.xml file in the Java project / jar file which you want to use - This will instruct the GWT compiler to use the listed classes. Use the included library via the inherit definition If you are using a jar file you also need to include the source files in the jar
Esfand S

JSNI Components « Technology I/O - 0 views

  • JSNI lets you interface between Java and JavaScript in a type-safe way; you can use JavaScript objects in the Java code and rely on Java’s strong typing to protect you against various programming errors. But again, the more functionality you include in a single JSNI block, the less you can rely on Java’s strong typing to minimize errors. JSNI also provides a seamless way of moving between Java and JavaScript, allowing you to pass objects and exceptions across the boundary in both directions. Through JSNI, you manage JavaScript objects from Java, and you can call back to the Java code from the JavaScript code you write. One use is to wrap a third-party JavaScript library, where you create JavaScript objects from the library and pass them around the GWT Java code before perhaps sending them back to the JavaScript library.
  • A guiding principle of JSNI coding is to spend as little time as possible in “the dark side”; each JSNI method should be at an atomic level (perform one clear function) so that you isolate issues and keep as much control as possible in the strongly-types Java realm.
  • Here’s a simple JSNI method call: public static native void method_name(ObjectTyp someData) /*-{ someData.@org.gwtbook.client.Data::data1 == "GWT In Action" }-*/; We hope that doesn’t look too scary, even with the @ and :: symbols sprinkled in.
  • ...7 more annotations...
  • To help any syntax checkers know that they should avoid parsing the JavaScript code, you wrap it as a comment by using a modified standard comment, which starts with the characters /*- (a forward slash, an asterisk, and a dash) and ends with -*/ (a dash, an asterisk, and a forward slash) (2). It’s also important not to forget the trailing semicolon at the end of the definition; otherwise your code won’t compile!
  • Crossing the boundary from Java to JavaScript can come in two forms: writing JavaScript code in the Java application that performs some dedicated functionality, or writing JavaScript in the Java application that calls functionality in a Java- Script library already loaded into the web browser.
  • If you provide a return type, rather than just a void, then the JavaScript must return an object of the correct type. (Be aware that JSNI code can’t create new Java objects; it can manipulate ones passed in or create new JavaScript objects, but not new Java objects.) REMEMBER It isn’t possible to create new Java objects in a JSNI code block. Return types must either be primitive types, manipulated Java objects that have been passed in as input parameters, or references to newly created Java- Script objects (a JavaScriptObject type). It’s important to understand how the objects you provide as parameters are handled across the Java-to-JavaScript boundary
  • ensure that a clearly defined and repeatable mapping exists between Java typed objects and JavaScript untyped objects, which is what GWT provides.
  • Primitive Java numeric types, such as byte, short, char, int, long, float, or double, become simple objects in JavaScript whose value is that of the original object. For example, if you have a Java char, char keyPress = ‘a’, then it will become the JavaScript variable var k = ‘a’. Similarly, the Java int, int val = 10, becomes the JavaScript variable var v = 10. A Java String is translated across into JavaScript as a simple variable to which the original text is assigned. Therefore the Java object String name = “GWT In Action” becomes the JavaScript variable var s = “GWT In Action”. Finally the simple Java boolean, becomes another simple JavaScript variable; the Java boolean b = true becomes the JavaScript variable var b = true.
  • Moving on to more complicated Java objects that can be passed across the boundary, you have the Java array, a Java object, and a new object to GWT called the JavaScriptObject. We’ll discuss the last object more in the next section; for now, you should think of it as just a reference to a JavaScript object created somewhere else that can be passed around the Java code and on to other JavaScript methods—but you can’t look into its contents from the GWT Java code. This may sound strange, but we’ll explain in more detail later in the section on this object. Passing an array across the Java-to-JavaScript boundary is treated in a similar opaque way; you know you have an array object, but you can’t look into its contents. This means that if the JavaScript code needs to use values in the array, then you should move them out of the array before you cross the boundary: either into separate parameters or into another type of user-defined Java object. You can manage Java objects in JavaScript through the JSNI interface, as we’ll discuss next. You can also pass your own defined Java objects across the Java-to-JavaScript  boundary; GWT provides a special syntax allowing you to access the fields and methods of that Java object. This will take a little bit of explaining, so please, stick with us.
  • Event
Esfand S

Anchors in GWT | GWT Tutorials - 0 views

  • The primary reason why I am writing a specific tutorial on the Anchor widget is because without it you will not be able to easily use GWT’s history framework
  • let’s talk about a hash, and how to use them. Since GWT is an easy way to use AJAX we are going to stay within that realm when talking about the hash. A hash is simply anything with the pound symbol in front of it. For example “#gwt” is a hash that points somewhere in your web application. We are going to learn more about the hash in the tutorial on GWT history.
  • Anchor anchor = new Anchor("GWT Tutorials", "http://www.gwttutorials.com?action=hello", "_blank");   String paramAction = Window.Location.getParameter("action");   //Do something with paramAction.
  • ...1 more annotation...
  • So basically the way this works is that you can create a new Anchor widget and append a parameter to it. In your onModuleLoad function you can get the parameter from the window’s location, and then use this parameter to load a different state of your application. To create a parameter just append a “?” then the name of the parameter and finally the value of the parameter. Also you can include multiple paramters by using the “&” symbol, so for example you could do this: “?action=hello&noaction=bye”.
Esfand S

GWT 2.0.3 + Maven2 + Eclipse - Google Web Toolkit | Google Groups - 0 views

  •  
    I converted the GWT starter app into a Maven project (see attachment), which might serve as a good starting point for you. It uses GWT 2.0.3, gwt-maven-plugin 1.2, and Google Plugin for Eclipse 1.3.1. I've also included an Eclipse project and launch configuration.
Esfand S

GWT JSNI | GWT Tutorials - 0 views

  • JSNI gives you the freedom to pick and choose which GWT capabilities you want to use.
  • JSNI is base on Java JNI which allows you to declare a Java method, but implement the definition in another language.
  • entire JavaScript libraries have been implemented into GWT with the use of JSNI.
Esfand S

GWT History | GWT Tutorials - 0 views

  • GWT handles the browser’s history stack by changing the hash, which is always preceded by the “#” symbol. While the JavaScript community call it a hash, GWT calls it a token, but regardless of what you call it, the token is how you are going to update the state of your web application.
  • The way in which you are going to capture changes in history is through the ValueChangeHandler. You will need to implement the ValueChangeHandler in your EntryPoint class,
  • The next step is to implement a function that will handle the logic of your state changes. So I am going to create a new method called onHistoryChange and I am going to pass in an argument called token. You will see why it is not recommended to write your logic in the onValueChange method in a moment.
  • ...2 more annotations...
  • The next step is to initialize the state of your web application using the history stack.
  • AJAX history logic can get confusing quickly, so you should have a good plan in place before writing the logic.
Esfand S

developerlife - Tutorials » GWT Tutorial - Managing History and Hyperlinks - 0 views

  • GWT provides a way for your apps to hook into the browser’s history mechanism, so that you can control what happens when a user hits Back or Forward in their browser. You can also programmatically manipulate the browser’s history, and even create hyperlinks in your apps that can hook into the browser’s history mechanism. You can even intercept these hyperlinks when a user clicks on them, instead of having the browser handle it, or both.
  • tokens allow you to map a specific state of your application to what’s in the browser’s history stack. When your app starts up, the stack is empty. When the user interacts with your app, and clicks on something, you can add tokens to this stack (either via hyperlinks or calls to History.newItem(String token)). This lets you change the history. You can also attach a HistoryListener to your app which will allow your app to respond to this change of history.
  • Why do it this way? I mean, if your app generates the tokens themselves, why not just change the state instead of dealing with receiving a history change notification (that you just initiated) and then respond to it? A good reason for taking the trouble to do this, is to allow people to bookmark certain states of your application. If you don’t want them to do this, then you can just plug into the history mechanism, and then ignore all the history state change events, and make it so that the Back or Forward button does not mess your app up.
  • ...7 more annotations...
  • If there are tokens in the history stack, and the user presses the Back button, or you invoke the History.back() method, then the following steps occur: a token is retrieved from the top of the stack this token (which is just a String) is then passed to your HistoryListener implementation, and this is how you know that the Back button is pressed. You then have to parse that token and change the state of your application to match what this token represents to your app.
  • no matter what happens, all these Back/Forward actions (whether initiated programmatically by your app, or by a user) ends up calling your HistoryListener’s onHistoryChanged(String token) method, which can act as a traffic cop of your state machine. You are in control of defining what a token is, and how it should map to various states in your application. You can encode parameters in the token and then parse them out later, to understand what your app is supposed to do now.
  • If you noticed the change in the browser’s displayed URL, when a hyperlink with a history token is clicked, then can see how the user is able to bookmark a specific state in your app… the token is simply added to the URL in the browser prefixed with a “#”. So, is it possible to add your own history token by typing in the URL for your app and just appending “#mynewtoken” to it? Yes! This is how GWT handles people bookmarking specific states of your application. One thing to keep in mind is that if you end the browser session, and then come into the app, then your app will have to process the initial history state, and it will have to check to see if there is “#mynewtoken” passed in the URL to the browser, and then adjust it’s state accordingly
  • you can hook into this mechanism and make it possible for the app to go to a particular state or load a particular resource or perform a function based on what is passed as a token to the URL.
  • You can use pass parameters to your app via the URL (here’s a coding quickie that shows you how), and you can use it along with tokens, but it’s bit confusing to use both.
  • let’s use this URL as an example: http://localhost:8888/Sample.Client/index.html#link2token?p1=v1&p2=v2 When you run the app with this URL, you will get the following string as the token: “link2token?p1=v1&p2=v2“. So as you can see it’s not a great idea to mix the two. This is the kind of URL that’s generated by the GWT Hyperlink class, so you can’t really mix and match query strings with history tokens.
  • If you want to create the URL yourself, then you can pass history tokens and query strings. In order to do this, you have to make sure to place the query string (?p1=v1&p2=v2) before the “#” in the URL and it will work. If you use this URL as an example: http://localhost:8888/Sample.Client/index.html?p1=v1&p2=v2#link2token When you run the app with this URL, you will get the following string as the history token: “link2token“. And a call to GWTUtils.getParamString() will return “?p1=v1&p2=v2“.
Esfand S

My First GWT IGoogle Gadget, What do you think? - Google Web Toolkit | Google Groups - 0 views

  • I built a basic and more complex gadgets which are demoed here. More Info here: http://code.google.com/p/gwt-examples/wiki/project_Gadget?ts=12722477... Basic Gadget is released here: IGoogle Directory: http://www.google.com/ig/directory?url=demogadgetmathflashcard.appspo...
Esfand S

How to use GWT to build, validate and submit a form - Community Wiki - Confluence - 0 views

  • A disadvantage of GWT is that you do not have a very big influence on the html that is being built. If you want to ban tables from your pages and only use divs, you can forget about GTW. If you want your form to be read by form readers for disabled users, GTW does not give you a lot of support for that.
1 - 20 of 199 Next › Last »
Showing 20 items per page