PDA

View Full Version : gxt desktop in a browser problem.



ulisseodisseo
10 Nov 2011, 5:51 AM
Hi at all.
I followed the tutorial and I'm making a mine project with 'desktop-in-a-browser' interface.
I've a problem. I've two kind of user (logged and guest), and i've a window with some button. I want that the guest user cannot click some button. For this reason, I implemented a service RPC that check if a user is logged or not.
When I create the shortuct and the window, I see only a blank window...

29212

this is the code of my Shortcut


Shortcut userManagerShortCut = new Shortcut(); userManagerShortCut.setText("User Manager");
userManagerShortCut.setIconStyle("grid-win-shortcut");
userManagerShortCut.setData("windows", this.createUserManagerWindow());
userManagerShortCut.addSelectionListener(new SelectionListener<ComponentEvent>(){


@Override
public void componentSelected(ComponentEvent ce) {
// TODO Auto-generated method stub

umw = new UserManagerWidget();


umw.actionRPC();
umw.create();
System.out.println("son la");
desktop.addWindow(umw.getUserManagerWidget());
if(!umw.getUserManagerWidget().isVisible())
umw.show();

}

});

and this is the code of my window






public class UserManagerWidget extends Window {


private boolean logged;


private Grid grid;

public UserManagerWidget() {
setResizable(true);

setHeading("User Manager");


}




public void actionRPC()
{
final ServiceAsync serviceUser = GWT.create(Service.class);

serviceUser.checkIfIsLogged(new AsyncCallback<Boolean>(){

@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
Info.display("Errore nel server",caught.getMessage());
setLogged(false);

}






@Override
public void onSuccess(Boolean result) {
// TODO Auto-generated method stub
setLogged(result);
System.out.println("result rpc "+logged);
create();
}

});

}



public void create()
{
this.removeAll();
grid = new Grid(1, 5);

System.out.println("logged = "+logged);
Button btnCerca = new Button("Cerca");
grid.setWidget(0, 0, btnCerca);

Button btnChat = new Button("Chat");
grid.setWidget(0, 1, btnChat);


Button btnMessaggi = new Button("Tuoi messaggi");
grid.setWidget(0, 2, btnMessaggi);

Button btnAmici = new Button("Tuoi amici");
grid.setWidget(0, 3, btnAmici);

Button btnProfilo = new Button("Tuo profilo");
btnProfilo.addClickHandler(new ClickHandler() {


@Override
public void onClick(ClickEvent event) {
// TODO Auto-generated method stub
if(logged)
{Window infoWindow = new ShowUserInfoWidget();
infoWindow.show();
}
else
Info.display("Errore", "devi essere loggato per visualizzare");
}

});

grid.setWidget(0, 4, btnProfilo);
add(grid);


}


public Window getUserManagerWidget()
{
return this;
}

public void setLogged(boolean logged) {
this.logged = logged;
}








public boolean isLogged() {
return logged;
}






public void setGrid(Grid grid) {
this.grid = grid;
}






public Grid getGrid() {
return grid;
}




How I can do to solve the problem? Please, help me... :((:((:((