Ver Mensaje Individual
  #3 (permalink)  
Antiguo 29/03/2012, 22:30
julianrb90
 
Fecha de Ingreso: marzo-2012
Mensajes: 21
Antigüedad: 12 años, 1 mes
Puntos: 1
Pregunta Respuesta: Vaadin problemas textfield

Lo que sucede es que seguí las instrucciones del vídeo y no funciona al obtención del valor del texfield que envía el nombre entre el primer CustomComponent y el segundo, he revisado varios foros y no he encontrado la respuesta. Agradecería alguien que me pueda ayudar.

Clase Aplicacion

Cita:
import com.vaadin.Application;
import com.vaadin.ui.*;

@SuppressWarnings("serial")
public class LoginApplication extends Application {
@Override
public void init() {
Window mainWindow = new Window("Login Application");
Registro r=new Registro();
mainWindow.setContent(r);
setMainWindow(mainWindow);
}

}
Clase CustomComponet1

Cita:
import com.vaadin.annotations.AutoGenerated;
import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.event.FieldEvents.TextChangeEvent;
import com.vaadin.ui.AbsoluteLayout;
import com.vaadin.ui.Button;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.TextField;
import com.vaadin.ui.Button.ClickEvent;


@SuppressWarnings("serial")
public class Registro extends CustomComponent implements Property.ValueChangeListener{

@AutoGenerated
private AbsoluteLayout mainLayout;
private GridLayout contenedor;
private Button ingresar;
private TextField nombre;

/**
* The constructor should first build the main layout, set the
* composition root and then do any custom initialization.
*
* The constructor will not be automatically regenerated by the
* visual editor.
*/
public Registro() {
buildMainLayout();
buildContenedor();
setCompositionRoot(mainLayout);

// TODO add user code here
}

@AutoGenerated
private AbsoluteLayout buildMainLayout() {
// the main layout and components will be created here
mainLayout = new AbsoluteLayout();
mainLayout.setImmediate(false);
mainLayout.setWidth("100%");
mainLayout.setHeight("100%");
mainLayout.setMargin(false);

setWidth("100.0%");
setHeight("100.0%");

contenedor=buildContenedor();
mainLayout.addComponent(contenedor,"top:0.0px;left :0.0px;");
return mainLayout;

}


@SuppressWarnings({ "deprecation" })
private GridLayout buildContenedor(){
contenedor=new GridLayout();
contenedor.setCaption("Login");
contenedor.setImmediate(false);
contenedor.setWidth("250px");
contenedor.setHeight("200px");
contenedor.setMargin(true);
contenedor.setRows(3);

nombre=new TextField();
nombre.setCaption("Nombre: ");
nombre.setImmediate(true);
nombre.setWidth("-1px");
nombre.setHeight("-1px");
nombre.setSecret(false);
nombre.addListener(this);
contenedor.addComponent(nombre,0 ,0);

ingresar=new Button();
ingresar.setCaption("Ingresar");
ingresar.setImmediate(false);
ingresar.setWidth("-1px");
ingresar.setHeight("-1px");
ingresar.addListener(new Button.ClickListener() {

@Override
public void buttonClick(ClickEvent event) {
// TODO Auto-generated method stub
getWindow().showNotification("Correcto");
getApplication().getMainWindow().setContent(new Ventana(nombre.getValue().toString()));
}
});
contenedor.addComponent(ingresar,0,1);

return contenedor;
}

@Override
public void valueChange(ValueChangeEvent event) {
// TODO Auto-generated method stub
getWindow().showNotification((String) nombre.getValue());

}


}
Clase CustomComponet2

Cita:
import com.vaadin.annotations.AutoGenerated;
import com.vaadin.ui.AbsoluteLayout;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.Label;

@SuppressWarnings("serial")
public class Ventana extends CustomComponent {

@AutoGenerated
private AbsoluteLayout mainLayout;
private Label nombre;
private String nom;

/**
* The constructor should first build the main layout, set the
* composition root and then do any custom initialization.
*
* The constructor will not be automatically regenerated by the
* visual editor.
*/
public Ventana(String nom) {
this.nom=nom;
buildMainLayout();
setCompositionRoot(mainLayout);

// TODO add user code here
}

@AutoGenerated
private AbsoluteLayout buildMainLayout() {
// the main layout and components will be created here
mainLayout = new AbsoluteLayout();
mainLayout.setImmediate(false);
mainLayout.setWidth("100%");
mainLayout.setHeight("100%");
mainLayout.setMargin(false);

setWidth("100.0%");
setHeight("100.0%");

nombre=new Label();
nombre.setImmediate(false);
nombre.setWidth("-1px");
nombre.setHeight("-1px");
nombre.setValue("Nombre"+nom);
mainLayout.addComponent(nombre,"top:42.0px;left:90 .0px;");

return mainLayout;

}

}
Proporcionado por Tequino
[URL="http://www.youtube.com/user/MrTequino?feature=watch"]http://www.youtube.com/user/MrTequino?feature=watch[/URL]