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