com.jfw.web.util
Class RequestUtils

java.lang.Object
  extended by com.jfw.web.util.RequestUtils

public final class RequestUtils
extends java.lang.Object

Implements methods for manage request parameters. All methods are static and thread safe.


Field Summary
static java.lang.String PARAMETERS_KEY
          The key to use for add the HashMap with the request parameters in an other HashMap (the one defined in JFWAction.myExecute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.struts.action.ActionMessages, java.util.HashMap)).
 
Constructor Summary
RequestUtils()
           
 
Method Summary
static java.lang.Object getValue(javax.servlet.http.HttpServletRequest request, java.lang.String name, java.lang.Object defaultValue)
          Get the value of parameter.
static void setGzipFilter(javax.servlet.http.HttpServletRequest request, boolean filter)
          Set attribute gzip in request.
static void setParameters(javax.servlet.http.HttpServletRequest request, java.util.HashMap outputData, java.lang.String[] exclude)
          Add directly in outputData all the requests parameters.
static void setParametersList(javax.servlet.http.HttpServletRequest request, java.util.HashMap outputData, java.lang.String[] exclude)
          Add in outputData, under key PARAMETERS_KEY, all the requests parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAMETERS_KEY

public static final java.lang.String PARAMETERS_KEY
The key to use for add the HashMap with the request parameters in an other HashMap (the one defined in JFWAction.myExecute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.struts.action.ActionMessages, java.util.HashMap)).

See Also:
Constant Field Values
Constructor Detail

RequestUtils

public RequestUtils()
Method Detail

getValue

public static java.lang.Object getValue(javax.servlet.http.HttpServletRequest request,
                                        java.lang.String name,
                                        java.lang.Object defaultValue)
Get the value of parameter.

Parameters:
request - an HttpServletRequest object.
name - parameter name.
defaultValue - the default value if parameter not found in request.
Returns:
  1. a String, if parameter exist and has only one value.
  2. a String[], if parameter exist and has more values.
  3. defaultValue, if parameter not found in request

setParametersList

public static void setParametersList(javax.servlet.http.HttpServletRequest request,
                                     java.util.HashMap outputData,
                                     java.lang.String[] exclude)
Add in outputData, under key PARAMETERS_KEY, all the requests parameters. If some parameters must be excluded then exclude must contain the names of that parameters.

Example of use in a jsp
 <%@ taglib uri="/WEB-INF/mytaglib.tld" prefix="mtl" %>
 
 ...
 
  <form name="mainform">
  <mtl:generic>
    <?repeat input_parameters?>
      <input type="hidden" name="<?name?>" value="<?value?>">
    </repeat>
  </mtl:generic>
  </form>
 

Parameters:
request - an HttpServletRequest object.
outputData - the HashMap defined in JFWAction.myExecute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.struts.action.ActionMessages, java.util.HashMap).
exclude - the names of parameters to exclude.

setParameters

public static void setParameters(javax.servlet.http.HttpServletRequest request,
                                 java.util.HashMap outputData,
                                 java.lang.String[] exclude)
Add directly in outputData all the requests parameters. If some parameters must be excluded then exclude must contain the names of that parameters.

Example of use in a jsp
 <%@ taglib uri="/WEB-INF/mytaglib.tld" prefix="mtl" %>
 
 ...
 
  <form name="mainform">
  <mtl:generic>
    <input type="hidden" name="PARAMETER_NAME_1" value="<?PARAMETER_NAME_1?>">
    <input type="hidden" name="PARAMETER_NAME_2" value="<?PARAMETER_NAME_2?>">
  </mtl:generic>
  </form>
 

Parameters:
request - an HttpServletRequest object.
outputData - the HashMap defined in JFWAction.myExecute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.struts.action.ActionMessages, java.util.HashMap).
exclude - the names of parameters to exclude.

setGzipFilter

public static void setGzipFilter(javax.servlet.http.HttpServletRequest request,
                                 boolean filter)
Set attribute gzip in request.

Parameters:
request - an HttpServletRequest object.
filter - a boolean with the value to set.