This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSF and the fly likes Setting bean value problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Setting bean value problem" Watch "Setting bean value problem" New topic
Author

Setting bean value problem

Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
Hi,
This mught be a very basic question. Don't know.

In my first page, I have a list of item to display to the user as below:
>

1. Of which fetches a list of items from the database to show a drop down list. And my config.xml is as below for the scope


2. Second item is a list from my config.xml as below:



3. Third item is just a inout box which is used to get the user inout and I have a validator to check for some specific formats.

As such I don't have problem in getting the values of what the user chooses and displying in the next page as well as I am updating a table in the database using hibernate.

Due to some special requirement, I am having some problem now.

Again let me repeat what I am displaying.

1. 1st item is a list (drop down)from a database as abc, def, hij and klm
2. 2nd item is a list (drop down) from my face-config.xml as extended and none
3. 3rd item is a input box.
4. I am using proper getter and setter methods to capture the values and sisplay in the next page as well as updating the database with respective values.

Now I want to check whether the item in the second value is (if the user chooses none from the drop down list) none and if it is so, I want to make the first and second value as none too.

I tried setting the values in the getter setter methods but it is throwing some exception as "null pointer exception" during database update.

For example as below:



How do I do it? Please let me know.
Joe Matthew
Ranch Hand

Joined: Jun 10, 2008
Posts: 66
You mentioned that the exception is thrown in the DB update section, so is the display of the first drop down correct?

Also, paste the exception log for us to analyze.


Regards,<br />Joe<br /> <br />"Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live."<br />--Martin Golding
Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
Hi Joe,
Thanks for your response.
The display of the list from the dabase is perfect. Update means, I am trying to get tehse three values and update into another table in the database.

Basically it is throwing "null pointer exception" Please let me know how to change the values of other two values depending upon the value the user chooses.

Regards
Joe Matthew
Ranch Hand

Joined: Jun 10, 2008
Posts: 66
I still did not get your issue. Are you trying to insert into the DB table when you get this error message?

Posting the exception log will go a long way to clear the confusion.
Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
Hi Joe,
Thanks. I will post the log on Monday.

My basic question is, I have three valus in a page. Sorry if my question is not clear for you.

1.Item1 is a drop down list from face-config.xml
2. Item2 is a drop down list from a database tableA
3. Inputbox.

Depending upon the value in the item2, I want to set the values for Item1 and Item2 and then finally save them in a database tabeB and also I want to display these values in the next page.

I tried using setter methods of UserBean and it is throwing exception. UserBean class contains getter and setter methods for Item1, Item2 and Item3 backing beans.

If the user chooses for example "non" for the Item2, the I want to make both Item1 and Item3 as "none".

I have no idea on how to do this. Please let me know. Thanks.
Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
Can anyone tell me how to manipulate the bean value(Item1 and Item3) depending upon item2 value. Because right now I am using only one Java class (UserBean) for all getter and setter methods for all tem1, item2 and item3. If I want to manipulate bean value as I mentioned earlier, where to set them? Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting bean value problem
 
Similar Threads
List box initialization through managed bean
Problem to populate a selectOneListbox from a Java-Bean
JSF backingbean value is null always.
how to navigate JSf form using value from h:selectOneRadio
Binding a selectOneMenu component to a managed bean