aspose file tools*
The moose likes JSF and the fly likes Problem with managed beans in Netbeans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Problem with managed beans in Netbeans" Watch "Problem with managed beans in Netbeans" New topic
Author

Problem with managed beans in Netbeans

Jesus Schneider
Greenhorn

Joined: Oct 17, 2012
Posts: 28
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

Joined: Jun 25, 2001
Posts: 16055
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Jesus Schneider
Greenhorn

Joined: Oct 17, 2012
Posts: 28
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

Joined: Oct 17, 2012
Posts: 28
Long-term scope = session or application for example???
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16055
    
  21

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

Joined: Oct 17, 2012
Posts: 28
I know that, but it's the only explanation I find to the behavior I describe above...
Does anyone find another reason?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with managed beans in Netbeans