/** * This is a utility method which is able to retrieve the view this action has * been executed on from its context. It uses well-known context keys of the * action context which are: * <ul> * <li> {@code ActionContextConstants.VIEW} to get the the view the action * executes on. * </ul> * <p> * The returned view mainly serves for acting on the view component the action * has to be triggered on. * * @param <T> * type inference return. * @param context * the action context. * @return the view this action was triggered on. */ protected <T> IView<T> getView(Map<String, Object> context) { return getView(null, context); }
/** * This is a utility method which is able to retrieve the view connector this * action has been executed on from its context. It uses well-known context * keys of the action context which are: * <ul> * <li> {@code ActionContextConstants.VIEW_CONNECTOR} to get the the view * value connector the action executes on. * </ul> * <p> * The returned connector mainly serves for acting on the view component the * action has to be triggered on. * * @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 value connector this action was triggered on. */ protected IValueConnector getViewConnectorFromPermId(String viewPermId, Map<String, Object> context) { int[] viewPathFromPermId = ViewHelper.getViewPathFromPermId(viewPermId, getView(context)); return getViewConnector(viewPathFromPermId, context); }
/** * This is a utility method which is able to retrieve the view this action has * been executed on from its context. It uses well-known context keys of the * action context which are: * <ul> * <li> {@code ActionContextConstants.VIEW} to get the the view the action * executes on. * </ul> * <p> * The returned view mainly serves for acting on the view component the action * has to be triggered on. * * @param <T> * type inference return. * @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 view this action was triggered on. */ @SuppressWarnings("unchecked") protected <T> IView<T> getViewFromPermId(String viewPermId, Map<String, Object> context) { int[] viewPathFromPermId = ViewHelper.getViewPathFromPermId(viewPermId, getView(context)); return getView(viewPathFromPermId, context); }
return (IValueConnector) context.get(ActionContextConstants.VIEW_CONNECTOR); IView<?> view = getView(viewPath, context); if (view != null) { return view.getConnector();
/** * Gets the model descriptor this action was triggered on. * * @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 model connector this action was triggered on. */ protected IModelDescriptor getModelDescriptorFromPermId(String viewPermId, Map<String, Object> context) { int[] viewPathFromPermId = ViewHelper.getViewPathFromPermId(viewPermId, getView(context)); return getModelDescriptor(viewPathFromPermId, 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); }
/** * Retrieves the selected models indices out of the model connector if it's a * collection connector and set them as selected indices in the action * context. * * @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 selectedModels * the list of models to select in the view connector. * @param context * the action context. */ protected void setSelectedModelsFromPermId(String viewPermId, Collection<?> selectedModels, Map<String, Object> context) { int[] viewPathFromPermId = ViewHelper.getViewPathFromPermId(viewPermId, getView(context)); setSelectedModels(viewPathFromPermId, selectedModels, context); }
/** * This is a versatile helper method that retrieves the selected models model * either from the selected child connectors if the action was triggered on a * collection connector or from the connector itself. * * @param <T> * type inference return. * @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 list of selected models. */ protected <T> List<T> getSelectedModelsFromPermId(String viewPermId, Map<String, Object> context) { int[] viewPathFromPermId = ViewHelper.getViewPathFromPermId(viewPermId, getView(context)); return getSelectedModels(viewPathFromPermId, context); }
/** * Gets the model this action was triggered on. * * @param <T> * type inference return. * @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 model. */ protected <T> T getModelFromPermId(String viewPermId, Map<String, Object> context) { int[] viewPathFromPermId = ViewHelper.getViewPathFromPermId(viewPermId, getView(context)); return getModel(viewPathFromPermId, context); }
/** * This is a versatile helper method that retrieves the selected model either * from the 1st selected child connector if the action was triggered on a * collection connector or from the connector itself. * * @param <T> * type inference return. * @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 model. */ protected <T> T getSelectedModelFromPermId(String viewPermId, Map<String, Object> context) { int[] viewPathFromPermId = ViewHelper.getViewPathFromPermId(viewPermId, getView(context)); return getSelectedModel(viewPathFromPermId, context); }
/** * Sets the selected indices of the UI component if it is a collection * component (table, list, ...). More accurately, the selected indices are set * to 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 selectedIndices * the selected indices to store in the action context. * @param context * the action context. */ protected void setSelectedIndicesFromPermId(String viewPermId, int[] selectedIndices, Map<String, Object> context) { int[] viewPathFromPermId = ViewHelper.getViewPathFromPermId(viewPermId, getView(context)); setSelectedIndices(viewPathFromPermId, selectedIndices, context); }
/** * Gets the model connector this action was triggered on. The model connector * is the versatile binding structure that adapts the actual model to the * Jspresso binding architecture. The actual model is stored in the model * connector value. Unless developing very generic actions, this method will * rarely be used in favor of the more concrete {@code getXXXModel} * context accessors. * * @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 model connector this action was triggered on. */ protected IValueConnector getModelConnectorFromPermId(String viewPermId, Map<String, Object> context) { int[] viewPathFromPermId = ViewHelper.getViewPathFromPermId(viewPermId, getView(context)); return getModelConnector(viewPathFromPermId, context); }