Tuesday, April 21, 2009

Using Windows With Sun VirtualBox



Now Im not idle anymore, I was assigned in new project, but this project require me develop in windows environment, so I must install windows on my inspiron, first in my thought, there are two alternatives: install windows inside my Ubuntu, or dual booting. I already ask id-ubuntu mailist, here's my post link for this problem.

In case Robbie, an office mate, already face the same problem before, and he choose the first way (install windows inside ubuntu) so I did the same thing. I need two installer:
- virtualbox-2.1_2.1.2-41885_Ubuntu_hardy_i386.deb
- XP installer (I have the SATA bundled one, in case inspiron harddisk is SATA).

I just double clicked the virtaulbox installer, because it's .deb filetipes so I didnot need run it from terminal. Actually there already newest version of virtualBox, but then I must download it first, so I just used that I already have. And there will be some usual install question such as how much memory and disk space that I spend for virtualBox, I give 200 MB memory and 10 GB of disk space. And also give the virtualBox a name. I give it "loswom" same as my project, and if I read that name again I said to myself: "what a name is that :D".

There will be one added item in the virtualBox explorer: "loswom". Then try to start it and it will be error because we still don't have the windows, we need to install it first (As seen in the picture, there's a picture in blogspot, I hope also seen in facebook). The explorer is in the left of the window, such as folder explorer, and the Start button and Setting button is on the top of that explorer.

I already have the .iso installer from my other friend, If you ever read my previous post when I first install ubuntu for this inspiron, I already copy the xp SATA bundled installer on my hard drive, So click Setting button left side of Start button, and find some option for install windows and locate the installer in the appropriate place, and restart again and the system will install windows as autobooting.

Install windows as usual, and we already have our windows, it is so easy far from my fear as I ask to id-Ubuntu mailist before.

Tuesday, April 14, 2009

Good Old Fashioned Lover Boy

"I can dim the lights and sing you songs full of sad things
We can do the tango just for two "

That is the first two lines of the lyrics of "Good Old Fashioned Lover Boy", song from Queen but sang again by Jason Mraz. I love the lyrics, I love the music, I also have the original one from Queen.

I remember that past few years ago I buy pirate cd from street when I work in my previous office when I live in Cilandak, I new in this town, alone, donot have computer, so I buy radio+cd player, and I bought the cd, it company me when Im sad, it company me when I feel alone.

Now I heard again that song, I have the mp3 of a lot of Jason Mraz songs, one of them is this song. Here is the full lyric, I copy paste from a site:

I can dim the lights and sing you songs full of sad things
We can do the tango just for two
I can serenade and gently play on your heart strings
Be your valentino just for you

Ooh love - ooh loverboy
What're you doin' tonight, hey boy
Set my alarm, turn on my charm
That's because I'm a good old-fashioned lover boy

Ooh let me feel your heartbeat (Grow faster, faster)
Ooh ooh can you feel my love heat
Come on and sit on my hot-seat of love
And tell me how do you feel right after-all
I'd like for you and I to go romancing
Say the word - your wish is my command

Ooh love - ooh loverboy
What're you doin' tonight, hey boy
Write my letter
Feel much better
And use my fancy patter on the telephone

When I'm not with you
I think of you always
(I miss those long hot summer nights)
I miss you
When I'm not with you
Think of me always
Love you - love you

Hey boy where do you get it from
Hey boy where did you go ?
I learned my passion in the good old
Fashioned school of loverboys

Dining at the Ritz we'll meet at nine precisely
One two three four five six seven eight nine o' clock
I will pay the bill, you taste the wine
Driving back in style, in my saloon will do quite nicely
Just take me back to yours that will be fine (Come on and get it)

Ooh love, (There he goes again just like a good old-fashioned lover boy)
Ooh loverboy
What're you doin' tonight, hey boy
Everything's all right
Just hold on tight
That's because I'm a good old-fashioned fashioned lover boy

Wednesday, April 1, 2009

Appfuse 2, Intro with Maven

I create new project using appfuse2, the main difference with appfuse1.9 is now we use maven rather than ant to build for example. The tutorial is already clear in appfuse site. But I will rewrite it in my own words.

1. Jdk and tomcat for the simple one.
2. Install maven, just download it, or apt-get it when if using ubuntu as me
3. Install mySql, I want to make the simple project one, so I use mySql because it is the default of appfuse, same as maven we can download it or apt-get from repository.
4. From the terminal type: mvn archetype:create and choose the framework, I choose the Spring basic from the options, actually I already try to make tapestry project, but fail in the midle. Here is the full syntax to create the project with basic SpringMVC:

mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-modular-spring -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.2 -DgroupId=com.mycompany.app -DartifactId=myproject

5. We must connect with internet incase we use the maven repository from internet, and it will download bunch of things from repository. And it should end with something like build successfully. and a folder named myproject is created.

6. Because it will be easier when uding IDE, so we can do as follow:
- From eclipse, create new java project
- Choose the radio: create project from existing source and browse it into myproject folder
- name it myproject

