I have a MasterDetailForm that contains a number of Composite Components and some basic components. When I first enter the form, all of the basic components are not enabled/editable, but all of my composite components are enabled/editable before I’ve chosen an entity to edit.
How can I make my composite components behave like the basic components?
I have included this code in my composite component, but it doesn’t appear to be enough:
@CompositeDescriptor("historyField-component.xml")
public class HistoryField
extends CompositeComponent<HBoxLayout>
implements Field<BigDecimal>,
CompositeWithCaption,
CompositeWithHtmlCaption,
CompositeWithHtmlDescription,
CompositeWithIcon,
CompositeWithContextHelp
{
My HistoryField is based on an HBoxLayout, which by itself does not implement Component.Edit. It’s the underlying fields that are editable.
@Override
public boolean isEditable() {
return historyField_valueField.isEditable();
}
@Override
public void setEditable(boolean editable) {
historyField_valueField.setEditable(editable);
historyField_historyBtn.setEnabled(editable);
}
@Override
public boolean isEnabled() {
return historyField_valueField.isEnabled();
}
@Override
public void setEnabled(boolean enabled) {
historyField_valueField.setEnabled(enabled);
historyField_historyBtn.setEnabled(enabled);
}
The MasterDetail XML contains:
<vbox id="editBox" height="100%" margin="false,false,false,true" expand="fieldGroupBox" spacing="true">
<scrollBox id="fieldGroupBox">
<form id="form" dataContainer="ordersourceDc">
<column width="250px">
<textField id="ordersourcecdField" property="ordersourcecd"/>
<textField id="descriptionField" property="description"/>
<lookupField id="sourcetypeField" property="sourcetype"/>
<app:historyField id="mailproccostField" property="mailproccost" field="osmailproccost"/>
<app:historyField id="callcentercostField" property="callcentercost" field="oscallcentercost" />
<app:historyField id="callcenterascostField" property="callcenterascost" field="oscallcenterascost" />
<app:historyField id="callcenterpctField" property="callcenterpct" field="oscallcenterpct" />
</column>
</form>
</scrollBox>
<hbox id="actionsPane" spacing="true" visible="false">
<button id="saveBtn" action="save"/>
<button id="cancelBtn" action="cancel"/>
</hbox>
</vbox>
The app:historyField items are my composite components.
I assume the problem is that my composite component is not listening to the EditableChangeEvent, but I can’t figure out how to make that happen.