public String login(){ 
   try{
     
     check=false; 
     openConnection();
     System.out.println("login action");
     ps=con.prepareStatement("select userid,password from epr_users where
userid=? and password=?");
     ps.setString(1,userid);
     ps.setString(2,password);
     ps.execute();
     rs=ps.getResultSet();
     System.out.println("hai");
     while(rs.next()){
          System.out.println(rs.getString("userid"));
          check=true;
     }
     if(check){
            context=FacesContext.getCurrentInstance();
            Iterator iter = context.getMessages("loginForm"); 
            while (iter.hasNext()) { 
                   System.out.println("messages is removing");   
                    iter.remove();  
            }    
         return "success";
     }
     else{ 
         context=FacesContext.getCurrentInstance();
         FacesMessage message = new FacesMessage("Invalid Username and/or
Password"); 
         context.addMessage("loginForm", message); 
         return "failure"; 
     } 
   }
   catch(SQLException e){
     e.printStackTrace();
   }
   finally{
     try{
       if(rs!=null)
         rs.close();
       rs=null;
     }
         catch(SQLException e){
       e.printStackTrace();
         }      
         try{
       if(ps!=null)
              ps.close();
           rs=null;
     }
         catch(SQLException e){
       e.printStackTrace();
     }
     try{
      close();
     }  
         catch(SQLException e){
           e.printStackTrace();
         }
   }
   return "failure";
 } 

}


please see this code while  login is success if there is any message
corresponding to
my login form i want to remove message.an
but it is not happening why .even though messages are adding to context in
context.getMessages("loginForm"); no messages is comming

--
View this message in context: 
http://www.nabble.com/how-can-i-remove-message-from-faces-context-t1839880.html#a5023009
Sent from the MyFaces - Users forum at Nabble.com.

Reply via email to