List of usage examples for org.apache.wicket.markup.html.list ListView getDefaultModelObject
public final Object getDefaultModelObject()
From source file:org.cipango.ims.hss.web.serviceprofile.EditIfcsPage.java
License:Apache License
@SuppressWarnings("unchecked") private void apply(AjaxRequestTarget target, Form<?> form1, Action action) { AbstractChoice available = (AbstractChoice) form1.get("available"); AbstractChoice used = (AbstractChoice) form1.get("used"); AbstractChoice shared = (AbstractChoice) form1.get("shared"); Iterator it;/*from ww w .ja v a 2 s. c om*/ List choosen; switch (action) { case ADD_TO_IFC: case ADD_TO_SHARED: it = ((List) available.getDefaultModelObject()).iterator(); choosen = available.getChoices(); break; case MOVE_TO_SHARED: case REMOVE_FROM_IFC: it = ((List) used.getDefaultModelObject()).iterator(); choosen = used.getChoices(); break; case MOVE_TO_IFC: case REMOVE_FROM_SHARED: it = ((List) shared.getDefaultModelObject()).iterator(); choosen = shared.getChoices(); break; default: throw new IllegalStateException("Unknown action " + action); } ServiceProfile profile = _dao.findById(_key); ListView ifcs = (ListView) getPage().get("contextMenu:ifcs"); Collection<String> contextModel = (Collection<String>) ifcs.getDefaultModelObject(); while (it.hasNext()) { String ifcName = (String) it.next(); InitialFilterCriteria ifc = _ifcDao.findById(ifcName); try { switch (action) { case ADD_TO_IFC: profile.addIfc(ifc, false); used.getChoices().add(ifcName); contextModel.add(ifcName); break; case ADD_TO_SHARED: profile.addIfc(ifc, true); shared.getChoices().add(ifcName); contextModel.add(ifcName); break; case MOVE_TO_IFC: profile.moveIfc(ifc, false); used.getChoices().add(ifcName); break; case MOVE_TO_SHARED: profile.moveIfc(ifc, true); shared.getChoices().add(ifcName); break; case REMOVE_FROM_IFC: case REMOVE_FROM_SHARED: _dao.unlink(profile, ifc); contextModel.remove(ifcName); available.getChoices().add(ifcName); break; default: break; } choosen.remove(ifcName); } catch (HssException e) { error(e.getMessage()); } it.remove(); } _dao.save(profile); getCxManager().profileUpdated(profile); if (target != null) { target.addComponent(form1); target.addComponent(getPage().get("feedback")); target.addComponent(getPage().get("contextMenu")); target.addComponent(getPage().get("pprPanel").setVisible(true)); } }