The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

ksek (2) [Avatar] Offline
#1
Hi
Here is a sample code for my FileUpload. The trouble I am having is, I am able to handle File uploads, but I would like to pass additional params to the servlet that handles file upload. so Introduced a hidden widget and am setting the name and ID but in the servlet when I tried to read the parameter with request.getparameter or request.getAttribute , it returns null. Am I missing something

public FilePanel() {
VerticalPanel outerPanel = new VerticalPanel();
HorizontalPanel horizontalPanel = new HorizontalPanel();

outerPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);
outerPanel.setVerticalAlignment(VerticalPanel.ALIGN_TOP);


HorizontalPanel inner = new HorizontalPanel();
HeaderPanel fileHeader = new HeaderPanel("Load From File");
fileHeader.setStyleName(Styles.FILE_HEADER);
inner.add(fileHeader);

FileUpload fileUpload = new FileUpload();
fileUpload.setName("fileUpload");

Hidden hiddenParams = new new Hidden();
hiddenParams.setID("userFund");
hiddenParams.setName("userFund");
hiddenParams.setValue("someValue");


horizontalPanel.add(fileUpload);
horizontalPanel.add(hiddenParams);

myForm = new FormPanel();
myForm.setAction(GWT.getModuleBaseURL() + AppConstants.FORM_SERVLET);
myForm.setEncoding(FormPanel.ENCODING_MULTIPART);
myForm.setMethod(FormPanel.METHOD_POST);
myForm.addFormHandler(this);
myForm.setWidget(horizontalPanel);

inner.add(myForm);
outerPanel.add(inner);
inner.setWidth(PANEL_WIDTH);
initWidget(outerPanel);
}
ksek (2) [Avatar] Offline
#2
Re: FileUpload with additional params
I was using the apache fileUpload for processing the File upload, so I handled the Form Fields as well using the apache file upload instead of reading from request attributes/parameters