VwpFAQAddremoveButtons

How do I change labels on Add Remove Component's buttons (Add, Remove, Add All, Remove All, Move Up, Move Down) to something else?

There are two ways to do this:

  • Create a button facet in the Add remove component
  • Modify the theme.


For the first way here is a sample:

1. drag a add removelist onto the designer
2. Edit the jsp to look like this:

      <ui:addRemove availableItemsLabel="Available:" binding="#{Page1.addRemoveList1}" id="addRemoveList1" items="#{Page1.addRemoveList1DefaultOptions.options}" moveButtons="true" selectAll="true" selected="#{Page1.addRemoveList1DefaultOptions.selectedValue}" selectedItemsLabel="Selected:" style="left: 24px; top: 24px; position: absolute">
         <f:facet name="addButton">
            <ui:button id="myAddButton" onClick="document.getElementById('form:addRemoveList1').add()" text="My Add"/>
          </f:facet>
      </ui:addRemove>


3. deploy/run
4. select an item and press the "My Add" button. The internal javascript gets called to add the item.

When the AddRemove component is rendered, a DOM object corresponding to the component is created. To manipulate the component on the client side, you can call functions on the DOM object. To add elements on the available list, call document.getElementById(id).add() where "id" is the DOM id of the AddRemove element. Javascript functions used to support Add Remove functionality are:

add()
addAll()
remove()
removeAll()
moveUp()
moveDown()

Note: When overriding functionality via a facet, buttons may not be en/disabled automatically. This functionality depends on specific button IDs (e.g., AddRemove.ADD_BUTTON_ID) used in JavaScript. Please see the AddRemove component for all public constants, but be careful not to hard code these IDs anywhere. (If the constant value changes, functionality may break.) Ideally, the custom button ID should be set using an EL expression or component binding.

The second way requires that you modify the themes. You can view these posts for information on modifying themes: Project Woodstock Theme Documenation.

The default button lables are:

AddRemove.add=Add
AddRemove.remove=Remove
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