Wednesday Mar 12, 2008

Remove unused binding attribute from VisualWeb JSF pages

Prior to NetBeans IDE 6.0 release VisualWeb Pages use to generate a binding attribute in the tag for every component in the page.

For example, when a Grid Panel was dropped on Page1, the following tag was automatically generated in the Page1.jsp file:

<h:panelGrid binding="#{Page1.gridPanel1}" id="gridPanel1" style="height: 96px; left: 24px; top: 24px; position: absolute; width: 96px"/>

and the following field, getter and setter was generated in the Page1.java file:

    private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel1() {
        return gridPanel1;
    }

    public void setGridPanel1(HtmlPanelGrid hpg) {
        this.gridPanel1 = hpg;
    }

This was good if you wanted to access the gridPane1 component programmatically. Otherwise it only served to bloat the .jsp and .java files. Therefore starting with NetBeans IDE 6.1 (M1+) release we decided to not generate the binding attribute automatically. Instead you can add and remove the binding attribute (and the corresponding field, getter and setter) by invoking the action in the component's pop up menu. For details, see the mini spec - On-demand binding attribute .

All this is well and good for projects developed using the NetBeans 6.1 (M1+) IDE and later. However the projects developed prior to NetBeanse 6.1 (M1+) IDE, do not benefit from this feature. That is where the new module - Remove unused binding attributes from VisualWeb JSF Pages comes for the rescue. This module installs the action - Remove unused binding attributes in the VisualWeb JSF Pages' in the projects pop up menu. When the action is invoked it shows a confirmation dialog:

Confirm Removing Binding Attributes Dialog 

Once you confirms the action, the unused binding attributes (and the corresponding field, getter and setter in the backing page bean) are removed from all the VisualWeb JSF pages in the VisualWeb project. The output window shows the processing messages. For example:

Removing unused binding attributes for components in the VisualWeb JSF Pages in the Project '/..../NetBeansProjects/WebApplication1'...
Modeling...
Modeling...Done
Processing '.../NetBeansProjects/WebApplication15/web/Page1.jsp'
:
:
:
Removed unused binding attribute for the component 'gridPanel1'.
:
:
:
Processing '.../NetBeansProjects/WebApplication15/web/Page1.jsp' Done

Processing '.../NetBeansProjects/WebApplication15/web/Page2.jsp'
:
:
Processing '.../NetBeansProjects/WebApplication15/web/Page2.jsp' Done
Processing '.../NetBeansProjects/WebApplication15/web/Page3.jsp'
:
:
Processing '.../NetBeansProjects/WebApplication15/web/Page3.jsp' Done
Removing unused binding attributes for components in the VisualWeb JSF Pages in the Project '/.../NetBeansProjects/WebApplication1'...Done

The process may take some time depending on the number of VisualWeb JSF pages in your project.

Please make sure you have backed up your project before you invoke the action. For best results invoke the action as soon as you open the project. Aftre you have processed all you projects you can remove the module by using Tools:Plugin action.

The module is available on the NetBeans 6.1 Beta Update center:

http://updates.netbeans.org/netbeans/updates/6.1/uc/beta/beta/catalog.xml.gz

You can configure the update center in the Tools:Plugins:Setting tab. NetBeans 6.1 Beta IDE is required to use this module.

Please send us your feedback here.

After processing, your project will become lean and mean, VisualWeb machine :)

About

sandipchitale

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today