【问题标题】:How to test if a value exists in the database without submitting?如何在不提交的情况下测试数据库中是否存在值?
【发布时间】:2011-07-23 10:28:44
【问题描述】:

我正在使用 JSF2.0/primefaces,

我想验证从日历中选择的日期:

<p:calendar  value="#{bean.date1}" style="width: 50px" showOn="button" />

但我希望在不提交结果的情况下完成验证,我想要的是当我选择日期并且它不存在于数据库中时,将向用户显示一条消息。 我写了一个函数来测试数据库中是否存在日期,但我不知道下一步该怎么做!

public void validateDate() throws ParseException
 {
  FindIssue fdate=new FindIssue();
  ArrayList<String> listdate=fdate.FindListdateCreation();
  Iterator itdate=listdate.iterator();
  while (itdate.hasNext())
  {
DateFormat out = new SimpleDateFormat("yyyy-MM-dd");
String date=out.format(itdate.next());

  if(!date.equals(formatingDateTime(date1))) 
  {
      System.out.println("invalide date ");
  }

  }
}

【问题讨论】:

    标签: java jsf-2 primefaces


    【解决方案1】:

    你可以例如使用&lt;f:ajax event 异步调用您的日期检查逻辑。

    【讨论】:

      猜你喜欢
      • 2019-11-05
      • 2013-04-18
      • 2020-12-10
      • 2017-09-23
      • 1970-01-01
      • 2012-04-03
      • 2020-08-29
      • 2012-01-17
      • 2011-04-15
      相关资源
      最近更新 更多