Hello,
Here is how you can do it:
On the client side, after submit:
final FormPanel formPanel = new FormPanel(C.exportFormPanel());
formPanel.setAction(GWT.getModuleBaseURL() + C.csv());
final FlowPanel flowPanel = new FlowPanel();
formPanel.setWidget(flowPanel);
final Hidden fileNameHidden = new Hidden(C.chartData(), csvData); //
csvData is the form data you want to flush.
flowPanel.add(fileNameHidden);
formPanel.setMethod(FormPanel.METHOD_POST);
RootLayoutPanel.get().add(formPanel);
formPanel.submit();
RootLayoutPanel.get().remove(formPanel);
Have a servlet to handle the form data in the server side:
In the doPost method, have the logic to flush the data
final String data = (String) request.getParameter(CHARTDATA);
response.setHeader(CACHE_CONTROL, NO_CACHE);
response.setHeader(PRAGMA, NO_CACHE);
response.setDateHeader(EXPIRES, 0);
response.setContentType(APPCSV);
response.setHeader(CONTENT_DISPOSITION, ATTACH_FILENAME);
// final String[] a = data.split("@");
PrintWriter writer = null;
try
{
writer = response.getWriter();
writer.append(data);
// for (String s : a)
// {
// writer.append(s);
// writer.append("\n");
// }
} finally
{
if (writer != null)
{
writer.flush();
writer.close();
}
}
This would export the data in the form of csv
On Friday, 2 March 2012 14:54:59 UTC+5:30, yashujn wrote:
>
> hi all,
>
> i have a in built form, what I want is when user fill the form and
> press the submit button the
>
> information will be saved into a csv file on server..... plz guide
> me how to do it.
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-web-toolkit/-/uh7RII9ifmgJ.
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.