7. From terminal enter into myproject folder and type mvn or "mvn appfuse:full-source" for getting all the resources. if we only type mvn we will refer sources or classes into the repository, we cannot see or modify the code. This stage needs lot of times because download many things, but we can stop it and continuing next time because once it download, it is not need to download again. I remember actually I start with appfuse2 few weeks ago and meet some fails, and yesterday I continue my work.

And AFAIR we will meet some errors with the default source code, first we need to copy junit jar and refer it. I do this with copying junit.jar and add library to it, we must know it when using eclipse, so there are no error sign in our source explorer.

And we must change the password of the database in file jdbc.properties:
jdbc.password=ourPassword
hibernate.connection.password=ourPassword

and in the file pom.xml:
<jdbc.password>ourPassword</jdbc.password>

also in the pom.xml if we want to use our installed tomcat we comment this statement:
<zipUrlInstaller>
<url>${cargo.container.url}</url>
<installDir>${installDir}</installDir>
</zipUrlInstaller>

8. Type mvn jetty:run-war and it also start tomcat, so we can see our application in http://localhost:8080

Monday, March 23, 2009

Importing Blog for Facebook Note

I recently new that we can show our posts from blog into notes application in facebook. So I donot need to copy my note into my blog. This post is for testing how my facebook looks after I create new post.

But I should tell you about something, I don't want to post just for trying that facility only. But to be honest it's very hard for me to write something, writing is a hard job, sometimes suddenly we get idea but and then we loose it or even when we write something we then blank, and loosing words, and it happen to me often.

Anyway now Im listening marz music again and again, I do it in here in office, I do it again at home, again and again, but sometimes I change it into murottil mp3 or mp3 of someone read quran without tartil when I feel miss my home or feel very religious atmosphere.

I love the lyrics of jason mraz songs. "Please Don't Tell Her", "The Remedy", "Im yours", "Geek in the Pink", or "Clockwatching", or some other lyrics. I think he write his songs by himself, in case it shows his conditions. he is still single like my, old as single like me, he was born in 1979 or 1977 I forget the detail, I think he is introvert just like me, he is not quite confidence for doing relationship just in lyrics in above songs, he said that "she is taller than I am", and he said that he is a geek just like as the title.

Friday, March 20, 2009

Getting Limit Query from Hibernate

This is a short note continuing older note about creating google wannabe paging, in case I want to write a note but Im not telling you yet how I create my own paging completely.

There are many ways how to get limited query in hibernate, there are HQL (Hibernate Query Language), Criterion, or native sql. I will tell you with the first way the HQL way. For me HQL is simply SQL using hibernate POJO (Plain Old Java Object), the object representative of tables. For example if the table named LOG_ACTIVITY the POJO could be named LogActivity. if the SQL looks like: "SELECT * FROM LOG_ACTIVITY", the HQL could simply looks like: "FROM LogActivity", and it has more functions.

In this note Im not only telling you about getting limitation records from 1 to 100, but also parameterized, such as getting records from yesterday to now only the first 100 records.
1. Get the searching criteria. The default value is "*". For example field username, if there is a value from the input such as "imam" then the username="imam", otherwise username="*"
2. Count the total record,
3. Have a constant of how many records shown in every page, for example 10, and it can parameterized also.
4. I divide total record with that constant so I get the total of pages
5. I do query with the same syntax when I search the count of the total records (the syntax I move into an own method), but this time is for getting the records not the count.
6. I pass all of the variables (page, totalPages, listPages, perPage, totRecord,
recordList, qName, qDate, etc etc)
- which page =page requested, foe example page 13
- totalPage for example 5
- listPages, so the values are: 11, 12, 13, 14, 15
- perPage, how many records shown in every page
- totRecord, because it will be shown in my application
- recordList
- qName, qDate, and other question as search parameter that saved in a session.

Anyway this is the code snipped, the first method to get the count of the record, the second is to get the actual records, while buildQueryString is method that resulting hql syntax with parameter criteria=names of the searching fields such as username, dateForm, dateTo, and the second parameter is question the values of the searching fields, I set "*" if null or empty.

public Long getLogActivitiesSearchingPagingCount(String criteria, String
question) {
String queryString = "select count(*) " + buildQueryString(criteria, question);
Long total = (Long) getSession().createQuery(queryString).uniqueResult();

return total;
}

public List getLogActivitiesSearchingPaging(int start, int length, String
criteria, String question) {
List logActivities = getSession().createQuery(buildQueryString(criteria, question))
.setFirstResult(start)
.setMaxResults(length).list();
return logActivities;
}

Monday, March 16, 2009

Creating google wannabe paging

As my several notes that copied to my blog, I will write a note again and then Ill copy to blog again although its a java theme, in case I think there are reader from facebook rather than from blogspot. And especially my blog is already long time don't have a java post.

