Tuesday 27 September 2011

Ant

In the root directory with build.xml & build.properties file.
Run "ant build hosted"

If directory not have .classpath or .project file:
Run 'ant eclipse.generate'

Sunday 25 September 2011

GWT Tut - RPC

To use RPC, write 3 components:

1.Define (ClientService interface) extends RemoteService & lists all RPC method.
2.Create (ServerServiceImpl class) extends RemoteServiceServlet & implements methods.
3.Define (ClientServiceAsync interface) to be called from client-side code.

Calling the remote procedure call:
1.Create the proxy class
private ClientServiceAsync clientServiceSvc = GWT.create(ClientService.class);
2.Initialize proxy , set up callback object & make call to the remote method.
Initialize: clientPriceSvc = GWT.create(ClientPriceService.class);
Set up callback: AsyncCallback callback = new AsyncCallback() {public void onFailure .... onSucess....}
Call the remote method: clientServiceSvc.getToy(...

Wednesday 14 September 2011

GWT Tut - gc

Development : in the "edit - refresh - view" cycle.

1.add the widgets to specific [div]
RootPanel rootPanel = RootPanel.get("stockList");
rootPanel.add(mainPanel);

2.Event
*Listen for mouse events on the Add button.
addStockButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {

3.Alert dialog box
Window.alert("'" + stockcode + "' not a valid code.");

4.Refer to widget value
String stockcode=newSymbolTextBox.getText().toUpperCase().trim();

5.Widget inside widget
Button removeStockButton = new Button("x");
stocksFlexTable.setWidget(row, 3, removeStockButton);

6.Timer
*Setup timer to refresh list automatically.
Timer refreshTimer = new Timer() {@Override
public void run() {

7.Generate random stock prices.
double price = Random.nextDouble() * MAX_PRICE;

8.From Double to String
String priceText = NumberFormat.getFormat("#,##0.00").format(price.getPrice());

9.Last update date and time
lastUpdatedLabel.setText("Last update : "+ DateTimeFormat.getShortDateTimeFormat().format(new Date()));

10.Debug
Run as debug. Resume, Step over, Step into.

11.Apply css style
stocksFlexTable.getRowFormatter().addStyleName(0, "watchListHeader");
stocksFlexTable.getCellFormatter().addStyleName(row, 1, "watchListNumericColumn");

12.Creat sec. styles dependent on primary style
removeStockButton.addStyleDependentName("remove");

13.Dynamic style
Label changeWidget = (Label)stocksFlexTable.getWidget(row, 2);
changeWidget.setText...
+if (price.getChangePercent() < -0.1f) +{changeStyleName = "negativeChange"; changeWidget.setStyleName(changeStyleName) 14. Generate stock data in JSON(Server). +PrintWriter out = resp.getWriter(); +out.println('['); out.println(" {"); out.print(" \"symbol\": \""); C1-Use JavaScript Native Interface (JSNI) and GWT overlay types to work with the JSON data. class StockData extends JavaScriptObject {... JSNI methods to get stock data. public final native String getSymbol() C2-Make HTTP call to retrieve the JSON data(Client). private static final String JSON_URL = GWT.getModuleBaseURL() + "stockPrices?q="; use the HTTP client classes in the com.google.gwt.http.client package [inherits name="com.google.gwt.http.HTTP" />

Thursday 8 September 2011

GWT Applications

1.First Step
============
1.Ajax (Asynchronous JavaScript and XML)
2.Web App By a.Adobe Flash and Flex b.Microsoft Silverlight c.Java FX
3.Software Engineering for Ajax - GWT most powerful tool for creat Ajax app
4.Can include any JS libraries, & compiles down distributed as Ajax app use only web don’t require runtimes or plugins. Browser appears like Ajax app, developer like build regular desktop app & provide debug support and compile-time error check on fly.
5.desktop like web-app : fast, responsive & visually rich
6.GWT generates JavaScript code from Java code
7.webAppCreator com.gwtapps.tutorial.client.Hangman

Wednesday 7 September 2011

Dojo

Hello
=====
1.[script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6.0/dojo/dojo.xd.js"][/script]
2.dojo.ready(function(){}
3.dojo.byId("greeting").innerHTML += ", from " + dojo.version;
4.dojo.require("dojo.fx"); //load module
5.dojo.create("li", {innerHTML: "One"}, list);
6.dojo.place(myfirst, mysecond, "last"); //for list
7.dojo.empty("mylist");

Thursday 1 September 2011

Master Detail

Nothing more than /object1/{object1.id}/object2/{object2.id}
url="{ownerId}/pets/{petId}/edit"

[c:forEach var="pet" items="${owner.pets}">
...
[c:forEach var="visit" items="${pet.visits}">

TABLE: owners
PRIMARY KEY id

TABLE: pets
PRIMARY KEY id
FOREIGN KEY owner_id references the owners table id field

TABLE: visits
PRIMARY KEY id
FOREIGN KEY pet_id references the pets table id field


(1)Database
Like, TABLE: owners
PRIMARY KEY id

TABLE: types
PRIMARY KEY id

TABLE: pets
PRIMARY KEY id
FOREIGN KEY type_id references the types table id field
FOREIGN KEY owner_id references the owners table id field

(2)Business Layer
Like, Entity or Validation
...petclinic.Owner
...validation.OwnerValidator

(3)Business + Persistence Layer (ApplicationContext-jpa.xml)
Like, JPA Clinic Implementation
...jpa.EntityManagerClinic
JPA configuration is provided by orm.xml & persistence.xml

(4)Presentation Layer (controller)
web.xml & petclinic-servlet.xml