There is a multi select data bean (psdi.webclient.system.beans.MultiselectDataBean) exists in Maximo. It is actually used everywhere where you expected to select multiple rows from a list. However, the way it is implemented sometimes make users surprised. The most obvious problem that users complain about – is that whenever a filter is applied to the list – all currently existing selections in the dialog are lost:
I understand, that per maximo design, setting a filter for the list forces reset of the current MboSet, so the existing selection cannot be kept. So, when users want to add e.g. several different types of materials into the work order plans, have to invoke the “select materials” dialog several times and each time specify a different filter for the materials.
In order to make our users a bit happier we implemented a REALLY multiselect data bean class that remembers all the selections done in the dialog regardless of how many times the filter was changed. You can extend this class to write your own implementation or simply use this class as is for your multi select databeans:
package com.iba.ism.tc.ui.beans; import java.rmi.RemoteException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Vector; import psdi.mbo.MboRemote; import psdi.util.MXException; import psdi.webclient.system.beans.MultiselectDataBean; import psdi.webclient.system.controller.WebClientEvent; public class KSMultiselectDataBean extends MultiselectDataBean { List<Long> uids; /* * This method is called when a new filter is applied for the dialog's MboSet. It is overridden in order to * save the existing selection. * @see psdi.webclient.system.beans.DataBean#reset() */ @Override public void reset() throws MXException { try { saveCurrentSelection(); } catch (RemoteException e) { handleRemoteException(e); } super.reset(); } @Override protected void initialize() throws MXException, RemoteException { uids = new ArrayList<Long>(); super.initialize(); } /* * This method is called whenever an event is generated in the dialog (e.g. OK button is pressed). It is * overridden in order to merge all previously saved selections and reset the resulting MboSet accordingly. * @see psdi.webclient.system.beans.MultiselectDataBean#callMethod(psdi.webclient.system.controller.WebClientEvent) */ @Override public int callMethod(WebClientEvent event) throws MXException { mergeAllSelections(); return super.callMethod(event); } /* * The method saves the UID's of all Mbo's selected in the dialog */ private void saveCurrentSelection() throws RemoteException, MXException { Vector<MboRemote> selection = mboSetRemote.getSelection(); Iterator<MboRemote> i = selection.iterator(); while(i.hasNext()) { MboRemote selected = i.next(); long id = selected.getUniqueIDValue(); uids.add(new Long(id)); } } /* * This method resets the DataBean's MboSet to include only selected Mbo's */ private void mergeAllSelections() throws MXException { try { saveCurrentSelection(); /*=== Generate a new WHERE clause to include all UID's of previously selected MBO's ===*/ String uidName = mboSetRemote.getZombie().getUniqueIDName(); StringBuffer resultSelectionWhere = new StringBuffer(); resultSelectionWhere.append(uidName+" in ("); Iterator<Long> iUids = uids.iterator(); boolean hasAnySelection = false; while (iUids.hasNext()) { hasAnySelection = true; long uid = iUids.next(); resultSelectionWhere.append("'"+uid+"',"); } if(hasAnySelection) { resultSelectionWhere.setCharAt(resultSelectionWhere.length()-1, ')'); resetQbe(); // Qbe must be reset, because something could have been entered in the filter mboSetRemote.setWhere(resultSelectionWhere.toString()); mboSetRemote.reset(); /*=== All Mbo's in the set must be selected, like if we have done it manually ===*/ for(MboRemote mbo = mboSetRemote.moveFirst();mbo != null; mbo = mboSetRemote.moveNext()) { mbo.select(); } } } catch (RemoteException e) { handleRemoteException(e); } } }