Pages

Friday, May 28, 2010

Tapestry 5 grid paging with hibernate

This is something that i expected to exist in tapestry. Since i "know" T5 from the first release, back then this class isn't available yet. So back then i created my own paging method with 2 additional action link above Tapestry Grid. 

But now its so easy. If you want to create paging for your grid, you just have to return the HibernateDataSource with the session and your class for your grid source parameter. Like this : 

return new HibernateGridDataSource(session, OrderForm.class);

Its something very simple. But when you're in the middle of something, sometimes its too easy to overcomplicate stuff (Not thinking straight, i previously implements my own GridDataSource for my hibernate class). Everything work out of the box (paging, sorting,etc)

Also the grid has a reset() method for reseting the Sort Ordering.


update : 


i found the easiest way to add default column sort for now is by implementing this method. 


@Component(id="orderGrid")
private Grid grid;


@SetupRender
void setDefaultSortOrder() {
if(grid.getSortModel().getSortConstraints().isEmpty()) {
// call it twice to make it desc ordered
grid.getSortModel().updateSort("orderDate");
grid.getSortModel().updateSort("orderDate");
}
} 


don't forget to reset the sort order to see the result.

Wednesday, May 26, 2010

I learn something new today :)

Thanks to geoff jumpstart, I finally learn how to protect tapestry page in a more 'classier' way. I've been meaning to learn this, but only able to do it now. The guide is here. The concept is very similar with me, only the the implementation differs.  While i'm using basic method of extending base page by their role. Jumpstart uses annotation, way cool :D

So now i'm trying to implement it using annotation. Its very straight forward actually, since the concept is very familiar. Even the autologin concept is very familiar. But of course he's doing it far better and classier than me and i think i will change it too :)

Jumpstart uses system properties to set the autologin properties, while I implement in the code. Since the system properties wouldn't be available when i deploy my apps to the server. I don't have to worry about forgetting to reset the autologin properties when i want to deploy my apps to the server.

To set the system properties in eclipse wtp, you just

  • go to the server window > right click > open 
  • in the bottom of general information > click open launch configuration
  • select the arguments tab, and in the vm argument box add
  • -Dmyapp.autologin="true"
  • restart your server
Cool and Classy :D

~FD

Monday, May 24, 2010

First experience with SQLLite

Well it more like the first problem i have with SQLLite in android. If you follow the notepad tutorial for android, you're going to think that this is like any regular database mapping in java. Especially for those of you that used to working with ORM such as hibernate.

When you want to add a second table naturally you'll create another class to handle that table. Well it turn out in SQLLite (in the SQLiteOpenHelper Constructor) if the database is already open, then it wont call the next onCreate() method. So your second table wouldn't be created.