Yesterday in milist Java User Group-Indonesia, there is a member asked about how to create paging list in java-application. I face the same problem in my first project in balicamp. I cannot find component that fetch query with limitation. Displaytag component select all records and then view it page by page as user needed. While valulist donot use hibernate, data framework that shoud be standard as java application. I will make the select in other post, but now I want to show you ho to make google paging mine version.

If you were googling, there will be list of paging if the result is a lot, such as: Previous 1 2 3 4 5 6 7 8 9 10 Next. It's easy not as scared as we saw it in google. it's only playing with some if and else in jsp with some of parameters.

Im a spring guy, spring is one kind of a framework that needed in building java application, and it playing class called controller, in easy word, we have a controller for each page we make. we need 3 parameters (information) for a controller for our paging:
1. page, the page that user request, for example is 5
2. totalPages, total of the pages, get from select count / perPage, which is perPage is total record every page.
for example total record = 100, perPage 10 record, so totalPages = 10
3. listPages, list pages that shown.
for example we viewing 5 pages, ther listPages is 3 4 5 6 7,

Meanwhile in the jsp the algorithm such as below:
1. if page != 1 then print First, anchor to page=1
2. print every value of listPages, if equals with the requested page, then no anchor needed, otherwise anchor to the page
3. if totalPage != 0 and requested page != total
3. jika totalPage != 0 dan page yg direquest != totalPages then print Last, anchor to the last page.
the result for our example is First 3 4 5 6 7 Last.

write all of that step into separated jsp file, we only need to include as we need it, we put it above our table.

As compare with google, google used 20 list of pages if the record is a lot. we already have the similar with google, unless if also set listPages size 20 same as google, and the page is 5 for example we print 20 pages from 1 to 20, while google only print 10 page. As far the page is below 10 google show only 10 page.

The other different is google print Previous and Next, while mine prints First and Last, and FYI, I prefer mine ^_^, I think it also applicable for other than java, because it's an algorithm not language-based, thank you for reading & have a nice try!!

Monday, March 9, 2009

Spent holiday as usual

Today is the third day of me being idle at home in jakarta, same as usual workers from other town, I rent a room near office in a house, big house in case it contains twenty rooms for rent beside rooms for the owner, the owner contains parents and three children. It quit expensive for me for the room, but in case many of my office friends living in the same house, so I never search other place for moving.

Last two days I spent times with sleeping a lot and watching tv a bit. I watch tv in a kind of living room, with friends, I watch the program that choosen by them. Last night I watch serie A between Milan and Atalanta. only the second half, in case I went to the tv room in 10pm because I cannot sleep. It's been so long time for me for wathing footbal again. and watch tv also, I so rarely watch it since working here.

the last score was 3 - 0 for milan, all of the goals made by philippo inzaghi, the first goal made in the first half, wich is Im not watch yet. the others is ofcourse made in the last half, with normally without diving in case he is fame of with doing unfair action AFAIK.

Nowadays milan is full of a stars, many of them are old but still great players, beside philippo inzaghi, milan has andrey shevchenco which is not quite showing good performance in his only for about ten minuites play. and the it has david beckham which still give precission ball passing, and then andrea pirlo with his energic stamina as usual, and also abiatti as goal keeper. and as the young gun it has pato which is sometimes try to make a goal but fails again and again. And also I saw kaka as supporter, which is not played perhaps his still injured. Nice personality of kaka with his formal dress, I think he has potentiality to be a celebrity same as beckam. And also I saw victoria, becham's wife supporting milan.

One thing I want to say is, in the last minuite, very very last minuite beckham was changed by new young innocent player which if Im not wrong heard is from uruguay. and the funny thing is after he entered the field the game is over, then he turn out the field as other player did, he only smiling. I think that just the scenario, how to sell beckham, footbal, and the country of that young player, the beckham replacer. yes, that is my opinion, they want to sell and shows to us the mega-shining the world of celebrity-football so we want to be in there also, at least dream of it.

rrrggh.. btw after finishing the serie a match, I saw metro tv, it's the "zona 80an", only for perhaps ten minuites, because the show already started on 10 pm in which I still watch for milan, the show as the title is about the 80 stuff, in last night episode, it invite the indonesian 80s movie stars. There is Rano karno, Paramitha Rusadie, Yessie Gusman, Rico Tampati, Ita Mustafa, and one again that I don remember.

They were adorable, rano is sometimes told a joke to the audience or the yessie gusman, when they were asked by audience in the ask-answer session about how far they'we near in relation between in the 80 era in case both of them involved in many movies such as galih and ratna ? hwehehe, i think everybody loves the movie. Rano said that Yesy should answer that question because the question is too hard for him because it ask about two think that different, far and near, and then yessy said that both of them are far from eye near in heart.

today is maulud nabi holiday, im not working now, but after saturday and sunday I spent in home, I go to office today for internet. Actually last night I told by my mother to read solawat a hundred times for maulud and already did it last night. Anyway thanks for reading if you're still read this note ^_^