Java Code Examples for org.springframework.web.util.WebUtils#hasSubmitParameter()
The following examples show how to use
org.springframework.web.util.WebUtils#hasSubmitParameter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractOverrideTabHandler.java From webcurator with Apache License 2.0 | 6 votes |
@Override public ModelAndView processOther(TabbedController tc, Tab currentTab, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { Overrideable o = overrideGetter.getOverrideable(req); ProfileCommand command = (ProfileCommand) comm; if(WebUtils.hasSubmitParameter(req, "delete")) { // Process the main tab. processTab(tc, currentTab, req, res, comm, errors); o.getProfileOverrides().getCredentials().remove((int)command.getCredentialToRemove()); TabbedModelAndView tmav = preProcessNextTab(tc, currentTab, req, res, comm, errors); tmav.getTabStatus().setCurrentTab(currentTab); return tmav; } return null; }
Example 2
Source File: TabbedController.java From webcurator with Apache License 2.0 | 6 votes |
/** * Override the bind and validate method to use the validate and command * objects defined by the tab, instead of those defined for the controller. * This allows us to have different command and validator classes per * handler. * * @param req * The HttpServletRequest object. * @param command * The Spring command object. * @param errors * The Spring errors object. * @throws Exception * on failure. */ @Override protected void onBindAndValidate(HttpServletRequest req, Object command, BindException errors) throws Exception { if (WebUtils.hasSubmitParameter(req, "_tab_current_page")) { String currentPage = req.getParameter("_tab_current_page"); Tab currentTab = tabConfig.getTabByID(currentPage); if (currentTab.getValidator() != null && !WebUtils.hasSubmitParameter(req, "_tab_cancel")) { currentTab.getValidator().validate(command, errors); } } else { if (defaultValidator != null && !WebUtils.hasSubmitParameter(req, "_tab_cancel")) { defaultValidator.validate(command, errors); } } }
Example 3
Source File: ServletAnnotationMappingUtils.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Check whether the given request matches the specified parameter conditions. * @param params the parameter conditions, following * {@link org.springframework.web.bind.annotation.RequestMapping#params() RequestMapping.#params()} * @param request the current HTTP request to check */ public static boolean checkParameters(String[] params, HttpServletRequest request) { if (!ObjectUtils.isEmpty(params)) { for (String param : params) { int separator = param.indexOf('='); if (separator == -1) { if (param.startsWith("!")) { if (WebUtils.hasSubmitParameter(request, param.substring(1))) { return false; } } else if (!WebUtils.hasSubmitParameter(request, param)) { return false; } } else { boolean negated = separator > 0 && param.charAt(separator - 1) == '!'; String key = !negated ? param.substring(0, separator) : param.substring(0, separator - 1); String value = param.substring(separator + 1); boolean match = value.equals(request.getParameter(key)); if (negated) { match = !match; } if (!match) { return false; } } } } return true; }
Example 4
Source File: ServletAnnotationMappingUtils.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Check whether the given request matches the specified parameter conditions. * @param params the parameter conditions, following * {@link org.springframework.web.bind.annotation.RequestMapping#params() RequestMapping.#params()} * @param request the current HTTP request to check */ public static boolean checkParameters(String[] params, HttpServletRequest request) { if (!ObjectUtils.isEmpty(params)) { for (String param : params) { int separator = param.indexOf('='); if (separator == -1) { if (param.startsWith("!")) { if (WebUtils.hasSubmitParameter(request, param.substring(1))) { return false; } } else if (!WebUtils.hasSubmitParameter(request, param)) { return false; } } else { boolean negated = separator > 0 && param.charAt(separator - 1) == '!'; String key = !negated ? param.substring(0, separator) : param.substring(0, separator - 1); String value = param.substring(separator + 1); boolean match = value.equals(request.getParameter(key)); if (negated) { match = !match; } if (!match) { return false; } } } } return true; }
Example 5
Source File: ParamsRequestCondition.java From java-technology-stack with MIT License | 4 votes |
@Override protected boolean matchName(HttpServletRequest request) { return (WebUtils.hasSubmitParameter(request, this.name) || request.getParameterMap().containsKey(this.name)); }
Example 6
Source File: ParameterMethodNameResolver.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public String getHandlerMethodName(HttpServletRequest request) throws NoSuchRequestHandlingMethodException { String methodName = null; // Check parameter names where the very existence of each parameter // means that a method of the same name should be invoked, if any. if (this.methodParamNames != null) { for (String candidate : this.methodParamNames) { if (WebUtils.hasSubmitParameter(request, candidate)) { methodName = candidate; if (logger.isDebugEnabled()) { logger.debug("Determined handler method '" + methodName + "' based on existence of explicit request parameter of same name"); } break; } } } // Check parameter whose value identifies the method to invoke, if any. if (methodName == null && this.paramName != null) { methodName = request.getParameter(this.paramName); if (methodName != null) { if (logger.isDebugEnabled()) { logger.debug("Determined handler method '" + methodName + "' based on value of request parameter '" + this.paramName + "'"); } } } if (methodName != null && this.logicalMappings != null) { // Resolve logical name into real method name, if appropriate. String originalName = methodName; methodName = this.logicalMappings.getProperty(methodName, methodName); if (logger.isDebugEnabled()) { logger.debug("Resolved method name '" + originalName + "' to handler method '" + methodName + "'"); } } if (methodName != null && !StringUtils.hasText(methodName)) { if (logger.isDebugEnabled()) { logger.debug("Method name '" + methodName + "' is empty: treating it as no method name found"); } methodName = null; } if (methodName == null) { if (this.defaultMethodName != null) { // No specific method resolved: use default method. methodName = this.defaultMethodName; if (logger.isDebugEnabled()) { logger.debug("Falling back to default handler method '" + this.defaultMethodName + "'"); } } else { // If resolution failed completely, throw an exception. throw new NoSuchRequestHandlingMethodException(request); } } return methodName; }
Example 7
Source File: ParamsRequestCondition.java From lams with GNU General Public License v2.0 | 4 votes |
@Override protected boolean matchName(HttpServletRequest request) { return WebUtils.hasSubmitParameter(request, this.name); }
Example 8
Source File: ParameterMethodNameResolver.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public String getHandlerMethodName(HttpServletRequest request) throws NoSuchRequestHandlingMethodException { String methodName = null; // Check parameter names where the very existence of each parameter // means that a method of the same name should be invoked, if any. if (this.methodParamNames != null) { for (String candidate : this.methodParamNames) { if (WebUtils.hasSubmitParameter(request, candidate)) { methodName = candidate; if (logger.isDebugEnabled()) { logger.debug("Determined handler method '" + methodName + "' based on existence of explicit request parameter of same name"); } break; } } } // Check parameter whose value identifies the method to invoke, if any. if (methodName == null && this.paramName != null) { methodName = request.getParameter(this.paramName); if (methodName != null) { if (logger.isDebugEnabled()) { logger.debug("Determined handler method '" + methodName + "' based on value of request parameter '" + this.paramName + "'"); } } } if (methodName != null && this.logicalMappings != null) { // Resolve logical name into real method name, if appropriate. String originalName = methodName; methodName = this.logicalMappings.getProperty(methodName, methodName); if (logger.isDebugEnabled()) { logger.debug("Resolved method name '" + originalName + "' to handler method '" + methodName + "'"); } } if (methodName != null && !StringUtils.hasText(methodName)) { if (logger.isDebugEnabled()) { logger.debug("Method name '" + methodName + "' is empty: treating it as no method name found"); } methodName = null; } if (methodName == null) { if (this.defaultMethodName != null) { // No specific method resolved: use default method. methodName = this.defaultMethodName; if (logger.isDebugEnabled()) { logger.debug("Falling back to default handler method '" + this.defaultMethodName + "'"); } } else { // If resolution failed completely, throw an exception. throw new NoSuchRequestHandlingMethodException(request); } } return methodName; }
Example 9
Source File: ParamsRequestCondition.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override protected boolean matchName(HttpServletRequest request) { return WebUtils.hasSubmitParameter(request, name); }
Example 10
Source File: TargetInstanceLogsHandler.java From webcurator with Apache License 2.0 | 4 votes |
public TabbedModelAndView preProcessNextTab(TabbedController tc, Tab nextTabID, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { // build mav stuff b4 displaying the tab TabbedModelAndView tmav = tc.new TabbedModelAndView(); Boolean editMode = false; TargetInstanceCommand cmd = null; TargetInstance ti = null; if (comm instanceof TargetInstanceCommand) { cmd = (TargetInstanceCommand) comm; if (cmd.getCmd().equals(TargetInstanceCommand.ACTION_EDIT)) { editMode = true; } } if (req.getSession().getAttribute(TargetInstanceCommand.SESSION_TI) == null) { ti = targetInstanceManager.getTargetInstance(cmd.getTargetInstanceId(), true); req.getSession().setAttribute(TargetInstanceCommand.SESSION_TI, ti); req.getSession().setAttribute(TargetInstanceCommand.SESSION_MODE, editMode); } else { // ensure that the session target instance id is consistent (it may not be if we've been directed straight to a specific tab) if (WebUtils.hasSubmitParameter(req, "targetInstanceOid")) { String targetInstanceOid = req.getParameter("targetInstanceOid"); Long targetInstanceId = Long.parseLong(targetInstanceOid); if (!((TargetInstance)req.getSession().getAttribute(TargetInstanceCommand.SESSION_TI)).getOid().equals(targetInstanceId)){ ti = targetInstanceManager.getTargetInstance(targetInstanceId, true); req.getSession().setAttribute(TargetInstanceCommand.SESSION_TI, ti); } } ti = (TargetInstance) req.getSession().getAttribute(TargetInstanceCommand.SESSION_TI); editMode = (Boolean) req.getSession().getAttribute(TargetInstanceCommand.SESSION_MODE); } TargetInstanceCommand populatedCommand = new TargetInstanceCommand(ti); if (editMode) { populatedCommand.setCmd(TargetInstanceCommand.ACTION_EDIT); } LogFilePropertiesDTO[] arrLogs = harvestCoordinator.listLogFileAttributes(ti); List<LogFilePropertiesDTO> logs = new ArrayList<LogFilePropertiesDTO>(); for(int i = 0; i < arrLogs.length; i++) { logs.add(arrLogs[i]); } tmav.addObject(TargetInstanceCommand.MDL_LOG_LIST, logs); tmav.addObject(Constants.GBL_CMD_DATA, populatedCommand); tmav.addObject(TargetInstanceCommand.MDL_INSTANCE, ti); return tmav; }