Dot.Nut

Sunday, October 30, 2005

A label for my thoughts...

In asp.net, it was common to have a label web control somewhere in my page that i will update upon performing some server action (eg update to db, delete a record, etc)... all i had to do was do it on my button click event, etc, like:

protected void Button_Click(Object obj, EventArgs e) {
// some action to update
myLabel.Text = "Some action performed!";
}


and it works all the time. yippee. fast and simple.

In java server faces, there was also an equivalent (i think) in the form of a outputText face component. It also has a setValue() method to update its value. So it was natural for me to do the same in .net style, given my liking for .net:

public String Button_Action() {
// some action to update
myOutputText.setValue("Some action performed!");

return null;
}


problem is, this doesn't work in jsf all the time! Some pages work, some dun. It really took me a long time to figure out wat was wrong... such a simple thing i wanted to do, but there was no error, no exception, nothing to tell me wat went wrong...

Until i realize it was "standard" to attach something called an actionListener, that i should attach to the outputText tag, so that it will execute everytime some action occurs:

// in my jsp:
<h:outputtext id="myLabel" actionlistener="#{backingBean.myListener}" ...>

// in my backing bean
public void myListener(ActionEvent ae) {
myLabel.setValue("some action perform!");
}


then only can i get the status to be displayed correctly everytime! Does that mean i have to create 10 actionListeners for 10 different status messages??

Sunday, October 23, 2005

The back button!!

Our team is currently on a j2ee project with jsf using studio creator. Fun. Due to some mechanism with the "session" scope and "request" scope thingie, we often run into problems when the user navigates to a listing page, clicks on link A, goes to page A, then presses the back button to go back to listing page, clicks on link B, but still page A shows up!! It seems that the listing page has its request cached inside, so by pressing the back button on the browser and clicking on ANY link will result in the browser resubmitting the cached request! so what we have to do is to:

create a back button/link inside the page A that allows the browser to clear the cached request and create a new and correct request.

But: some pages do not come from just a single listing page! does that mean we have to create X links for X pages where page A comes from? no way!

New post! sorta...

I've decided to create another blog to complain about my projects, work and programming crap! esp my escapades with dot.net and hatred for j2ee! remember, its http://pchia.blogspot.com!

If you are not programming siao, or entered by mistake, go to my ChiaP blog instead! thats where i complain about life, love (huh?) and crap hahaha.