Send TextField values (parameter) to a servlet
i have 3 TextFields (Vaadin) ( DBName, DBUserName, DBPassword) i want to send the typed in text from a portlet to a servlet , this is what i've got so far :
Portlet part:
TextField DBName;
TextField DBUserName;
TextField DBPassword;
DBName = new TextField("Enter DB Name");
DBName.setColumns(20);
DBUserName = new TextField("Enter UserName");
DBUserName.setColumns(20);
DBPassword = new TextField("Enter Password");
DBPassword.setColumns(20);
//Button
if(event.getSource()== Connect){
Resource newPictureResource = new ExternalResource("http://localhost:8888/portlet/picture?UserName="+DBUserName.getValue()+"&DBPassword="+DBPassword.getValue()+"&DBName="+DBName.getValue());
picture.setSource(newPictureResource);
editContent.addComponent(picture);
}
Servlet part :
no ideas here , was开发者_C百科 thinkig about
String UserName = request.getParameter("DBUserName");
String Password = request.getParameter("DBPassword");
String DataBase = request.getParameter("DBName");
I want to get the Values that has been entered to the text field, any ideas ?
Your code almost looks finished. I only edited it a little bit (I wasn't sure what your actual problem was). You could simply use java's built in support for posting data. You can read more about querystrings in the vaadin book.
TextField DBName;
TextField DBUserName;
TextField DBPassword;
DBName = new TextField("Enter DB Name");
DBName.setColumns(20);
DBUserName = new TextField("Enter UserName");
DBUserName.setColumns(20);
DBPassword = new TextField("Enter Password");
DBPassword.setColumns(20);
Button b = new Button("Connect");
b.setImmediate(true);
b.addListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
// post form values using java url connection
}
})
精彩评论