Saturday, March 10, 2007

How rich is rich client

It's very rich that it can seamlessly emulate any desktop representation sub systems now.
Steps to create a simple representation client:

1.create client stub (note the options)









1.1 Create eclipse project stub




2. Import as eclipse project







3. Project layout










4. Auto generated sample code (with a button and a label)
[cite]
package com.spark.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;

/**
* Entry point classes define onModuleLoad().
*/
public class veryRich implements EntryPoint {

/**
* This is the entry point method.
*/
public void onModuleLoad() {
final Button button = new Button("Click me");
final Label label = new Label();

button.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
if (label.getText().equals(""))
label.setText("Hello World!");
else
label.setText("");
}
});

// Assume that the host HTML has elements defined whose
// IDs are "slot1", "slot2". In a real app, you probably would not want
// to hard-code IDs. Instead, you could, for example, search for all
// elements with a particular CSS class and replace them with widgets.
//
RootPanel.get("slot1").add(button);
RootPanel.get("slot2").add(label);
}
}
[cite]

5.compile it using java2javascript compiler provided by gwt:




6. Run in eclipse - click the file veryRich-shell.cmd
The following browser hooked into jvm will be started:
















Click the button, the label will be switched.





That's cool.

The only limitation on rich client is speed, security and imagination

No comments: