-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi, I have a SELECTBOX for loading Value/Text types of data. when i delete a selected item, the refresh code works fine. However, if i delete another item in the same dropdown immediately, the same refresh code throws "null pointer exception". any help would be appreciated.
In the below code, "model.getSelection();" throws that error. Model still holds values at this point.
ZUL <selectbox id="mfrListbox" model="${$composer.mfrModel}" >="" <template="" name="model"> ${each.text} </template> </selectbox>
@Listen("onClick=button#btnDelMfr")
public void DelMfr() throws SQLException {
Header sHeader = new Header();
sHeader.setManufacturer(getStringValue("mfrListbox", mfrModel));
HardwareDb hardwareDb = new HardwareDb();
hardwareDb.DelMfr(sHeader);
RefreshManufacturer();
}
String getStringValue(String componentId, ListModelList<socketheader.valuetype> model) {
Set<SocketHeader.ValueType> types = model.getSelection();
SocketHeader.ValueType type = types.iterator().next();
return type.getValue();
}
Hi Darksu,
Actually, there is a function being called right after delete is executed. Yes, it does refresh the mrfModel.
private void RefreshManufacturer() throws SQLException {
mfrListbox.setModel(new ListModelList<SocketHeader.ValueType>(getManufacturer()));
mfrModel = new ListModelList<SocketHeader.ValueType>(getManufacturer());
}
Here is my test case.
Lets say there are 10 values loaded initially into the SELECT BOX. First, I DELETED Item 9 from the dropdown and refreshed the drop down. Now, the drop down has 9 values which is correct. Next, I deleted Item 8 again and then calling the same code. This time, model.getSelection() returns size = 0. It is suppose to return Item 8. why it is failing?
The sync up between model and listbox should be reversed in order to work. This resolved my issue.
private void RefreshManufacturer() throws SQLException {
mfrModel = new ListModelList<socketheader.valuetype>(getManufacturer());
mfrListbox.setModel(mfrModel);
}
Asked: 2016-01-02 19:42:17 +0800
Seen: 17 times
Last updated: Jan 06 '16
Problem binding values to a composite component
How to access static member field of a class in zul without zscript
How can i load a constant in .zul
MVVM Validator: class not found ? [closed]
MVVM tab box - delay @load until tab pane displayed?
mvvm, load or save with after or before for seach command
how to fire an event when a variable value loaded through VM
is there any event trigger from zk component on binding ?
ZK team plans to dispose of Composer EventQueues no longer in scope? [closed]