Monday, March 30, 2009

GWT 1.6.3 - update procedures for Mac

1. Download the GWT folder:

2. Install GWT jars into the Maven2 Repository:

cd /opt/gwt/gwt-mac-1.6.3/

mvn install:install-file -DgroupId=com.google.gwt -DartifactId=gwt-user -Dversion=1.6.3 -Dpackaging=jar -Dfile=gwt-user.jar 


mvn install:install-file -DgroupId=com.google.gwt -DartifactId=gwt-servlet -Dversion=1.6.3 -Dpackaging=jar -Dfile=gwt-servlet.jar


mvn install:install-file -DgroupId=com.google.gwt -DartifactId=gwt-dev -Dversion=1.6.3 -Dpackaging=jar -Dfile=gwt-dev-mac.jar

3. Change your filter/properties files e.g. uki.properties:

GWT_DEV_JAR = /Users/uki/.m2/repository/com/google/gwt/gwt-dev/1.6.3/gwt-dev-1.6.3.jar

M2_REPO= /Users/uki/.m2/repository

4. Change your ANT build.xml (project specific):

< property name="GWT_SERVLET_PATH" value="${M2_REPO}\\com\\google\\gwt\\gwt-servlet\\1.6.3" / > 
< property name="GWT_USER_PATH" value="${M2_REPO}\\com\\google\\gwt\\gwt-user\\1.6.3" / >
< fileset dir="${GWT_SERVLET_PATH}"> < include name="*.jar" / > < /fileset >


Thursday, March 26, 2009

Java set

Java set is a collection that contain unique elements.
Set sports = new HashSet();
for (Season season : currentSeasons)
{
sports.add(season.getSportLeague().getSport());
}

Tuesday, March 24, 2009

SQL: having count

select * from game g join team_game tg on g.id = tg.game_id group by g.id having count(g.id) > 2


The HAVING clause is used with the GROUP BY clause. It can be used in a SELECT statement to filter the records that a GROUP BY returns.

Saturday, March 21, 2009

CSS: help tip, cursor: help;

Cursor: HELP; gives you a nice "?" mark when you mouse over the help item.


.help_link {

padding: 15px;

text-align: justify;

font-variant: small-caps;

color: gray;

text-decoration: underline;

cursor: help;

}

Thursday, March 19, 2009

Selenium IDE Flow Control

The following configuration has to be done in Selenium IDE for the conditional flow to work.

The Options settings in Selenium IDE should set the 'Selenium Core extensions' to include the path of file '/XYZ/docs/Sellenium/goto_sel_ide.js', similar to the image below. Click on Options menu -> options to get below form.

Tuesday, March 17, 2009

GWT compiler optimizations

http://css.dzone.com/news/understanding-gwt-compiler

If you want to change the style of the javascript that is generated you can use the following argument.
-style The script output style: OBF[uscated], PRETTY, or DETAILED(defaults to OBF)

Another nice argument to know is this one that will not fully optimize the generated code, and will allow for faster compile times when compiling for Dev reasons:
-XdisableAggressiveOptimization

The last thing that can speed up compile times, is to narrow the number of user agents (browsers) that you want the generated code to work with. You have to edit the UserAgent.gwt.xml file in the gwt-user.jar which can be a pain, but is well worth the trouble if you are compiling only to test a one browser.

Friday, March 13, 2009

Simple If-Then-Else Operation

int greater = (number_one > number_two) ? number_one : number_two;
This is a simple piece of code that runs a conditional and based on the outcome, will return one of two results. If the conditional is true, the first answer is returned (ie: number_one). If it is false, the second is returned (ie: number_two).

Thursday, March 12, 2009

Passing Functions in Java

Though it is not possible to pass functions in java like in dynamic languages, you can just as easily create a new class and pass that class with the given with a defined function. The method can even take arguments and return a value given by parameterized types. Below is the interface I created that these classes implement which contain the function you want to call.


package com.ucc.csd.client.common;
public interface FunctionCall {
V call(T value);
}


V is used to specify the class that needs to be returned by the method, and T is used to specify the class that the method takes. These can easily just be of type Void if no value needs to be passed or returned. Below is an example that doesn't need to take or return values.


public class SomeClass{

private void doSomething(){

FunctionCall callOnCompletion = new FunctionCall()
{
public Void call(Void arg0)
{
//do stuff

return null;
}
};

SomeCommonClass.doStuff(callOnCompletion);
}
}

public class SomeCommonClass{

static void doStuff(FunctionCall callOnCompletion){
//do stuff

callOnCompletion.call(null);
}
}

Wednesday, March 11, 2009

Java isEven() using modulus operator



    public static boolean isEven(int x)

    {

return (x % 2) == 0;

    }

Tuesday, March 10, 2009

subList function in GWT

The subList function for the List interface is not supported in GWT. It causes a runtime error because the function is not implemented as of GWT 1.5.3.

Sunday, March 8, 2009

scp (secure copy to a server)


uki@Uki:~/Documents/workspace/CSD $ scp map.tar someuser@xx.xxx.x.xx:
someuser@xx.xxx.x.xx's password: 
map.tar                                                                                                               13% 2288KB 183.2KB/s   01:23 ETA

Create a ZIP-TAR (Archive file)

To ZIP TAR the directory:

uki@Uki:~/Documents/workspace/CSD $ tar cvzf map.tar map/

Friday, March 6, 2009

svn cleanup

Sometimes if you are forced to close the Eclipse while sync, you may corrupt your project.


update /Users/uki/path/MyProject -r 575 --force
   
  svn: Working copy '/Users/uki/path/MyProject' locked; try performing 'cleanup'

To cleanup SVN run the following command from the Terminal window:


uki:~ uki$ cd /Users/uki/path/MyProject
uki:/Users/uki/path/MyProject uki$ svn cleanup

Tuesday, March 3, 2009

Hibernate hql error with sets

Hibernate error

If anyone gets an error similar to this:

java.lang.NullPointerException
at org.hibernate.hql.ast.tree.DotNode.getColumns(DotNode.java:97)
at org.hibernate.hql.ast.tree.DotNode.initText(DotNode.java:212)
at org.hibernate.hql.ast.tree.DotNode.resolve(DotNode.java:206)



if your hql query looks similar to: where user.addresses.state.abbreviation = 'WI';

try joining and creating an alias for the set of addresses: join user.addresses as adrs ... where ... adrs.state.abbreviation = 'WI';

Sunday, March 1, 2009

Selenium: setting an ID on GWT widgets

Selenium is an automated testing tool for web applications. If you are using Selenium test cases for GWT (Google web Toolkit), you need to set the ID's on UI widgets. Each clickable HTML element should have an ID set using the ensureDebugId("my_id"); method. Make sure to use this ID once ONLY:

Label userName = new Label("User Name:");
userNameInput = new TextBox();
userNameInput.setStyleName("textbox");
userNameInput.ensureDebugId("userNameID");


In your gwt.xml file, include:

com.google.gwt.user.Debug