List of usage examples for org.springframework.web.servlet.support RequestContextUtils getInputFlashMap
@SuppressWarnings("unchecked") @Nullable public static Map<String, ?> getInputFlashMap(HttpServletRequest request)
From source file:org.kuali.rice.krad.uif.lifecycle.ViewLifecycleRefreshBuild.java
@Override public void run() { View view = ViewLifecycle.getView(); UifFormBase form = (UifFormBase) ViewLifecycle.getModel(); HttpServletRequest request = ViewLifecycle.getRequest(); String flashMapSelectedLineValues = ""; if (RequestContextUtils.getInputFlashMap(request) != null) { flashMapSelectedLineValues = (String) RequestContextUtils.getInputFlashMap(request) .get(UifParameters.SELECTED_LINE_VALUES); }/* ww w.j av a 2 s.co m*/ String refreshCallerType = ""; if (request.getParameterMap().containsKey(KRADConstants.REFRESH_CALLER_TYPE)) { refreshCallerType = request.getParameter(KRADConstants.REFRESH_CALLER_TYPE); } // process multi-value lookup returns if (StringUtils.equals(refreshCallerType, UifConstants.RefreshCallerTypes.MULTI_VALUE_LOOKUP)) { String lookupCollectionName = ""; if (request.getParameterMap().containsKey(UifParameters.LOOKUP_COLLECTION_NAME)) { lookupCollectionName = request.getParameter(UifParameters.LOOKUP_COLLECTION_NAME); } String lookupCollectionId = ""; if (request.getParameterMap().containsKey(UifParameters.LOOKUP_COLLECTION_ID)) { lookupCollectionId = request.getParameter(UifParameters.LOOKUP_COLLECTION_ID); } if (StringUtils.isBlank(lookupCollectionName)) { throw new RuntimeException( "Lookup collection name is required for processing multi-value lookup results"); } String multiValueReturnFields = ""; if (request.getParameterMap().containsKey(UifParameters.MULIT_VALUE_RETURN_FILEDS)) { multiValueReturnFields = request.getParameter(UifParameters.MULIT_VALUE_RETURN_FILEDS); } String selectedLineValues = ""; if (request.getParameterMap().containsKey(UifParameters.SELECTED_LINE_VALUES)) { selectedLineValues = request.getParameter(UifParameters.SELECTED_LINE_VALUES); } if (!StringUtils.isBlank(flashMapSelectedLineValues)) { selectedLineValues = flashMapSelectedLineValues; } // invoked view helper to populate the collection from lookup results ViewLifecycle.getHelper().processMultipleValueLookupResults(form, lookupCollectionId, lookupCollectionName, multiValueReturnFields, selectedLineValues); } // refresh references if (request.getParameterMap().containsKey(KRADConstants.REFERENCES_TO_REFRESH)) { String referencesToRefresh = request.getParameter(KRADConstants.REFERENCES_TO_REFRESH); ViewLifecycle.getHelper().refreshReferences(referencesToRefresh); } // set focus and jump position for returning from a quickfinder // check and invoke callback method if (request.getParameterMap().containsKey(UifParameters.QUICKFINDER_ID)) { String quickfinderId = request.getParameter(UifParameters.QUICKFINDER_ID); String focusId = (String) form.getViewPostMetadata().getComponentPostData(quickfinderId, UifConstants.PostMetadata.QUICKFINDER_FOCUS_ID); if (StringUtils.isNotBlank(focusId)) { form.setFocusId(focusId); } String jumpToId = (String) form.getViewPostMetadata().getComponentPostData(quickfinderId, UifConstants.PostMetadata.QUICKFINDER_JUMP_TO_ID); if (StringUtils.isNotBlank(jumpToId)) { form.setJumpToId(jumpToId); } // check for callback method and invoke it if present String callbackMethodToCall = (String) form.getViewPostMetadata().getComponentPostData(quickfinderId, UifConstants.PostMetadata.QUICKFINDER_CALLBACK_METHOD_TO_CALL); MethodInvokerConfig callbackMethod = (MethodInvokerConfig) form.getViewPostMetadata() .getComponentPostData(quickfinderId, UifConstants.PostMetadata.QUICKFINDER_CALLBACK_METHOD); if (StringUtils.isNotBlank(callbackMethodToCall) || callbackMethod != null) { // if the callbackMethod is not set, then we set it if (callbackMethod == null) { callbackMethod = new MethodInvokerConfig(); } // get additional parameters to be passed to the callback method Map<String, String> callbackContext = (Map<String, String>) form.getViewPostMetadata() .getComponentPostData(quickfinderId, UifConstants.PostMetadata.QUICKFINDER_CALLBACK_CONTEXT); // if target class or object not set, use view helper service if ((callbackMethod.getTargetClass() == null) && (callbackMethod.getTargetObject() == null)) { callbackMethod.setTargetObject(ViewLifecycle.getHelper()); } callbackMethod.setTargetMethod(callbackMethodToCall); Object[] arguments = new Object[3]; arguments[0] = form; arguments[1] = quickfinderId; arguments[2] = callbackContext; callbackMethod.setArguments(arguments); // invoke callback method try { callbackMethod.prepare(); Class<?> methodReturnType = callbackMethod.getPreparedMethod().getReturnType(); if (StringUtils.equals("void", methodReturnType.getName())) { callbackMethod.invoke(); } else { // TODO : can the return type be anything else other than void? if so, what? } } catch (Exception e) { throw new RuntimeException("Error invoking callback method for quickfinder: " + quickfinderId, e); } } } }
From source file:org.kuali.rice.krad.web.service.impl.RefreshControllerServiceImpl.java
/** * Handles the return from a multi-value lookup, processing any select line values and invoking the * configured view helper service to create the lines for those values in the model collection. * * <p>There are two supported strategies for returning the selected lines. One, if the lookup view * and the caller are within the same application container, Springs input flash map is used. If however, * the lookup view is outside the caller, then just a standard request parameter is used.</p> * * @param form form instance containing the model data * @param request http request object being handled *//* w w w . j ava 2 s . c o m*/ protected void processMultiValueReturn(final UifFormBase form, HttpServletRequest request) { final String lookupCollectionId = request.getParameter(UifParameters.LOOKUP_COLLECTION_ID); final String lookupCollectionName = request.getParameter(UifParameters.LOOKUP_COLLECTION_NAME); if (StringUtils.isBlank(lookupCollectionName)) { throw new RuntimeException( "Lookup collection name is required for processing multi-value lookup results"); } final String multiValueReturnFields = request.getParameter(UifParameters.MULIT_VALUE_RETURN_FILEDS); String selectedLineValuesParam = request.getParameter(UifParameters.SELECTED_LINE_VALUES); String flashMapSelectedLineValues = ""; if (RequestContextUtils.getInputFlashMap(request) != null) { flashMapSelectedLineValues = (String) RequestContextUtils.getInputFlashMap(request) .get(UifParameters.SELECTED_LINE_VALUES); } if (!StringUtils.isBlank(flashMapSelectedLineValues)) { selectedLineValuesParam = flashMapSelectedLineValues; } final String selectedLineValues = selectedLineValuesParam; Runnable runnable = new Runnable() { @Override public void run() { // invoked view helper to populate the collection from lookup results ViewLifecycle.getHelper().processMultipleValueLookupResults(form, lookupCollectionId, lookupCollectionName, multiValueReturnFields, selectedLineValues); } }; ViewLifecycle.encapsulateLifecycle(form.getView(), form, form.getViewPostMetadata(), null, request, runnable); }
From source file:sg.ncl.MainController.java
@RequestMapping(value = "/signup2", method = RequestMethod.GET) public String signup2(Model model, HttpServletRequest request) { Map<String, ?> inputFlashMap = RequestContextUtils.getInputFlashMap(request); if (inputFlashMap != null) { log.debug((String) inputFlashMap.get(MESSAGE)); model.addAttribute(SIGNUP_MERGED_FORM, (SignUpMergedForm) inputFlashMap.get(SIGNUP_MERGED_FORM)); } else {//from w w w . j a v a 2 s . c om log.debug("InputFlashMap is null"); model.addAttribute(SIGNUP_MERGED_FORM, new SignUpMergedForm()); } return SIGNUP_PAGE; }