Thursday, September 25, 2008

Setting Environment Variables on Mac

It is essential to set up a list of environment variables that are specific to a specific development environment. Below are the step on how to accomplish this on MacOS:

1. Open a text file and save it as .bash_profile:
# User specific Terminal config
if [ -n "$PS1" ]; then PS1='\u@\h:\w \$ '; fi
shopt -s checkwinsize

echo ~/.bash_profile

export PATH=$PATH:/usr/local/bin

####### JAVA DEV #######
export JAVA_HOME=/Library/Java/Home/
export PATH=$PATH:$JAVA_HOME/bin


2. Save .bash_profile under main user directory in the HD.
3. Restart your terminal window.
4. Verify in the terminal that you have the correct path for the env var. you just set up:
echo $JAVA_HOME

Tuesday, September 23, 2008

GWT: convert database objects to DTO object

Google web toolkit operates on DTOs (Data Transfer Object) in the front end. Every time data is retrieved from the database, it has to be converted to DTO objects before it can be used in the front end. Below code illustrates how to convert from database objects to DTOs:

In the service implementation class, externd HibernateRemoteService class:
public class MyServiceImpl extends HibernateRemoteService implements MyService,
{
public MServiceImpl()
{
XmlBeanFactory xml = ApplicationContextFactory.getXmlBeanFactoryInstance();
setBeanManager((HibernateBeanManager) xml.getBean("hibernateBeanManager"));
myDao = (MyDao) xml.getBean("myDao");
}
private MyDao myDao;
public List fetchAll()
{
List myList = organizationDao.fetchAll();
List dtos = ConvertToDTO.clone MyObject ListToDTO(getBeanManager(), myList);
return dtos;
}
}


Create a method as follows:
public static List cloneMyObjectListToDTO(HibernateBeanManager beanManager, List myList)
{
List< MyObjectDTO > dtos = new ArrayList< MyObjectDTO >();
for (MyObject obj : myList)
{
MyObjectDTO organization = (MyObjectDTO) beanManager.clone(org1);
dtos.add(organization);
}
return dtos;
}


At this point you can make a call from the front end to the Asynchronous method to call the service implementation. This will allow you to get a DTO objects that are converted from the back end.

Monday, September 22, 2008

"Runner" software for iPhone GPS

Yesterday night,  I was evaluating a new iPhone software for runners.

The program works very well, here are the highlights:

  • start your music BEFORE you start running and it will keep on playing in the background
  • select the distance (3 mile, etc), or time you want to run 
  • keeps track of your current speed, 
  • keeps track of your  average speed, 
  • calories burned for your weight and distance (about 120 kcal per mile)
  • routes the path you have run on the map
  • keeps history of all of that

Friday, September 19, 2008

Turning on colored coding in Eclipse


It is exteremly helpful to have color coding turned on in your development environment. In Eclipse you can turn on this color coding option in order to have modifiers, variable names, etc display in a common color, this will help you quickly identify how the code is used. To do this follow below steps:

In Eclipse menu -> Preferences option -> type "Editor" in the search text box -> Mark occurrences -> check all check boxes shown in picture below.

Thursday, September 18, 2008

Technology and Determination

Richard E. Leakey, a famous archeologist, described humans in his book, the "Origins":

[as] highly intelligent creature who, through technology and determination, has come to dominate the world [...]

Everyone will understand the definition of determination, but what is the technology today? Surely not the flint points.

We created a lot of powerful technologies.. atomic bombs, fighter planes, satellites, bio and chemical weapons, but if you think of it, they are mostly useless, the MOST far reaching and POWERFUL weapon is INFORMATION and the World Wide Web. We [I and some of my readers] happen to be foremost experts in this technology.

Do we have the determination to make a good use of it?

Sunday, September 14, 2008

Saturday, September 13, 2008

Setting up a new GWT project - part 2

This article assumes that you followed the previous step in "Setting up a new GWT project - part 1".

We will try to extend the previous functionality which just displayed the content of "Main.html" file and create a simple GWT element.



Here are the steps that we will work with:
  • Add css and images directories for later styling
  • Main.gwt.xml
This file at this point only defines the application entry point Main.java
  • Main.html
This file does not change much, but it includes the compiled JavaScript 

    <script language='javascript' src='com.taktico.Main.nocache.js' type="text/javascript">


  • Main.java
This is a very basic GWT functionality:

package com.taktico.client;


import com.google.gwt.core.client.EntryPoint;

import com.google.gwt.user.client.Window;

import com.google.gwt.user.client.ui.Label;

import com.google.gwt.user.client.ui.RootPanel;


/**  @author Uki D. Lucas  */

public class Main implements EntryPoint

{

    public Main()

    {

RootPanel.get("page").add(new Label("GWT! 1"));


    }


    public void onModuleLoad()

    {

RootPanel.get("page").add(new Label("GWT! 2"));

Window.alert("done loading!");

    }

}


The Eclipse directory will look similar to this:


Here is the screenshot of Main.gwt.xml and Main.html




And here is the resulting application!




At this point you have the client side GWT working, all you have to do is to add some services...

