Hello Isomorphic.
I have a question for you. We have a selectItem with a picklist, paged, having filter. The problem we face is that we want to set some value to this item. Unfortunately this works perfectly only in case this record is already loaded into selectItem. In case picklist is on some page which does not have the record we try to set calling getSelectedRecord() returns null. This can be illustrated in showcase example MultiFieldSearchSample, changing the getViewPanel to following:
HLayout result = new HLayout();
DataSource supplyItemDS = ItemSupplyXmlDS.getInstance();
final DynamicForm form = new DynamicForm();
form.setWidth(500);
form.setNumCols(4);
ListGrid pickListProperties = new ListGrid();
pickListProperties.setShowFilterEditor(true);
ListGridField skuField = new ListGridField("SKU");
ListGridField itemNameField = new ListGridField("itemName");
final SelectItem filteredSelect = new SelectItem("filteredSelect");
filteredSelect.setTitle("Item (Select)");
filteredSelect.setOptionDataSource(supplyItemDS);
filteredSelect.setDisplayField("SKU");
filteredSelect.setValueField("SKU");
filteredSelect.setPickListWidth(300);
filteredSelect.setPickListFields(skuField, itemNameField);
filteredSelect.setPickListProperties(pickListProperties);
ComboBoxItem filteredCombo = new ComboBoxItem();
filteredCombo.setTitle("Item (ComboBox)");
filteredCombo.setAddUnknownValues(false);
filteredCombo.setOptionDataSource(supplyItemDS);
filteredCombo.setDisplayField("itemName");
filteredCombo.setValueField("SKU");
filteredCombo.setPickListWidth(300);
filteredCombo.setFilterFields("SKU", "itemName");
filteredCombo.setPickListFields(skuField, itemNameField);
Button button = new Button("fill");
button.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
filteredSelect.setValue("32706605");
}
});
Button sbutton = new Button("show");
sbutton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
SC.warn(filteredSelect.getSelectedRecord().toString());
}
});
form.setItems(filteredSelect, filteredCombo);
result.addMembers(form, button, sbutton);
return result;
Clicking first button will set the value to the item, which looks good. Clicking on second button throws null pointer exception, because getSelectedRecord() returns null.
Is this an expected behavior? Or is there any way we can force item to load the page with corresponding record and return it when we call getSelectedRecord?
Thanks in advance for your support.
Best regards,
Iaroslav
I have a question for you. We have a selectItem with a picklist, paged, having filter. The problem we face is that we want to set some value to this item. Unfortunately this works perfectly only in case this record is already loaded into selectItem. In case picklist is on some page which does not have the record we try to set calling getSelectedRecord() returns null. This can be illustrated in showcase example MultiFieldSearchSample, changing the getViewPanel to following:
HLayout result = new HLayout();
DataSource supplyItemDS = ItemSupplyXmlDS.getInstance();
final DynamicForm form = new DynamicForm();
form.setWidth(500);
form.setNumCols(4);
ListGrid pickListProperties = new ListGrid();
pickListProperties.setShowFilterEditor(true);
ListGridField skuField = new ListGridField("SKU");
ListGridField itemNameField = new ListGridField("itemName");
final SelectItem filteredSelect = new SelectItem("filteredSelect");
filteredSelect.setTitle("Item (Select)");
filteredSelect.setOptionDataSource(supplyItemDS);
filteredSelect.setDisplayField("SKU");
filteredSelect.setValueField("SKU");
filteredSelect.setPickListWidth(300);
filteredSelect.setPickListFields(skuField, itemNameField);
filteredSelect.setPickListProperties(pickListProperties);
ComboBoxItem filteredCombo = new ComboBoxItem();
filteredCombo.setTitle("Item (ComboBox)");
filteredCombo.setAddUnknownValues(false);
filteredCombo.setOptionDataSource(supplyItemDS);
filteredCombo.setDisplayField("itemName");
filteredCombo.setValueField("SKU");
filteredCombo.setPickListWidth(300);
filteredCombo.setFilterFields("SKU", "itemName");
filteredCombo.setPickListFields(skuField, itemNameField);
Button button = new Button("fill");
button.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
filteredSelect.setValue("32706605");
}
});
Button sbutton = new Button("show");
sbutton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
SC.warn(filteredSelect.getSelectedRecord().toString());
}
});
form.setItems(filteredSelect, filteredCombo);
result.addMembers(form, button, sbutton);
return result;
Clicking first button will set the value to the item, which looks good. Clicking on second button throws null pointer exception, because getSelectedRecord() returns null.
Is this an expected behavior? Or is there any way we can force item to load the page with corresponding record and return it when we call getSelectedRecord?
Thanks in advance for your support.
Best regards,
Iaroslav
Comment