HI!
I have a question from you:
You can insert into a single method onClick of a ButtonListenerAdapter
more than one function that interacts with the database, relied on
interface Service?
My problem is that the first function returns a value (id) I retrieved
from the database and who I uses as a parameter for the second
function, but when I click on the button the first time, it seems that
the first callback does not retain the value of id that I gained from
the database. Instead the second click on the button I get what I
want.

------
Login.java

long id_programmer = 0;
Button regConfirmButton = new Button("Confirm");

regConfirmButton.addListener(new ButtonListenerAdapter(){
                        public void onClick(Button button, EventObject e){
                                
loginService.getIdProgrammer(fName.getValueAsString(),
fLastName.getValueAsString(), email.getValueAsString(), callback1 );
        
loginService.createUser(userNew.getValueAsString(),passwNew.getValueAsString(),
id_programmer, callback2);
                                if( id_programmer > 0){
                                        MessageBox.alert("Registration was 
successful");
                                }else
                                        MessageBox.alert("Programmer not found 
in database");
                        }
                });



final AsyncCallback callback1 = new AsyncCallback(){
                public void onSuccess(Object result) {
                        long ok = Long.valueOf(result.toString()).longValue();
                        id_programmer = ok;
                       //String s
=Long.valueOf(id_programmer).toString();
                        //Label lab = new Label(s);
                        //panelHoriz.add(lab);
                }
                public void onFailure(Throwable arg0) {
                }
};

--------------------------------

LoginServiceImpl.java

public long getIdProgrammer(String name, String lastName, String email)
{
                long ret = 0;
                List<ProgrammerTO> listprogrTO = new ArrayList<ProgrammerTO>();
                ProgrammerDAO progrDAO = new ProgrammerDAO();
                listprogrTO = progrDAO.findByLastName(lastName);

                Iterator<ProgrammerTO> iter = listprogrTO.iterator();
                while(iter.hasNext()){
                        ProgrammerTO progrItem = iter.next();
                        if( nome.equals( progrItem.getName() ) &&
email.equals( progrItem.getEmail() ) )
                                ret = progrItem.getId();
                }
                return ret;

        }

        public void createUser(String username, String password, Long
id_progr){

                RegistrationTO registrTO = new RegistrationTO();
                RegistrationDAO registrDAO = new RegistrationDAO();
                registrTO.setUsername(username);
                registrTO.setPassword(password);
                registrTO.setId_programmer(id_progr);

                registrDAO.create(registrTO);
        }


-------
So, with the first function I verify that the person you want to
register as a Programmer, and the second runs the registered with the
login data on the database.
Why after the first click is on the second maintain the value of your
function, but doing tests in callback1 I see that the id_programmer is
set correctly at the right value received from query?



Already thanks for having reached the end of this post!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to