Wednesday, April 29, 2009

Trip@Bandung




Last weekend me and office mates had trip to bandung, we had great time spend everything together.

Friday night at 1 am, we went from office, in case we wait panji doing his work on uploading production, actually he plan to go in saturday morning and I will go with him because in that time many works to do. It's about 00.30 am, and I already from home to take some clothes so I went back to the office, and we wait for rahmat that also joining us after had futsal. We went by two cars, Anita's and Kamil's car. One is go to Hendri's home first to take some clothes, and one again went to Herman's home to take clothes and Nintendo Wii.

And then we meet again in alfamart for buy something like soap, bread, and beverage. We then change our sits in car, there are 16 people of us, I was in Kamil's car with Kamil, Rere, Herman, Erna, mas Roy, Rahmat and Danik. While Anita's car there were Eka, Iqbal, Anita, Yanti, Mulan, Meli, Panji, and Hendri. It's about 3 hours until we were in Bandung in vila Istana Bunga. So it's about 4 am. The place is on the hill, and its so cold.

I cannot sleep while Im in the car, after in the place also cannot sleep, in the morning we doing many things, some of us were playing wii, me and rahmat take a walk near the house, some of us trying to get sleep, some others just talk each other in the tv room. we wait until about 9 am to take a shower, there are three bathroom one is in the second floor, and the other is in the ground. and there four sleeping room, three is in second floor, and one is in the ground floor, each of them has double bed so it's fit all of us.

When the sun is rising most of us take a walk to get a lot of pictures with a lot of styles. and some others is locked in house for a nap. And then Eka and some others buy some meals for breakfast.

In the day we went to cihampelas (or some place like that with full of stores sorrounding), and then we lunch in mcD in there. I buy panas special, rice, slice of fried chicken, scrumbled egg and a glass of coke. And then we back home in the afternoon, some of us take a bath, but I did not, because I choose take nap because we gonna had trip in midnight and Im not take a sleep yet.

In about 7 pm, we go to kampung daun, a beautiful places with full of eating places. I bought fried banana cheese and hot tea and then we go to Brebes restaurant to buy chicken barbeque. And then we go to ciater, a place with warm water for soaking. We were in ciater in about 1 am, the place is open for 24 hours and the funny thing is it's peak hour is in the midnight.

We were back to home when dawn. we take sleep for tomorrow agenda, actually we had plenty of schedule in the last day, like visiting gedung sate and to strawberry garden, but the fact is we spent last day happily in home by play wii, or cards, or watching motoGP.

In the midle of the day we eat padang food, I eat chicken. and then we went home, in the middle of the way we stop in burengreng for eating batagor, and then we stop again in primarasa store to buy goodies, I buy a box of brownies, and I take it to the office in monday.

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!!