[RSS]

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:

  1. In the Navigator window, double-click on RequestnBean1 to open it in the Java editor.
  2. Under the constructor public class RequestBean1 extends AbstractRequestBean, declare the property. For example
    private java.util.Date timestamp;
  3. Fix imports if necessary by pressing Ctrl+Shift+I.
  4. Right-click in the Java Editor and select Refactor > Encapsulate Fields.
  5. 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.
  6. Make sure that variable declarations and field visibility are private and accessor visibility public.
  7. Click Refactor.

These steps are the same for session bean and application bean properties.