changing value of UIComponent in Program

I have a backing bean in which there is a private HtmlOutputText firstName component. In the constructor of the backing class I am trying to set its value as given below

private HtmlOutputText firstName;

public EmployeeOutput() {

firstName.setValue("Jatin");

}

This is giving me the following exception

Can't instantiate class: java.lang.NullPointerException

What is wrong with the above code ?

[444 byte] By [Jatin_Kulkarnia] at [2007-11-26 17:12:24]
# 1

A NullPointerException simply means that the related object is still null and therefore you cannot invoke actions on it.

The solution is very simple:

if (someObject == null) {

someObject = new SomeObject();

}

someObject.invokeAction();

Or just initialize it right in the property field:private SomeObject someObject = new SomeObject();

Then you don't need to do a null check.

I would say, please restart reading some Java tutorials or do some courses. This is really basic Java knowledge ;)

BalusCa at 2007-7-8 23:40:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
I am a bit coufused about the creating new object(in this context). When I processed my input JSF page, I don't create any objects for HtmlInputText, still I was able to access its value(bound to JSP page).
Jatin_Kulkarnia at 2007-7-8 23:40:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
You're trying to use this object in the constructor of the bean before the JSF lifecycle have initialized it for you by the setter of this object.
BalusCa at 2007-7-8 23:40:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...