本文整理汇总了Java中org.apache.struts.util.RequestUtils类的典型用法代码示例。如果您正苦于以下问题:Java RequestUtils类的具体用法?Java RequestUtils怎么用?Java RequestUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RequestUtils类属于org.apache.struts.util包,在下文中一共展示了RequestUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getActionMessage
import org.apache.struts.util.RequestUtils; //导入依赖的package包/类
/**
* Gets the <code>ActionMessage</code> based on the
* <code>ValidatorAction</code> message and the <code>Field</code>'s
* arg objects.
* @param request the servlet request
* @param va Validator action
* @param field the validator Field
*/
public static ActionMessage getActionMessage(
HttpServletRequest request,
ValidatorAction va,
Field field) {
String args[] =
getArgs(
va.getName(),
getMessageResources(request),
RequestUtils.getUserLocale(request, null),
field);
String msg =
field.getMsg(va.getName()) != null
? field.getMsg(va.getName())
: va.getMsg();
return new ActionMessage(msg, args);
}
示例2: getActionError
import org.apache.struts.util.RequestUtils; //导入依赖的package包/类
/**
* Gets the <code>ActionError</code> based on the
* <code>ValidatorAction</code> message and the <code>Field</code>'s
* arg objects.
* @param request the servlet request
* @param va Validator action
* @param field the validator Field
* @deprecated Use getActionMessage() instead. This will be removed after
* Struts 1.2.
*/
public static ActionError getActionError(
HttpServletRequest request,
ValidatorAction va,
Field field) {
String args[] =
getArgs(
va.getName(),
getMessageResources(request),
RequestUtils.getUserLocale(request, null),
field);
String msg =
field.getMsg(va.getName()) != null
? field.getMsg(va.getName())
: va.getMsg();
return new ActionError(msg, args);
}
示例3: initFormBean
import org.apache.struts.util.RequestUtils; //导入依赖的package包/类
/**
* Locate or create the bean associated with our form.
* @throws JspException
* @since Struts 1.1
*/
protected void initFormBean() throws JspException {
int scope = PageContext.SESSION_SCOPE;
if ("request".equalsIgnoreCase(beanScope)) {
scope = PageContext.REQUEST_SCOPE;
}
Object bean = pageContext.getAttribute(beanName, scope);
if (bean == null) {
// New and improved - use the values from the action mapping
bean =
RequestUtils.createActionForm(
(HttpServletRequest) pageContext.getRequest(),
mapping,
moduleConfig,
servlet);
if (bean instanceof ActionForm) {
((ActionForm) bean).reset(mapping, (HttpServletRequest) pageContext.getRequest());
}
if (bean == null) {
throw new JspException(messages.getMessage("formTag.create", beanType));
}
pageContext.setAttribute(beanName, bean, scope);
}
pageContext.setAttribute(Constants.BEAN_KEY, bean, PageContext.REQUEST_SCOPE);
}
示例4: renderBaseElement
import org.apache.struts.util.RequestUtils; //导入依赖的package包/类
/**
* Render a fully formed HTML <base> element and return it as a String.
* @param scheme The scheme used in the url (ie. http or https).
* @param serverName
* @param port
* @param uri The portion of the url from the protocol name up to the query
* string.
* @return String An HTML <base> element.
* @since Struts 1.1
*/
protected String renderBaseElement(
String scheme,
String serverName,
int port,
String uri) {
StringBuffer tag = new StringBuffer("<base href=\"");
tag.append(RequestUtils.createServerUriStringBuffer(scheme,serverName,port,uri).toString());
tag.append("\"");
if (this.target != null) {
tag.append(" target=\"");
tag.append(this.target);
tag.append("\"");
}
if (TagUtils.getInstance().isXhtml(this.pageContext)) {
tag.append(" />");
} else {
tag.append(">");
}
return tag.toString();
}
示例5: createObject
import org.apache.struts.util.RequestUtils; //导入依赖的package包/类
public Object createObject(Attributes attributes) {
// Identify the name of the class to instantiate
String className = attributes.getValue("className");
if (className == null) {
ModuleConfig mc = (ModuleConfig) digester.peek();
className = mc.getActionFormBeanClass();
}
// Instantiate the new object and return it
Object actionFormBean = null;
try {
actionFormBean =
RequestUtils.applicationInstance(className);
} catch (Exception e) {
digester.getLogger().error(
"ActionFormBeanFactory.createObject: ", e);
}
return actionFormBean;
}
示例6: getBaseRef
import org.apache.struts.util.RequestUtils; //导入依赖的package包/类
/**
* Renders the reference for a HTML <base> element.
*/
public String getBaseRef() {
if (request == null)
return null;
StringBuffer result = RequestUtils.requestToServerStringBuffer(request);
String path = null;
if (forward == null)
path = request.getRequestURI();
else
path = request.getContextPath() + forward.getPath();
result.append(path);
return result.toString();
}
示例7: getMessage
import org.apache.struts.util.RequestUtils; //导入依赖的package包/类
/**
* Look up and return a message string, based on the specified parameters.
*
* @param key Message key to be looked up and returned
* @param args Replacement parameters for this message
*/
public String getMessage(String key, Object args[]) {
MessageResources resources = getMessageResources();
if (resources == null)
return null;
// Return the requested message
if (args == null)
return resources.getMessage(
RequestUtils.getUserLocale(request, null),
key);
else
return resources.getMessage(
RequestUtils.getUserLocale(request, null),
key,
args);
}
示例8: verifyActionMappingClass
import org.apache.struts.util.RequestUtils; //导入依赖的package包/类
/**
* <p>Return <code>true</code> if information returned by
* <code>config.getActionMappingClass</code> is all valid;
* otherwise, log error messages and return <code>false</code>.</p>
*/
protected boolean verifyActionMappingClass() {
String amcName = config.getActionMappingClass();
if (amcName == null) {
log(servlet.getInternal().getMessage
("verifyActionMappingClass.missing"));
return (false);
}
try {
Class amcClass = RequestUtils.applicationClass(amcName);
} catch (ClassNotFoundException e) {
log(servlet.getInternal().getMessage
("verifyActionMappingClass.invalid", amcName));
return (false);
}
return (true);
}
示例9: verifyPlugInConfigs
import org.apache.struts.util.RequestUtils; //导入依赖的package包/类
/**
* <p>Return <code>true</code> if information returned by
* <code>config.findPluginConfigs</code> is all valid;
* otherwise, log error messages and return <code>false</code>.</p>
*/
protected boolean verifyPlugInConfigs() {
boolean ok = true;
PlugInConfig pics[] = config.findPlugInConfigs();
for (int i = 0; i < pics.length; i++) {
String className = pics[i].getClassName();
if (className == null) {
log(servlet.getInternal().getMessage
("verifyPlugInConfigs.missing"));
ok = false;
} else {
try {
Class clazz = RequestUtils.applicationClass(className);
} catch (ClassNotFoundException e) {
log(servlet.getInternal().getMessage
("verifyPlugInConfigs.invalid", className));
ok = false;
}
}
}
return (ok);
}
示例10: getTramite
import org.apache.struts.util.RequestUtils; //导入依赖的package包/类
public TramiteEspecificado getTramite()
{
if ( tramite == null )
{
try
{
tramite = ( TramiteEspecificado ) RequestUtils.applicationInstance(tramiteClassName);
}
catch ( Throwable t )
{
log.error("No se ha podido crear el tramite ", t);
return null;
}
}
return tramite;
}
示例11: getValues
import org.apache.struts.util.RequestUtils; //导入依赖的package包/类
public Traducible getValues()
{
Traducible values = getTramite().getEspecificaciones();
if (values == null)
{
try
{
values = (Traducible) RequestUtils.applicationInstance(valuesClassName);
this.setValues( values );
} catch (Throwable t)
{
log.error("No se ha podido crear el value ", t);
return null;
}
}
return values;
}
示例12: initValidator
import org.apache.struts.util.RequestUtils; //导入依赖的package包/类
/**
* Initialize the <code>Validator</code> to perform validation.
*
* @param key The key that the validation rules are under (the
* form elements name attribute).
* @param bean The bean validation is being performed on.
* @param application servlet context
* @param request The current request object.
* @param errors The object any errors will be stored in.
* @param page This in conjunction with the page property of a
* <code>Field<code> can control the processing of
* fields. If the field's page is less than or equal
* to this page value, it will be processed.
*/
public static Validator initValidator(String key, Object bean,
ServletContext application, HttpServletRequest request,
ActionMessages errors, int page) {
ValidatorResources resources =
Resources.getValidatorResources(application, request);
Locale locale = RequestUtils.getUserLocale(request, null);
Validator validator = new Validator(resources, key);
validator.setUseContextClassLoader(true);
validator.setPage(page);
validator.setParameter(SERVLET_CONTEXT_PARAM, application);
validator.setParameter(HTTP_SERVLET_REQUEST_PARAM, request);
validator.setParameter(Validator.LOCALE_PARAM, locale);
validator.setParameter(ACTION_MESSAGES_PARAM, errors);
validator.setParameter(Validator.BEAN_PARAM, bean);
return validator;
}
示例13: validateByteLocale
import org.apache.struts.util.RequestUtils; //导入依赖的package包/类
/**
* Checks if the field can safely be converted to a byte primitive.
*
* @param bean The bean validation is being performed on.
* @param va The <code>ValidatorAction</code> that is currently
* being performed.
* @param field The <code>Field</code> object associated with the
* current field being validated.
* @param errors The <code>ActionMessages</code> object to add errors
* to if any validation errors occur.
* @param validator The <code>Validator</code> instance, used to access
* other field values.
* @param request Current request object.
* @return true if valid, false otherwise.
*/
public static Object validateByteLocale(Object bean, ValidatorAction va,
Field field, ActionMessages errors, Validator validator,
HttpServletRequest request) {
Object result = null;
String value = null;
value = evaluateBean(bean, field);
if (GenericValidator.isBlankOrNull(value)) {
return Boolean.TRUE;
}
Locale locale = RequestUtils.getUserLocale(request, null);
result = GenericTypeValidator.formatByte(value, locale);
if (result == null) {
errors.add(field.getKey(),
Resources.getActionMessage(validator, request, va, field));
}
return (result == null) ? Boolean.FALSE : result;
}
示例14: validateShortLocale
import org.apache.struts.util.RequestUtils; //导入依赖的package包/类
/**
* Checks if the field can safely be converted to a short primitive.
*
* @param bean The bean validation is being performed on.
* @param va The <code>ValidatorAction</code> that is currently
* being performed.
* @param field The <code>Field</code> object associated with the
* current field being validated.
* @param errors The <code>ActionMessages</code> object to add errors
* to if any validation errors occur.
* @param validator The <code>Validator</code> instance, used to access
* other field values.
* @param request Current request object.
* @return true if valid, false otherwise.
*/
public static Object validateShortLocale(Object bean, ValidatorAction va,
Field field, ActionMessages errors, Validator validator,
HttpServletRequest request) {
Object result = null;
String value = null;
value = evaluateBean(bean, field);
if (GenericValidator.isBlankOrNull(value)) {
return Boolean.TRUE;
}
Locale locale = RequestUtils.getUserLocale(request, null);
result = GenericTypeValidator.formatShort(value, locale);
if (result == null) {
errors.add(field.getKey(),
Resources.getActionMessage(validator, request, va, field));
}
return (result == null) ? Boolean.FALSE : result;
}
示例15: validateIntegerLocale
import org.apache.struts.util.RequestUtils; //导入依赖的package包/类
/**
* Checks if the field can safely be converted to an int primitive.
*
* @param bean The bean validation is being performed on.
* @param va The <code>ValidatorAction</code> that is currently
* being performed.
* @param field The <code>Field</code> object associated with the
* current field being validated.
* @param errors The <code>ActionMessages</code> object to add errors
* to if any validation errors occur.
* @param validator The <code>Validator</code> instance, used to access
* other field values.
* @param request Current request object.
* @return true if valid, false otherwise.
*/
public static Object validateIntegerLocale(Object bean, ValidatorAction va,
Field field, ActionMessages errors, Validator validator,
HttpServletRequest request) {
Object result = null;
String value = null;
value = evaluateBean(bean, field);
if (GenericValidator.isBlankOrNull(value)) {
return Boolean.TRUE;
}
Locale locale = RequestUtils.getUserLocale(request, null);
result = GenericTypeValidator.formatInt(value, locale);
if (result == null) {
errors.add(field.getKey(),
Resources.getActionMessage(validator, request, va, field));
}
return (result == null) ? Boolean.FALSE : result;
}