How do I add properties to managed beans in NetBeans IDE 6.0?
In earlier NetBeans Visual Web Pack 5.5/5.5.1 and in Sun Java Studio Creator, you added properties by right-clicking the bean in the Outline window and choosing Add > Property.
In NB 6, you edit the bean's java code directly and then refactor the code to add getter and setter methods.
To add a property to a web application's RequestBean1 property:
- In the Navigator window, double-click on RequestnBean1 to open it in the Java editor.
- Under the constructor public class RequestBean1 extends AbstractRequestBean, declare the property. For example
private java.util.Date timestamp;
- Fix imports if necessary by pressing Ctrl+Shift+I.
- Right-click in the Java Editor and select Refactor > Encapsulate Fields.
- For properties with Read/Write access, check the boxes for creating both getter and setter methods. For read only properties, check only the box to create the getter method.
- Make sure that variable declarations and field visibility are private and accessor visibility public.
- Click Refactor.
These steps are the same for session bean and application bean properties.