this link explain it more throughly. To solve it you need to put the table creation in one place. The better approach is to open the db in a single class and pass around the handler to other class that actually handle the database functionality. That way you wont be stuck with one single file to handle the database (we're trying to stick with OOP principles here) :).

Another good link about DB/SQLLite handling in android is this link. This will tell you how to ship your android application with prebake database file.

~FD

Sunday, May 23, 2010

Second Milestone

Today is a second milestone for me. Its exactly 2 month since I quit my job. I'm a little behind, haven't release my second apps yet. But May isn't over, hopefully i can manage in this last few days.

Tuesday, May 18, 2010

Forget to create trunk folder in SVN

Another one about SVN. Since i'm a bit hurry when adding my project to my SVN repositories. I forgot to create the common directories (trunk, branch and tags). After my project is stable i decided to move the code to the proper directories before tagging it.

After quick i found a simple and effective way. Since I'm working on windows, i made a simple batch script for it. Beware it tested lightly, and I didn't tune it to be a generic script.

@echo off
set repo=http://localhost/svn/myProject
echo "Repository location " %repo%

echo "Creating SVNTemp directory"
del SVNTemp
mkdir SVNTemp

echo "Checking out source from repo"
svn checkout %repo% SVNTemp

echo "Creating trunk in repo"
svn mkdir %repo%/trunk -m "creating trunk"

cd SVNTemp
FOR /F %%a IN ('dir /b *') do (
echo "Moving %%a to trunk"
C:\Progra~1\Subversion\bin\svn.exe mv %%a trunk
)
svn commit -m "organizing to trunk"
cd ..
@echo on

Tuesday, May 11, 2010

1 Of 2 Fear

Udah lama emosi gw gak memuncak seperti ini. Dulu udah sering marah, berantem, capek. Jadi sekarang lebih milih diam aja , paling2 dibilang cuek abis. Tapi gak ada yang bakal sakit hati kena gw semprot, dan gw gak bakal uring2an berminggu2.

Tapi tanggal 9 dan 10 Mei ini nyokap memang bener2 keterlaluan. Tapi tetep aja gak bisa marah sama nyokap sendiri, gak mau nyakitin hati, but don't push me !

Saturday, May 8, 2010

The mystifying URL Encoding

I just found out about this things. I never really care about the difference between URL and URI. Whatever it is I just figured it will point to a resource somewhere in the internet. For all i know they can be used interchangeably, so far.

It turn out, when you're trying to generate your own URL programmatic-ally , it matters. One thing to know, that it encode space differently. URL will encode space into + as demand by html 4.0 specification. While with URI you can get the usual %20 character.

And what more annoying is this fact.  That you can't simply use URLEncoder to encode and decode URL, but you need to create a URI then execute the toURL() method.

Tapestry URL


Now something specific about tapestry. Since I'm creating an android client that will talk with tapestry server. I need to generate my own URL. In this URL fiasco it turn out that tapestry has its own URL Encoding policy. You can see the change in this jira. Tapestry substitute the '%' character with '$00'.

Luckily the you can get tapestry URLEncoder implementation from tapestry code. So i just use that class in my android app. And one problem solved.

Oh another thing i found out. Tapestry page isn't debug able with eclipse WTP. But the services are.

Cheers

~FD

Its not easy

Well, its not easy when you're always at home and people think that you're just wasting your saving money. Ditching out a well payed job and many opportunities.

Its not easy, especially when they didn't understand about your field of work. Hell, even some of the people in your line of work couldn't see as far as you and other see.

Its not easy. But at least I'm thankful that my parent never ever force their decision on me. Although they sometimes didn't understand why i do it. And sometimes brought up question that i couldn't answer at the moment. I could only smile, and hope they will see it at the end.

Its not easy. But this is my choice, and i will go through it no matter what happened.

Siapakah pengguna tapestry 5 di indonesia ?

Judul di atas adalah pertanyaan yang muncul di kepala saya saat ini. Semenjak dulu 'canggih tetapi susah' adalah sebuah paradigma yang melekat dengan Tapestry. Tadinya saya pikir dengan keluarnya tapestry 5 (T5) akhirnya tapestry akan bisa jadi booming. Mungkin bukan saya sendiri yang berpikir seperti itu, tetapi para pengguna tapestry yang lain juga berpikir seperti itu. Tapi pada kenyataanya hal itu tidak terjadi.

Hingga saat ini, dimana tapestry dengan versi 5.1.0.5 yang sudah cukup stabil. Ternyata labelnya tetap melekat. Saya sendiri harus mengakui belajar Tapestry itu tidak mudah, sampai sekarang pun masih seperti orang bego :D.

Tetapi ini juga yang membuat saya tidak bisa lepas dari T5, terutama disaat seperti sekarang. Dimana saya merasa perlu untuk mendalami satu hal secara serius. Tidak hanya belajar kulitnya saja seperti selama ini. Tapestry itu canggih, apalagi di T5, banyak konsep2 yang mendahului jamannya. Selain itu tapestry banyak 'memaksa' kita untuk menggunakan cara2 yang 'benar' dengan segala jenis design pattern yang perlu kita pelajari. Bukan sekedar framework hack and slash :)

Mungkin itu juga sebabnya tapestry begitu sulit untuk di kuasai. Tetapi bagi saya sendiri mempelajari T5 dengan baik menjadi begitu berharga. Banyak hal yang bisa saya pelajari, semakin kelihatan perbedaan keahlian dalam mendalami konsep java dan web setiap kali saya mempelajari sesuatu. Pengalaman ini suatu saat pasti akan menjadi begitu berharga.

Dan sekarang yang menjadi pertanyaan saya adalah. Apakah ada orang lain di indonesia yang memiliki pikiran yang sama dengan saya. Kalau seandainya ada komunitasnya betapa senangnya bisa saling bertukar pengetahuan sebagai pengguna T5.