Side note: 
MyEclipse 6.5  Maven dependencies drives me nuts, I frequently switch to MyEclipse 5.0 and all seems to work fine.


Setting up a new GWT project - part 1

Below are steps I took to set up a new GWT project. I realize that this is not a simple step-by-step instruction that someone may follow, but hopefully it will help you in some way. 

  • Create a new Java project in Eclipse 
  • Create Maven2 pom.xml with all dependencies you may need
Maven gathers all the required jars and builds the war file that will be copied to the Tomcat.
  • Ant build.xml file:
Ant file coordinates all tasks into simple "single-click".  

    <target name="war" depends="clean">

    <echo>Maven Executable: ${MAVEN_EXEC}echo>

    <exec taskname="mvn war" dir="${basedir}"

    executable="${MAVEN_EXEC}">

    <arg line="clean compile war:war -Dtarget=${TARGET}" />

    exec>

    <delete file=".\\target\\csd.war" />

    target>


    name="gwt_shell" depends="war">

    <echo>GWT: starting hosted (dev)echo>

    <java taskname="GWT hosted" classpathref="class_path"

    classname="com.google.gwt.dev.GWTShell" fork="true"

    maxmemory="512m">

    <jvmarg line="-verbose ${JVM_ARG_START}" />

    <arg line="-out www com.taktico.Main/Main.html" />

    java>

    target>


    <target name="gwt_compile_to_js" depends="war">

    <java taskname="GWT compile" classpathref="class_path"

    classname="com.google.gwt.dev.GWTCompiler" fork="true"

    maxmemory="512m">

    <jvmarg line="-verbose ${JVM_ARG_START}" />

    <arg line="-logLevel WARN -out www com.taktico.Main" />

    java>

    target>


  • Properties file in src/main/resources (uki.properties)

    DEPLOY_DIR = /usr/local/tomcat/webapps/csd/

    GWT_HOME=/opt/gwt/gwt-mac-1.5.1/

    JVM_ARG_START = -XstartOnFirstThread

    MAVEN_EXEC=/opt/maven/apache-maven-2.0.9/bin/mvn



  • Add  src/com/taktico/public/Main.html
  • Add src/com/taktico/Main.gwt.xml




If you can see the HTML  it is a great time to take a break, good job!

If you need a weekend tutoring on any of the subjects mentioned I might be available on weekends for a very reasonable fee plus travel expense if outside the Chicago area, contact: UkiDLucas@mac.com

Please leave a comment.

Friday, September 5, 2008

Internet Connection Anywhere (or almost)

I love to write blogs from the coffee shops at the bookstore.

There is hardly anything more stimulating for me than watching people
reading books. I try to guess each persons character and interests and
I know many of us do that. The crowds in the airports, malls, or
Starbucks are also interesting, but the people with books are much
better. You get less of the mindless or sleazy types in the bookstore,
yes I am talking about loud and obnoxious sales types. When totally
out luck, I can always glance up to the portraits of the authors in
Barnes & Noble, and smile to my buddy Melville and to my writing
Polish sailor hero, Joseph Conrad.

For last few years I have been using the Hot-Spot WI-FI service for T-
mobile, initially it was great, later it was dropped from Barnes &
Noble booksellers. I could still use it in Starbucks and Borders, but
there are two of the Barnes & Noble stores in my neighborhood and no
Borders, ouch!

Then, a few coincidences directed me to the current solution. I have
seen couple of associates using the laptop cards when internet was too
slow, or not available, I noticed the AT&T $60/month plans while
shopping for the new iPhone, finally after I cancelled a credit card
my T-Mobile service rejected me at the Starbucks.

I have to admit that $60 per month for the card is a lot, twice as
much as my previous WI-FI was. WIth it I still get WI-FI speed at the
coffee shops, but I can go on the sailboat, or the park bench and
still do my things. Time will show if this was a good choice. Since I
have a MacBookPro I opted for ExpressCard card and if you buy
refurbished one, you don't pay nothing for it with 2 year contract.


Mac driver for the Option Wireless GT Ultra Express.

Wednesday, September 3, 2008

Unix: passing in params into tomcat from shell


startup.sh -Djive.ws.disabled=false –DjiveHome=Users/zaziz/Documents/workspace/jive/jive-dev/Project/jiveHome
Using CATALINA_BASE: /opt/apache-tomcat-6.0.16
Using CATALINA_HOME: /opt/apache-tomcat-6.0.16
Using CATALINA_TMPDIR: /opt/apache-tomcat-6.0.16/temp
Using JRE_HOME: /Library/Java/Home/

Monday, September 1, 2008

Option Wireless: GT Ultra Express Mac Installation

I wanted to provide these installation steps since the (retard) manufactures do not make it easy...

1) Insert the card (ExpressCard slot)

2) Download Mac driver for the Option Wireless GT Ultra Express.

3) Preferences -> Network -> Location (drop-down) -> "GlobeTrotter Connect" -> close this window

4) Open application: "GlobeTrotter Connect" -> Preferences -> 3G/EDGE/GPRS -> enter following:

APN: isp.cingular

5) click blue icon "Connect" -> Elapsed Time should tick...