private void setSelectedModel(final IModel<Node> model) { selectedModel = model; onSelect(isValidSelection(model)); if (settings.isLastVisitedEnabled() && model != null) { lastModelVisited = model; } }
/** * Try to determine which model should be used as initial selection. First, retrieve the model that represents the * actual selected node and see if it is valid. If so, select it and return, if not, see if a last visited model * is set and if so select it and return. If not, see if a default model is set, if so, select it and return. If * not, fallback to the model currently in the selectionModelReference. * * TODO: We should try and see if the last-visited model is visible in the browser, if not, go on to default model **/ public void initSelection() { final IModel<Node> initialModel = getInitialModel(); if (isValidSelection(initialModel)) { selectionModelReference.setModel(initialModel); return; } if (settings.isLastVisitedEnabled() && lastModelVisited != null) { selectionModelReference.setModel(lastModelVisited); return; } final IModel<Node> defaultModel = getBaseModel(); if (defaultModel != null) { selectionModelReference.setModel(defaultModel); return; } setSelectedModel(selectionModelReference.getModel()); }