I have a problem i get the grid data with js and i have my servlet to
open xls but i don´t know how to send data from clien side to servlet,
and i don´t want to send by url this is my example

-------Button--------------------
IButton export = new IButton("Export");
                export.addClickHandler(new ClickHandler() {

                        @Override
                        public void onClick(ClickEvent event) {

                                StringBuilder exportedCSV = exportCSV(grid);
                                System.out.println(exportedCSV);


                                
Window.Location.replace(GWT.getModuleBaseURL()+"export");



                        }
                });

------------------Get data from grid------------

private StringBuilder exportCSV(ListGrid listGrid) {
                StringBuilder stringBuilder = new StringBuilder(); // csv data 
in
here

                // column names
                ListGridField[] fields = listGrid.getFields();
                for (int i = 0; i < fields.length; i++) {
                        ListGridField listGridField = fields[i];
                        stringBuilder.append("\"");
                        stringBuilder.append(listGridField.getName());
                        stringBuilder.append("\",");
                }
                stringBuilder.deleteCharAt(stringBuilder.length() - 1); // 
remove
last
                                                                                
                                                // ","
                stringBuilder.append("\n");

                // column data
                ListGridRecord[] records = listGrid.getRecords();
                for (int i = 0; i < records.length; i++) {
                        ListGridRecord listGridRecord = records[i];
                        ListGridField[] listGridFields = listGrid.getFields();
                        for (int j = 0; j < listGridFields.length; j++) {
                                ListGridField listGridField = listGridFields[j];
                                stringBuilder.append("\"");
                                
stringBuilder.append(listGridRecord.getAttribute(listGridField
                                                .getName()));
                                stringBuilder.append("\",");
                        }
                        stringBuilder.deleteCharAt(stringBuilder.length() - 1); 
// remove
                                                                                
                                                        // last ","
                        stringBuilder.append("\n");
                }
                return stringBuilder;
        }


-----------------servelt------------------------

public class ExcelServlet extends  HttpServlet {

    private static final long serialVersionUID = 1L;

    public void doGet(HttpServletRequest request, HttpServletResponse
response) throws IOException {



        OutputStream out = null;
        try {

         response.setContentType("application/vnd.ms-excel");
         response.setHeader
           ("Content-Disposition", "attachment; filename=Prueba.xls");
         WritableWorkbook w =
         Workbook.createWorkbook(response.getOutputStream());
         WritableSheet s = w.createSheet("Probando", 0);
         s.addCell(new Label(0, 0, "Hello World"));
         w.write();
         w.close();
        }
        catch (Exception e){
         try {
            throw new ServletException("Exception in Excel Sample
Servlet", e);
        } catch (ServletException e1) {
            e1.printStackTrace();
        }
        }
        finally{
         if (out != null)
          out.close();
        }

      }

}


i want to know how in button i can send data to servlet

thks

-- 
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