Could not disable the preview button of a combo box.

Could not disable the preview button of a combo box.

book

Article ID: KB0075793

calendar_today

Updated On:

Products Versions
TIBCO EBX All supported versions.

Description

Problem

When trying to disable the preview button of a combo box in the DMA, or with UIComboBox.setPreviewButtonDisplayable(false), the button is still displayed.

Explanation

This is a known limitation of combo boxes. The preview button is not deactivable when the editor is disabled for that field.

The editor is disabled in three cases:

  • When it has been explicitly disabled programmatically or through the DMA
  • When the field is displayed in a table view
  • In a form, when the field is Read-Only

A bug report about this subject exists, but it is not planned in the product roadmap because it requires heavy changes.

Bug reference: #CP-5222

Issue/Introduction

Could not disable the preview button of a combo box.

Resolution

Solution

The workaround consists of implementing a custom widget that will write the raw value of the foreign key label in the context in which you want to disable the preview button.

Example: Disable the preview button in the context of a table view.

Here is the implementation of the write() method of the UISimpleCustomWidget:

MyCustomWidget.java
public void write(WidgetWriter writer, WidgetDisplayContext context) {
 
   if (context.isDisplayedInTable()) { // If the widget is displayed in the context of a table view
 
      ValueContext valueContext = context.getValueContext();
      Object value = valueContext.getValue();                // Get the field value from the ValueContext
      String label = context.displayOccurrence(value, true); // Retrieve the label
      writer.add(label); // Write the label
 
   else writer.addWidget(Path.SELF); // In other cases, display the default widget (combo box)
}

Additional Information

https://docs.tibco.com/pub/ebx/5.9.8/doc/html/en/Java_API/com/orchestranetworks/ui/form/widget/UIWidgetFactory.html
https://docs.tibco.com/pub/ebx/5.9.8/doc/html/en/Java_API/com/orchestranetworks/ui/form/widget/UISimpleCustomWidget.html
https://docs.tibco.com/pub/ebx/5.9.8/doc/html/en/Java_API/com/orchestranetworks/ui/form/widget/WidgetDisplayContext.html#isDisplayedInForm--
https://docs.tibco.com/pub/ebx/5.9.8/doc/html/en/Java_API/com/orchestranetworks/ui/form/widget/WidgetDisplayContext.html#isDisplayedInTable--