本文整理汇总了Java中org.springframework.binding.validation.ValidationContext类的典型用法代码示例。如果您正苦于以下问题:Java ValidationContext类的具体用法?Java ValidationContext怎么用?Java ValidationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ValidationContext类属于org.springframework.binding.validation包,在下文中一共展示了ValidationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: validateAdminForm
import org.springframework.binding.validation.ValidationContext; //导入依赖的package包/类
public void validateAdminForm(Person personBean, ValidationContext context) {
LOGGER.debug("Validate the admin - START");
MessageContext messages = context.getMessageContext();
if(personBean.getFirstName().equals(""))
messages.addMessage(new MessageBuilder().error().source("firstName").defaultText("required").build());
if(personBean.getLastName().equals(""))
messages.addMessage(new MessageBuilder().error().source("lastName").defaultText("required").build());
if(personBean.getEmail().equals(""))
messages.addMessage(new MessageBuilder().error().source("email").defaultText("required").build());
else
if(!testEmail(personBean.getEmail()))
messages.addMessage(new MessageBuilder().error().source("email").defaultText("incorrect form").build());
try {
if(BLPerson.getInstance().getByUsername(personBean.getUsername()) != null)
messages.addMessage(new MessageBuilder().error().source("username").defaultText("Username already exists!").build());
} catch (BusinessException e) {
e.printStackTrace();
}
LOGGER.debug("Validate the organisation - END");
}
开发者ID:CodeSphere,项目名称:termitaria,代码行数:27,代码来源:PersonBeanValidator.java
示例2: validateDeliveryOptions
import org.springframework.binding.validation.ValidationContext; //导入依赖的package包/类
/**
* <p>validateDeliveryOptions</p>
*
* @param deliveryOptions a {@link org.opennms.reporting.core.DeliveryOptions} object.
* @param context a {@link org.springframework.binding.validation.ValidationContext} object.
*/
public void validateDeliveryOptions(DeliveryOptions deliveryOptions, ValidationContext context) {
MessageContext messages = context.getMessageContext();
if (!((deliveryOptions.getSendMail() | deliveryOptions.getPersist()))) {
messages.addMessage(new MessageBuilder().error().source("sendMail").
defaultText("one of send mail or persist should be selected").build());
messages.addMessage(new MessageBuilder().error().source("persist").
defaultText("one of send mail or persist should be selected").build());
} else {
if (deliveryOptions.getSendMail() && (deliveryOptions.getMailTo() == "")) {
messages.addMessage(new MessageBuilder().error().source("mailTo").
defaultText("cannot have empty mail recipient").build());
}
}
if (deliveryOptions.getInstanceId().length() == 0) {
messages.addMessage(new MessageBuilder().error().source("instanceId").
defaultText("cannot have an empty Id for the report instance").build());
} else if (m_reportSchedulerService.exists(deliveryOptions.getInstanceId())) {
messages.addMessage(new MessageBuilder().error().source("instanceId").
defaultText("report instanceId is already in use").build());
}
}
开发者ID:qoswork,项目名称:opennmszh,代码行数:29,代码来源:DeliveryOptionsValidator.java
示例3: validateSettlementGenerationEntry
import org.springframework.binding.validation.ValidationContext; //导入依赖的package包/类
public void validateSettlementGenerationEntry(ValidationContext context)
{
String userEventName = context.getUserEvent();
if (!((userEventName.equalsIgnoreCase("completeSettlement"))
|| (userEventName.equalsIgnoreCase("delete"))
|| (userEventName.equalsIgnoreCase("settlementdeletionconfirmed"))
|| (userEventName.equalsIgnoreCase("settlementdeletioncancelled"))
|| (userEventName
.equalsIgnoreCase("closeSettlementOk")))) {
if (getStartDate().after(getEndDate())) {
MessageContext messages = context.getMessageContext();
messages.addMessage(new MessageBuilder().error()
.code("startdate.greaterthan.enddate").build());
}
}
}
开发者ID:arunkpatra,项目名称:expense-tracker,代码行数:17,代码来源:SettlementBean.java
示例4: validateCasMustChangePassView
import org.springframework.binding.validation.ValidationContext; //导入依赖的package包/类
/**
* Validate cas must change pass view.
*
* @param bean the bean
* @param context the context
*/
public void validateCasMustChangePassView(final PasswordChangeBean bean, final ValidationContext context) {
final MessageContext messages = context.getMessageContext();
if (!bean.getPassword().equals(bean.getConfirmedPassword())) {
messages.addMessage(new MessageBuilder().error().source("pm.passwordsMustMatch").
defaultText("Provided passwords do not match.").build());
return;
}
if (!bean.getPassword().matches(casProperties.getAuthn().getPm().getPolicyPattern())) {
messages.addMessage(new MessageBuilder().error().source("pm.passwordFailedCriteria").
defaultText("Password policy rejected the provided insecure password.").build());
}
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:20,代码来源:PasswordValidator.java
示例5: validateCreateUser
import org.springframework.binding.validation.ValidationContext; //导入依赖的package包/类
public void validateCreateUser(ValidationContext context) {
MessageContext messages = context.getMessageContext();
if (!StringUtils.equals(uiPassword, verifyPassword)) {
messages.addMessage(new MessageBuilder().error().source("password").source("verifyPassword")
.defaultText("Passwords must be the same.").build());
}
}
开发者ID:arnaldop,项目名称:enhanced-pet-clinic,代码行数:8,代码来源:User.java
示例6: validateEnterExpenseSearchCriteria
import org.springframework.binding.validation.ValidationContext; //导入依赖的package包/类
public void validateEnterExpenseSearchCriteria(ValidationContext context)
{
if (getStartDate().after(getEndDate())) {
MessageContext messages = context.getMessageContext();
messages.addMessage(new MessageBuilder().error()
.code("enddate.lessthan.startdate").build());
}
}
开发者ID:arunkpatra,项目名称:expense-tracker,代码行数:9,代码来源:ExpenseSearchCriteria.java
示例7: validateUserModificationScreen
import org.springframework.binding.validation.ValidationContext; //导入依赖的package包/类
public void validateUserModificationScreen(ValidationContext context)
{
String userEventName = context.getUserEvent();
if (("addAuth".equalsIgnoreCase(userEventName))
|| ("deleteAuth".equalsIgnoreCase(userEventName))) {
if (getUsername().equalsIgnoreCase(
context.getUserPrincipal().getName())) {
MessageContext messages = context.getMessageContext();
messages.addMessage(new MessageBuilder().error()
.code("cannot.modify.selfauths").build());
}
}
}
开发者ID:arunkpatra,项目名称:expense-tracker,代码行数:14,代码来源:UserBean.java
示例8: validateEnterBookingDetails
import org.springframework.binding.validation.ValidationContext; //导入依赖的package包/类
public void validateEnterBookingDetails(ValidationContext context) {
MessageContext messages = context.getMessageContext();
if (checkinDate.before(today())) {
messages.addMessage(new MessageBuilder().error().source("checkinDate")
.code("booking.checkinDate.beforeToday").build());
} else if (checkoutDate.before(checkinDate)) {
messages.addMessage(new MessageBuilder().error().source("checkoutDate")
.code("booking.checkoutDate.beforeCheckinDate").build());
}
}
开发者ID:websphere,项目名称:SpringPrimeFacesShowcase,代码行数:11,代码来源:Booking.java
示例9: validateReportParameters
import org.springframework.binding.validation.ValidationContext; //导入依赖的package包/类
/**
* <p>validateReportParameters</p>
*
* @param reportCriteria a {@link org.opennms.api.reporting.parameter.ReportParameters} object.
* @param context a {@link org.springframework.binding.validation.ValidationContext} object.
*/
public void validateReportParameters(ReportParameters reportCriteria, ValidationContext context) {
MessageContext messages = context.getMessageContext();
List<ReportDateParm> dateParms = reportCriteria.getDateParms();
for (Iterator<ReportDateParm> dateParmIter = dateParms.iterator(); dateParmIter.hasNext();) {
ReportDateParm dateParm = dateParmIter.next();
if (dateParm.getDate() == null) {
messages.addMessage(new MessageBuilder().error().source("date parms").
defaultText("cannot have null date field" + dateParm.getDisplayName()).build());
}
}
List<ReportStringParm> stringParms = reportCriteria.getStringParms();
for (Iterator<ReportStringParm> stringParmIter = stringParms.iterator(); stringParmIter.hasNext();) {
ReportStringParm stringParm = stringParmIter.next();
if (stringParm.getValue() == "" ) {
messages.addMessage(new MessageBuilder().error().source("string parms").
defaultText("cannot have empty string field" + stringParm.getDisplayName()).build());
}
}
List<ReportIntParm> intParms = reportCriteria.getIntParms();
for (Iterator<ReportIntParm> intParmIter = intParms.iterator(); intParmIter.hasNext();) {
ReportIntParm intParm = intParmIter.next();
// TODO add a more sensible check here - I think we probably can have zero int parm
if (intParm.getValue() == 0 ) {
messages.addMessage(new MessageBuilder().error().source("int parms").
defaultText("cannot have zero integer field" + intParm.getDisplayName()).build());
}
}
List<ReportFloatParm> floatParms = reportCriteria.getFloatParms();
for (Iterator<ReportFloatParm> floatParmIter = floatParms.iterator(); floatParmIter.hasNext();) {
ReportFloatParm floatParm = floatParmIter.next();
if (floatParm.getValue() == null ) {
messages.addMessage(new MessageBuilder().error().source("float parms").
defaultText("cannot have null float field" + floatParm.getDisplayName()).build());
}
}
List<ReportDoubleParm> doubleParms = reportCriteria.getDoubleParms();
for (Iterator<ReportDoubleParm> doubleParmIter = doubleParms.iterator(); doubleParmIter.hasNext();) {
ReportDoubleParm doubleParm = doubleParmIter.next();
if (doubleParm.getValue() == null ) {
messages.addMessage(new MessageBuilder().error().source("double parms").
defaultText("cannot have null double field" + doubleParm.getDisplayName()).build());
}
}
}
开发者ID:qoswork,项目名称:opennmszh,代码行数:63,代码来源:ReportParametersValidator.java
示例10: validateAddNewAuth
import org.springframework.binding.validation.ValidationContext; //导入依赖的package包/类
public void validateAddNewAuth(ValidationContext context)
{
MessageContext messages = context.getMessageContext();
messages.addMessage(new MessageBuilder().error()
.code("role.allready.exists").build());
}
开发者ID:arunkpatra,项目名称:expense-tracker,代码行数:7,代码来源:UserBean.java
示例11: expenseRelatedTests
import org.springframework.binding.validation.ValidationContext; //导入依赖的package包/类
@Test
public void expenseRelatedTests() {
// Check if expense was saved earlier
Assert.assertNotNull("Expense detail is null",expenseDetail);
// start
//RequestContext requestContext = new MockRequestContext();//MockRequestContext();
//
// MockExternalContext ec = new MockExternalContext();
// ec.setCurrentUser("Admin");
// ((MockRequestContext) requestContext).setExternalContext(ec);
MappingResults mResults = new DefaultMappingResults(null, null, new ArrayList<MappingResult>());
ValidationContext vc = new DefaultValidationContext(rCtx, "calcShares", mResults);
expenseDetail.validateEnterExpenseDetail(vc);
// try with next
vc = new DefaultValidationContext(rCtx, "next", mResults);
expenseDetail.setOverrideSharesFlag(true);
expenseDetail.validateEnterExpenseDetail(vc);
// end
int result = expenseService.saveExpense(expenseDetail);
Assert.assertTrue("Failed to save expense.", result == 0);
// Search for expenses in a date range
ExpenseSearchCriteria esc = new ExpenseSearchCriteria();
Date today = new Date();
Calendar cal1 = Calendar.getInstance();
cal1.setTime(today);
cal1.add(Calendar.DAY_OF_MONTH, -1);
Date yesterday = cal1.getTime();
//
Calendar cal2 = Calendar.getInstance();
cal2.setTime(today);
cal2.add(Calendar.DAY_OF_MONTH, 1);
Date tomorrow = cal2.getTime();
//
esc.setEndDate(tomorrow);
esc.setStartDate(yesterday);
List<ExpenseDetail> expenses = expenseService.getExpenses(esc);
Assert.assertNotNull("Failed to get expenses", expenses);
int i = expenses.size();
Assert.assertTrue("Expected exactly 1 expense.", i == 1);
// Locate a specific expense by id
ExpenseDetail ee = expenses.get(0);
ExpenseDetail ed = expenseService.getExpenseById(ee.getId());
Assert.assertNotNull("Failed to get expensedetail", ed);
// Edit record
ed.setEditMode(true);
ed.setCategory("New category");
int resultR = expenseService.saveExpense(ed);
Assert.assertTrue("Failed to edit expense.", resultR == 0);
// Locate expense detail bean
ExpenseDetail ed1 = expenseService.getExpenseDetailBeanById(ee.getId());
Assert.assertNotNull("Failed to get expensedetailbean", ed1);
// Get unsettled expenses
SettlementBean sb = new SettlementBean();
sb.setStartDate(yesterday);
sb.setEndDate(tomorrow);
List<ExpenseDetail> ex2 = expenseService.getUnsettledExpenses(sb);
Assert.assertNotNull("Failed to get unsettled expenses", ex2);
Assert.assertTrue("Expected exactly 1 expense to settle.", ex2.size() == 1);
// Delete expense
int delresult = expenseService.deleteExpenseById(ee.getId(), rCtx);
Assert.assertTrue("Failed to delete expense", delresult == 0);
// get expense for null user id
expenseService.getExpenseDetailBeanById(null);
}
开发者ID:arunkpatra,项目名称:expense-tracker,代码行数:75,代码来源:JpaExpenseServiceTests.java
示例12: validateEdit
import org.springframework.binding.validation.ValidationContext; //导入依赖的package包/类
public void validateEdit(ValidationContext validationContext) {
if (stateValidationEnabled && startDate.after(endDate)) {
MessageContext messageContext = validationContext.getMessageContext();
messageContext.addMessage(new MessageBuilder().error().code("startDateBeforeEndDate.viewState").build());
}
}
开发者ID:websphere,项目名称:SpringPrimeFacesShowcase,代码行数:7,代码来源:Reservation.java
示例13: validate
import org.springframework.binding.validation.ValidationContext; //导入依赖的package包/类
public void validate(ValidationContext validationContext) {
if (globalValidationEnabled && startDate.after(endDate)) {
MessageContext messageContext = validationContext.getMessageContext();
messageContext.addMessage(new MessageBuilder().error().code("startDateBeforeEndDate.global").build());
}
}
开发者ID:websphere,项目名称:SpringPrimeFacesShowcase,代码行数:7,代码来源:Reservation.java
示例14: validateOrganizationForm
import org.springframework.binding.validation.ValidationContext; //导入依赖的package包/类
public void validateOrganizationForm(Organisation organisationBean, ValidationContext context) {
LOGGER.debug("Validate the organisation - START");
MessageContext messages = context.getMessageContext();
try {
if(organisationBean.getName().equals(""))
messages.addMessage(new MessageBuilder().error().source("name").defaultText("required").build());
else
if(BLOrganisation.getInstance().getOrgByName(organisationBean.getName()) != null)
messages.addMessage(new MessageBuilder().error().source("name").defaultText("This name is already in use!").build());
if(organisationBean.getAddress().equals(""))
messages.addMessage(new MessageBuilder().error().source("address").defaultText("required").build());
if(organisationBean.getPhone().equals(""))
messages.addMessage(new MessageBuilder().error().source("phone").defaultText("required").build());
if(organisationBean.getEmail().equals(""))
messages.addMessage(new MessageBuilder().error().source("email").defaultText("required").build());
else
if(!testEmail(organisationBean.getEmail()))
messages.addMessage(new MessageBuilder().error().source("email").defaultText("incorrect format").build());
if(organisationBean.getIban().equals(""))
messages.addMessage(new MessageBuilder().error().source("iban").defaultText("required").build());
if(organisationBean.getLocation().equals(""))
messages.addMessage(new MessageBuilder().error().source("location").defaultText("required").build());
if(organisationBean.getType() == (byte) -1)
messages.addMessage(new MessageBuilder().error().source("type").defaultText("Choose a type").build());
if(organisationBean.getCui().equals(""))
messages.addMessage(new MessageBuilder().error().source("cui").defaultText("required").build());
if(organisationBean.getJ().equals(""))
messages.addMessage(new MessageBuilder().error().source("j").defaultText("required").build());
} catch (BusinessException e) {
e.printStackTrace();
}
LOGGER.debug("Validate the organisation - END");
}
开发者ID:CodeSphere,项目名称:termitaria,代码行数:44,代码来源:OrganisationBeanValidator.java
示例15: ValidateTriggerDetails
import org.springframework.binding.validation.ValidationContext; //导入依赖的package包/类
/**
* <p>ValidateTriggerDetails</p>
*
* @param triggerDetails a {@link org.opennms.web.report.database.model.TriggerDetails} object.
* @param context a {@link org.springframework.binding.validation.ValidationContext} object.
*/
public void ValidateTriggerDetails(TriggerDetails triggerDetails, ValidationContext context) {
//TODO validate the cron expression here
}
开发者ID:qoswork,项目名称:opennmszh,代码行数:10,代码来源:TriggerDetailsValidator.java
注:本文中的org.springframework.binding.validation.ValidationContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论