本文整理汇总了Java中org.apache.commons.validator.Field.getArgs方法的典型用法代码示例。如果您正苦于以下问题:Java Field.getArgs方法的具体用法?Java Field.getArgs怎么用?Java Field.getArgs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.validator.Field
的用法示例。
在下文中一共展示了Field.getArgs方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMessage
import org.apache.commons.validator.Field; //导入方法依赖的package包/类
/**
* Gets the <code>Locale</code> sensitive value based on the key passed in.
* @param application the servlet context
* @param request the servlet request
* @param defaultMessages The default Message resources
* @param locale The locale
* @param va The Validator Action
* @param field The Validator Field
*/
public static String getMessage(ServletContext application,
HttpServletRequest request,
MessageResources defaultMessages,
Locale locale,
ValidatorAction va,
Field field) {
Msg msg = field.getMessage(va.getName());
if (msg != null && !msg.isResource()) {
return msg.getKey();
}
String msgKey = null;
String msgBundle = null;
MessageResources messages = defaultMessages;
if (msg == null) {
msgKey = va.getMsg();
} else {
msgKey = msg.getKey();
msgBundle = msg.getBundle();
if (msg.getBundle() != null) {
messages = getMessageResources(application, request, msg.getBundle());
}
}
if (msgKey == null || msgKey.length() == 0) {
return "??? " + va.getName() + "." + field.getProperty() + " ???";
}
// Get the arguments
Arg[] args = field.getArgs(va.getName());
String[] argValues = getArgValues(application, request, messages, locale, args);
// Return the message
return messages.getMessage(locale, msgKey, argValues);
}
示例2: getMessage
import org.apache.commons.validator.Field; //导入方法依赖的package包/类
/**
* Gets the <code>Locale</code> sensitive value based on the key passed
* in.
*
* @param application the servlet context
* @param request the servlet request
* @param defaultMessages The default Message resources
* @param locale The locale
* @param va The Validator Action
* @param field The Validator Field
*/
public static String getMessage(ServletContext application,
HttpServletRequest request, MessageResources defaultMessages,
Locale locale, ValidatorAction va, Field field) {
Msg msg = field.getMessage(va.getName());
if ((msg != null) && !msg.isResource()) {
return msg.getKey();
}
String msgKey = null;
String msgBundle = null;
MessageResources messages = defaultMessages;
if (msg == null) {
msgKey = va.getMsg();
} else {
msgKey = msg.getKey();
msgBundle = msg.getBundle();
if (msg.getBundle() != null) {
messages =
getMessageResources(application, request, msg.getBundle());
}
}
if ((msgKey == null) || (msgKey.length() == 0)) {
return "??? " + va.getName() + "." + field.getProperty() + " ???";
}
// Get the arguments
Arg[] args = field.getArgs(va.getName());
String[] argValues =
getArgValues(application, request, messages, locale, args);
// Return the message
return messages.getMessage(locale, msgKey, argValues);
}
示例3: validate
import org.apache.commons.validator.Field; //导入方法依赖的package包/类
/**
* Validates the value of the specified Field on the target Object
*
* @param object
* @param fieldName
* @return a Set of Validation Error Keys
* @throws ValidationException
*/
public Set<String> validate(Object object, String fieldName)
throws ValidationException
{
try
{
Set<String> errorKeys = new HashSet<String>();
String objectId = object.getClass().getName();
//Setup the Validator
Validator validator = new Validator(this.validatorResources, objectId);
validator.setParameter(Validator.BEAN_PARAM, object);
validator.setFieldName(fieldName);
ValidatorResults results = validator.validate();
Form form = this.validatorResources.getForm(Locale.getDefault(), objectId);
Iterator propertyNames = results.getPropertyNames().iterator();
while(propertyNames.hasNext())
{
String property = (String)propertyNames.next();
ValidatorResult result = results.getValidatorResult(property);
Map actionMap = result.getActionMap();
Iterator keys = actionMap.keySet().iterator();
while (keys.hasNext())
{
String actionName = (String) keys.next();
if (!result.isValid(actionName))
{
Field field = form.getField(property);
Arg[] args = field.getArgs(actionName);
if(args != null)
{
for(int i=0; i<args.length; i++)
{
errorKeys.add(args[i].getKey());
}
}
}
}
}
return errorKeys;
}
catch(Exception e)
{
log.error(this, e);
throw new ValidationException(e);
}
}
示例4: getActionMessage
import org.apache.commons.validator.Field; //导入方法依赖的package包/类
/**
* Gets the <code>ActionMessage</code> based on the
* <code>ValidatorAction</code> message and the <code>Field</code>'s arg
* objects.
*
* @param validator the Validator
* @param request the servlet request
* @param va Validator action
* @param field the validator Field
*/
public static ActionMessage getActionMessage(Validator validator,
HttpServletRequest request, ValidatorAction va, Field field) {
Msg msg = field.getMessage(va.getName());
if ((msg != null) && !msg.isResource()) {
return new ActionMessage(msg.getKey(), false);
}
String msgKey = null;
String msgBundle = null;
if (msg == null) {
msgKey = va.getMsg();
} else {
msgKey = msg.getKey();
msgBundle = msg.getBundle();
}
if ((msgKey == null) || (msgKey.length() == 0)) {
return new ActionMessage("??? " + va.getName() + "."
+ field.getProperty() + " ???", false);
}
ServletContext application =
(ServletContext) validator.getParameterValue(SERVLET_CONTEXT_PARAM);
MessageResources messages =
getMessageResources(application, request, msgBundle);
Locale locale = RequestUtils.getUserLocale(request, null);
Arg[] args = field.getArgs(va.getName());
String[] argValues =
getArgValues(application, request, messages, locale, args);
ActionMessage actionMessage = null;
if (msgBundle == null) {
actionMessage = new ActionMessage(msgKey, argValues);
} else {
String message = messages.getMessage(locale, msgKey, argValues);
actionMessage = new ActionMessage(message, false);
}
return actionMessage;
}