I'm sure we can learn a lot :D

Cheers

Wednesday, May 5, 2010

Removing folder from SVN

Well, i haven't use SVN for a long time, so my memory is a bit lacking. I initially import all of my project to SVN, but I've forgotten some folder that should be excluded from the initial import. Such as generated bin files. And i want to remove it from SVN versioning.

The solution is pretty simple, you go to the folder that you didn't want to manage in windows explorer. Search for file and folder containing .svn, and don't forget to check search subdirectory, and search hidden file option. Sort by folder, delete all of the .svn folder.

Then go to eclipse, update your project. And then the bin  folder will have a question mark near it. Just right click add to svn:ignore. And you're finished. The bin folder wouldn't be managed by SVN any longer.

Update :
After migrating to eclipse galileo subclipse somehow treat this workaround  as un-ignored error. The better approach is to delete the folder from SVN Repositories View and check out the code again, and then add the folder to svn:ignore. The subclipse wiki explain in more detail.


~SD

Saturday, May 1, 2010

Color Harmony

Well, for someone like me who is color illiterate , this seems to be the perfect place to start. By learning it you make sure that the user that uses your web doesn't get a headache every time they uses your apps. :D

And this tool from Adobe is amazing :D

My SUN has set, its time to SEARCH for a new one :)

I wonder if the title is appropriate :D

Tepat 38 hari semenjak gw berhenti kerja kantoran. Yes, my SUN has set. Sebuah perusahaan yang punya begitu banyak inovasi dan penuh kultur keterbukaan. Untuk pindah dari kultur seperti ini ke kultur big O yang menomorsatukan sales number diatas semua hal, sepertinya bukanlah sebuah pilihan. Dan untungnya, gw bukan sendirian yang berpikir seperti ini. Bahkan JG pun memutuskan untuk berhenti.

In SEARCHing a new one,  sepertinya memang hanya perusahaan itu yang punya kultur mirip. Mendorong keterbukaan dan juga mendorong melakukan good things. Tetapi itu mungkin akan menjadi cerita di lain waktu.

Kembali ke gw, udah Mei saja :D. Tadinya mau menulis banyak hal, merayakan tepat satu bulan berhenti dengan menumpahkan pikiran dan angan-angan kedalam blog. Tapi gak jadi :) gak usah dipaksakan, pada waktunya nanti yang ingin ditulis pasti akan ditulis. Goodnewsnya waktu yg tadinya akan digunakan untuk menulis, dimanfaatkan untuk mengerjakan sesuatu yang lebih produktif.

Di awal-awal long vacation,  gw berhasil olahraga rutin, lari pagi untuk mengembalikan kondisi fisik. Masih keep kontak dengan teman2 kantor dengan main bulutangkis dan futsal. Tapi sayangnya karena cedera futsal dipertandingan lain di kampus, olahraga paginya terpaksa di stop dulu. Gw gak mau cedera ini jadi parah dan kambuhan.

I'm a lot happier, sholat lebih teratur, bisa Nemenin nyokap di rumah karena lagi gak ada pembantu buat nemenin. Banyak belajar ulang mengenai konsep-konsep di tapestry dan javascript yang selama ini belajar sambil lalu. Dan akhir pekan lalu, gw merelease aplikasi pertama gw di android.

Ternyata banyak hal dapat dilakukan dalam waktu satu bulan. Perbedaannya besar sekali melakukan hal yang lu bener-bener suka, dengan melakukan mundane job at the office. Ucapan terimakasih dari tiap-tiap orang yang menggunakan aplikasi lu benar2 terasa nikmatnya.

Tapi satu hal yang benar-benar gw pahamin. Dalam keadaan seperti ini, dukungan dari teman dan komunitas benar-benar terasa manfaatnya. Disaat ragu dan bimbang tentang apa yang kita kerjakan, would it matter ? A nudge in the shoulder and a little push really2 meant a lot.

So whats next ?

Gw berencana untuk tetap fokus di hal yang gw kerjakan saat ini. Belajar lebih jauh tentang android, memperbaiki aplikasi gw, dan mudah2an me-release aplikasi ke dua gw di android di bulan ini. Wish me luck :D