Hai,
       I am very new to the Flex
      I am working on flex + blazeds. I have a peculiar doubt that many feel 
silly,but this is that part,
I have an mxml file which contains A login Form --> when i click on the button 
it will be load another MXML page, during that action, the form values are 
validated in the java Api and again returned back to the MXML.

The catch is When the Java returns the object to the MXML (ie AS), as Object 
Async Token, hoe do i handle this one to Integer or anything else.

Either way it is satisfying the If in that function (ie it allows inside the If 
even though we give the unknown user)

i dont know how to sort out this.

This is the method in the AS
public function checkUser():Void {


                       
        if (loaderService.loginValidate(user))
        {
                Alert.show("user found.."+ (user) ,
"Information", Alert.OK, null, null, null, Alert.OK);
               
                placeWindow();//this will load the content
               
        }
        else
        {
                Alert.show("User not found...",
"Information", Alert.OK, null, null, null, Alert.OK);    
        }
       
       
       
        //loader.getConsultants();
       
                                         
//saveService.addUpdateUser(userObj);  
return null;
}



And this is the Java API

public int loginValidate(Users usersObj) throws Exception
        {
               
                int result = 0;
                List <Users> Usersobject =null;
                try {
                        //  Users user =  new Users();
                        Usersobject = new ArrayList<Users>();
                        EntityManagerFactory entityManagerFactory = 
Persistence.createEntityManagerFactory(PERSISTENCE_UNIT);

                        EntityManager em = 
entityManagerFactory.createEntityManager();

                        Query findAllQuery = 
em.createNamedQuery("user.findAll");
                        Usersobject = findAllQuery.getResultList();
                        logger.debug("** Found " + Usersobject.size() + 
"records:");                        
                        if (Usersobject != null)

                                logger.debug("** Found " + Usersobject.size() + 
"records:");
                        for (Iterator iterator = Usersobject.iterator(); 
iterator
                                        .hasNext();) {
                                Users users = (Users) iterator.next();
                               
                                logger.debug("getname"+users.getName());
                                logger.debug("objname"+usersObj.getName());
                                //if(users.getName()== ((Users) 
Usersobject).getName())
                                
if(users.getName().trim().equals(usersObj.getName().trim()))
                                {
                                        System.out.println("user found");
                                        logger.debug("user found");
                                        return 1;
                               
                                }
                                else
                                {
                                        System.out.println("user n  found");
                                        logger.debug("user not found");
                                        return 0;
                                }
                        }
                } catch (Exception e) {
                        e.printStackTrace();
                        System.out.println(e.getMessage());
                }

                return result;
        }
       

Thanks in advance, if anymore details needed i will be glad to share with you. 

Reply via email to