jQuery in Action, 3rd edition
The moose likes JSF and the fly likes Bean Value is always Null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Bean Value is always Null" Watch "Bean Value is always Null" New topic

Bean Value is always Null

Omar Barrera

Joined: Aug 17, 2005
Posts: 15
Hello All,

I am new to JSF and am having an issue with a selectonemenu component always being null. I have form that is is populated with backing bean list that has the states. On the form the list displays properly. However when I attempt to write the value to the database, I get a null value.

Backing bean with list:

jsp view page:

selectedState method:
Nat Dickstein

Joined: Feb 26, 2005
Posts: 4
Hello Omar,
it seems that states_ isn't null, maybe you instatiated it and it is empty? Check for (states_!= && states_.size() < 1)
Omar Barrera

Joined: Aug 17, 2005
Posts: 15
What I noticed in my code is that I initialized state_ to null. So I corrected that and am now getting another error. The error I am getting is Caused by: java.lang.NoSuchMethodError:

Here is a copy of the class I am using:

When I am calling the getSelectedState method from the bean I am getting
Caused by: java.lang.NoSuchMethodError: stateBean.getState()Ljava/lang/String;

Caused by: javax.faces.FacesException: Error calling action method of component with id _idJsp0Pluto_264_:SaveButton
at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
at javax.faces.component.UICommand.broadcast(UICommand.java:109)
at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
at org.apache.myfaces.portlet.MyFacesGenericPortlet.processAction(MyFacesGenericPortlet.java:246)
... 38 more
Caused by: javax.faces.el.EvaluationException: Exception while invoking expression #{databaseHandler.InsertApplicant}
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:156)
at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:61)
... 45 more
[ July 07, 2008: Message edited by: Omar Barrera ]
Omar Barrera

Joined: Aug 17, 2005
Posts: 15
I was able to get my code to run partially correct. However I am still having an issue binding the selectonemenu item that is selected from the jsp view to the information in the bean. Again, forgive my ignorance as I am new to JSF, 1st project btw, but I thought if used the value element in the selectonemenu component tag, then the value the user selects would be bound by the get and set methods of the underlying bean.

I agree. Here's the link: http://aspose.com/file-tools
subject: Bean Value is always Null
It's not a secret anymore!