Hi guys!
I’m having some troubles with my Vaadin 7 application.
I need to execute some Javascript and send the result to the controller. I’m using a AJAX call in the JavaScript but i cannot access to the controller after the ajax call.
I dont know how to return to my actual controller.
The Javascript method is in the controller LoginLayoutController:
Page.getCurrent().getJavaScript().execute(
"MiniApplet.cargarMiniApplet('[url_Server]
');
var enviarCertificado = null; var mostrarError = null; " +
" enviarCertificado = function(certificateB64) {" +
" document.getElementById(‘select’).value = certificateB64;" +
“var parametros = {” +
" ‘select’ : certificateB64" +
" };" +
“$.ajax({” +
" url: ‘/loginLayoutController’," +
" type: ‘POST’," +
" data: parametros" +
“});” +
" }; " +
" mostrarError = function(errorType, errorMessage) {" +
" alert(‘Type: ’ + errorType + ‘nMessage: ’ + errorMessage);" +
" }; " +
"MiniApplet.selectCertificate(’’, enviarCertificado, mostrarError);"
);
});
And the doPost method called by AJAX:
protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
String certificado = request.getParameter(“select”);
sessionId = request.getRequestedSessionId();
}
When doPost is executed, the controller is not the same and all the controller initialization is lost.
Another way to send the Javascript result instead of AJAX.
Please, i need some help.
Thx.