• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with managed beans in Netbeans

 
Jesus Schneider
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I was developing a JSF 2.1 application with Netbeans 7.2 and tried to code a simple selectOneMenu that loads its values in the constructor. Something like that:





It didn't work no matter what I did!! The constructor seemed as if didn't exist!! After several tests I made a NEW managed bean with the SAME CODE as above and... IT WORKED!!
The only explanation I find is that sometimes I COPY one managed bean in the file manager and RE-USE it, instead of making a new one with "New-JSF managed bean".
Is that posible?
Thanks in advance!
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just a general comment: if your development process is dependent on what IDE you're using, you're in trouble.

Regardless of what IDE you are using, however, you can run into this problem in at least 2 ways I can think of:

1. The bean has a long-term scope and you had erased the selectItem list at some point.

2. You didn't actually define the bean as a Managed bean and therefore there's not really a bean to get the options from.

You don't need a "setOptions" method, by the way. The SelectItem list is a read-only property.
 
Jesus Schneider
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your answer.
Regarding point 1: I don't know what a long-term scope is, but I'm sure that I didn't erase the list. The example I tested is as simple as you see in the code above.
About point 2: The bean HAS the "@ManagedBean" and the "@RequestScoped". Is there some hidden option inside the IDE to defines WHAT is a managed bean?
I tested plenty of things and finally it worked just creating a new one and copying the old code on it, so there must be something weird about the netbeans IDE I don't know. Some Kind of "managed bean editor"?
I'm just curious to know wether I'm right or not.
Some programmer with experience with netbeans?
 
Jesus Schneider
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Long-term scope = session or application for example???
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesus Schneider wrote: Is there some hidden option inside the IDE to defines WHAT is a managed bean?


The IDE won't be within 13000 kilometers of the webapp when the webapp runs in production. The IDE not only cannot determine how things like this work, it must not.
 
Jesus Schneider
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know that, but it's the only explanation I find to the behavior I describe above...
Does anyone find another reason?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic