This discussion is archived
8 Replies Latest reply: Jan 23, 2013 11:33 PM by Kayaman RSS

code not throwing validation error

adf009 Explorer
Currently Being Moderated
hi i have below code,but it does not throw validation error when the error occurs
    public void uniqueOrgname(ValueChangeEvent vce) {
       Object object = null;
        String value = (String)object;
        String s = "SELECT ORGANISATIONNAME FROM UAM_ORGANISATIONS where  ORGANISATIONNAME = '"+value+"'"; 
                           ApplicationModuleImpl am = (ApplicationModuleImpl)ADFUtils.getApplicationModuleForDataControl("UAMAppModuleDataControl1");
        
                   ResultSet rs;
                   String orgname = null;
                   System.out.println(s);
           DCBindingContainer bindings = 
                                          (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();  
                          
            
                   DCIteratorBinding iterBind = bindings.findIteratorBinding("UamOrganisationsView1Iterator");
                   Row[] rows = iterBind.getViewObject().getFilteredRows("Organisationname",vce.getNewValue()); //Check if any rows matching with given organization name, if matches, row count will be >0
                       if(rows.length>0){
                           //Write your code here, throw validation error message                     
                           
                           try {
                              rs=  am.getDBTransaction().createStatement(0).executeQuery(s);
                            
                               if(rs.next()){
                                   orgname = (String)rs.getObject(1) ;
                                   System.out.println( orgname);
                                   throw new ValidatorException(new FacesMessage("OrganisationName already exist"));
                               }
                           } catch (Exception e) {
                               e.printStackTrace();
                               
                           }
                           String msg = "<p> Your :  </p></br> <p> OrganisationName is  : "+ orgname+"</p>";
                           
                           
                                                       
                           }
                       }
Edited by: adf009 on 2013/01/23 5:22 PM

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points