OnDemandBindingAttribute

On-demand binding attribute

Background

Up until NetBeans 6.1, the VW requires that every component tag in the VW JSP page have the binding attribute which is bound using a value binding expression to a property of the backing page bean. For example  :

  • Page1.jsp
:
:
                        <webuijsf:button binding="#{Page1.button1}" id="button1" style="left: 23px; top: 72px; position: absolute" text="Button"/>
:
:
  • Page1.java
:
:
    private Button button1 = new Button();

    public Button getButton1() {
        return button1;
    }

    public void setButton1(Button b) {
        this.button1 = b;
    }
:
:

This is done in anticipation that the user may want to script the component instance in Java code. In terms of implementation, this mechanism is used to create hierarchy of DesignBean that parallels the JSP structure.

This has several issues associated with it though:

  • The binding attribute is not a mandatory attribute according to JSF Specs. Therefore the user may not want the binding attribute if they are not planning to script the component in Java code.
  • The current scheme blindly enforces the binding attribute even for the components which are most likely to be not ever scripted in the Java code e.g. TableRowGroup components. This creates a bloated backing bean Java file - especially if the page has several complex components like Table or Tree. In fact when the backing bean Java file size gets over a certain size (1M) the NetBeans Java editor infrastructure warns about it.
  • If the user deletes the binding attribute by hand, current implementation inserts a new component tag back into the JSP code and at a wrong place at that.

For all the above reasons mandatory requirement to have the binding attribute will be replaced by on demand management of the binding attribute management.

Functional Specs

  • The new page and page fragment templates will not have binding' attributes in the JSP file and the corresponding properties in the Java file.
  • The VW will not try to force insert a new component tag if the binding attribute is removed from the JSP source.
  • The user will be able to manage the insertion and removal of binding attribute the following actions:
  • Add binding attribute - this action will be shown if the component tag does not have the binding attribute. Invoking this action will add the binding attribute in JSP source and corresponding property to the backing bean Java source (if needed).
  • Remove binding attribute - this action will be shown if the component tag does have the binding attribute. Invoking this action will remove the binding attribute in JSP source and corresponding property from the backing bean Java source (if needed). Before the actual removal happens there are three scenarios that need to be handled correctly:
  1. There is only the binding attribute in the JSP and the corresponding field, getter and a setter in the Java source. In this scenario the binding, field, getter and setter will be removed silently.
  2. In addition to the binding attribute in the JSP and the corresponding field, getter and a setter in the Java source there is(are) a property set(s) (persisted) in the _init() method. In this scenario the user will be warned that removing the binding, field, getter, setter and the property set(s) in the _init() method will reset the value of those properties to default value. If the user still wants to proceed the previously mentioned artifacts will be removed.
  3. In addtion to the above if there is any other usage of the binding, the user will be asked to clean up that usage. Only after that the user will be able to proceed with binding removal. The usage may be in the form of field, getter, setter access in Java code or a binding expression like "#{Page1.component1. ...}" etc in Java or JSP code.

Both actions will support the Undo/Redo as long as the user is working in the Designer/Outline. The actions labels will be I18Ned and A11Yed.

These actions will be shown in the popup menu's of

  • componet's node in Outline window
  • selected component in the Designer
  • when no component is selected the actions will apply to the form(?) component.

With this approach the projects from prior releases should also work.

Test Cases

  • No binding attr in JSP - add the binding attribute in JSP and , field, getter and setter in Java.
  • Binding attr in JSP and field, getter, setter in Java - remove the binding attribute in JSP and , field, getter and setter in Java.
  • Binding attr in JSP, field, getter, setter and property set(s) in _init() method in Java
  • Warn user of property reset to default value. If the user insists - proceed and remove the binding attribute in JSP and , field, getter and setter and property set(s) in Java. Otherwise do nothing.
  • If there are other usages of the binding - tell the user to first clean up those usages and do nothing.
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo