ravi.m183
1 Feb 2010, 11:37 PM
Hi,
In one of my modules I am using HiddenField which is added to a FormPanel. I am submitting the FormPanel and it gets submitted to a HttpServlet. I want to retrieve the value which is set in the HiddenField.
My client side code is:
FormPanel formPanel = new FormPanel();
formPanel.setFrame(false);
formPanel.setBodyBorder(false);
formPanel.setHeaderVisible(false);
formPanel.setAction(GWT.getModuleBaseURL() + "excel-upload-service");
formPanel.setEncoding(Encoding.MULTIPART);
formPanel.setMethod(Method.POST);
formPanel.setButtonAlign(HorizontalAlignment.CENTER);
HiddenField<String> hiddenField = new HiddenField<String>();
hiddenField.setId("hiddenField");
hiddenField.setValue("12345");
formPanel.add(hiddenField);
//On action submit the form
formPanel.submit();
I am trying to retrieve the value on the server side as follows:
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try
{
String value1 = req.getAttribute("hiddenField");
String value2 = req.getParameter("hiddenField");
}
}
I tried accessing both value1 and value2, but both are null values.
Can anyone please help?
Thanks
Ravi
In one of my modules I am using HiddenField which is added to a FormPanel. I am submitting the FormPanel and it gets submitted to a HttpServlet. I want to retrieve the value which is set in the HiddenField.
My client side code is:
FormPanel formPanel = new FormPanel();
formPanel.setFrame(false);
formPanel.setBodyBorder(false);
formPanel.setHeaderVisible(false);
formPanel.setAction(GWT.getModuleBaseURL() + "excel-upload-service");
formPanel.setEncoding(Encoding.MULTIPART);
formPanel.setMethod(Method.POST);
formPanel.setButtonAlign(HorizontalAlignment.CENTER);
HiddenField<String> hiddenField = new HiddenField<String>();
hiddenField.setId("hiddenField");
hiddenField.setValue("12345");
formPanel.add(hiddenField);
//On action submit the form
formPanel.submit();
I am trying to retrieve the value on the server side as follows:
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try
{
String value1 = req.getAttribute("hiddenField");
String value2 = req.getParameter("hiddenField");
}
}
I tried accessing both value1 and value2, but both are null values.
Can anyone please help?
Thanks
Ravi