/** * Gets the selected indices out of the UI component if it is a collection * component (table, list, ...). More accurately, the selected indices are * taken from the view connector that adapts the UI component to the Jspresso * binding architecture. * * @param context * the action context. * @return the selected indices stored in the action context. */ protected int[] getSelectedIndices(Map<String, Object> context) { return getSelectedIndices(null, context); }
/** * Gets the selected indices out of the UI component if it is a collection * component (table, list, ...). More accurately, the selected indices are * taken from the view connector that adapts the UI component to the Jspresso * binding architecture. * * @param viewPermId * the view permId to search for. The view hierarchy is climed to the top and then a chid view with the searched * permId is recursively searched. * @param context * the action context. * @return the selected indices stored in the action context. */ protected int[] getSelectedIndicesFromPermId(String viewPermId, Map<String, Object> context) { int[] viewPathFromPermId = ViewHelper.getViewPathFromPermId(viewPermId, getView(context)); return getSelectedIndices(viewPathFromPermId, context); }
if (modelConnector instanceof ICollectionConnector) { models = new ArrayList<>(); int[] selectedIndices = getSelectedIndices(viewPath, context); if (selectedIndices != null && selectedIndices.length > 0) { for (int selectedIndice : selectedIndices) {
/** * Gets the model connector this action was triggered on following a model path described as a dotted string. * * @param modelPath * the model path to follow as a dotted string. * @param context * the action context. * @return the model connector this action was triggered on. */ protected IValueConnector getModelConnector(String modelPath, Map<String, Object> context) { IValueConnector modelConnector = getModelConnector(context); if (modelConnector instanceof ICollectionConnectorProvider) { int[] selectedIndices = getSelectedIndices(context); if (selectedIndices.length > 0) { modelConnector = ((ICollectionConnectorProvider) modelConnector).getCollectionConnector().getChildConnector( selectedIndices[0]); } } if (modelConnector != null) { if (modelPath != null) { String[] modelSteps = modelPath.split("\\."); for (String modelStep : modelSteps) { modelConnector = ((ICompositeValueConnector) modelConnector).getChildConnector(modelStep); } } return modelConnector; } return null; }