Discussion:
Upload a file gwt
Ousti Driss
2018-09-12 09:05:57 UTC
Permalink
Hey guys,

While browsing on the internet I found a way to upload a file in a gwt app,
I managed to reimplement the code and it works just fine using formPanel,
It just happens that this file needs to be stored in a mysql database,
the problem is before the user selects the file he wants to upload, he
needs to pick up two elements from
2 combobox,
I need those informations so I can build my sql querry, How I can get those
fields selected by the user
in the upload File servlet?

Thanks a lot,
--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+***@googlegroups.com.
To post to this group, send email to google-web-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
Paul Robinson
2018-09-12 09:50:57 UTC
Permalink
You can store the file on the server in a temporary area, returning a key
to the UI. Then, when the user is ready to submit the lot, the UI sends the
file's key to the server as well as the other data.

The server can then move the file data to a permanent home, or mark it as
permanent.

Paul
Post by Ousti Driss
Hey guys,
While browsing on the internet I found a way to upload a file in a gwt app,
I managed to reimplement the code and it works just fine using formPanel,
It just happens that this file needs to be stored in a mysql database,
the problem is before the user selects the file he wants to upload, he
needs to pick up two elements from
2 combobox,
I need those informations so I can build my sql querry, How I can get
those fields selected by the user
in the upload File servlet?
Thanks a lot,
--
You received this message because you are subscribed to the Google Groups
"GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+***@googlegroups.com.
To post to this group, send email to google-web-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
Ousti Driss
2018-09-12 09:59:40 UTC
Permalink
Thank you for your answer Paul,
Your solution seems logical,
but in my case these other data, I need it from the first submit,
these data are basically type of file ...
I need it to store correctly the file in the database,
Moreover, on the client side a submit is not taken into account untill all
the other data are filled.
Post by Paul Robinson
You can store the file on the server in a temporary area, returning a key
to the UI. Then, when the user is ready to submit the lot, the UI sends the
file's key to the server as well as the other data.
The server can then move the file data to a permanent home, or mark it as
permanent.
Paul
Post by Ousti Driss
Hey guys,
While browsing on the internet I found a way to upload a file in a gwt app,
I managed to reimplement the code and it works just fine using formPanel,
It just happens that this file needs to be stored in a mysql database,
the problem is before the user selects the file he wants to upload, he
needs to pick up two elements from
2 combobox,
I need those informations so I can build my sql querry, How I can get
those fields selected by the user
in the upload File servlet?
Thanks a lot,
--
You received this message because you are subscribed to the Google Groups
"GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an
<javascript:>.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+***@googlegroups.com.
To post to this group, send email to google-web-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
Josselin Bardet
2018-09-12 10:17:20 UTC
Permalink
Hi

You can use the form input name to send informations for exemple
Post by Ousti Driss
Thank you for your answer Paul,
Your solution seems logical,
but in my case these other data, I need it from the first submit,
these data are basically type of file ...
I need it to store correctly the file in the database,
Moreover, on the client side a submit is not taken into account untill all
the other data are filled.
Post by Paul Robinson
You can store the file on the server in a temporary area, returning a key
to the UI. Then, when the user is ready to submit the lot, the UI sends the
file's key to the server as well as the other data.
The server can then move the file data to a permanent home, or mark it as
permanent.
Paul
Post by Ousti Driss
Hey guys,
While browsing on the internet I found a way to upload a file in a gwt app,
I managed to reimplement the code and it works just fine using formPanel,
It just happens that this file needs to be stored in a mysql database,
the problem is before the user selects the file he wants to upload, he
needs to pick up two elements from
2 combobox,
I need those informations so I can build my sql querry, How I can get
those fields selected by the user
in the upload File servlet?
Thanks a lot,
--
You received this message because you are subscribed to the Google
Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+***@googlegroups.com.
To post to this group, send email to google-web-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
Ousti Driss
2018-09-12 10:25:16 UTC
Permalink
I founnd something similar,
On the client side I instanciated hidden objects,
I gave them a name and for the value it's the one selected by the user,
now, on the server side, when the result is parsed, I've got a list of
items, how can I check
that an item is the hidden one ?
Post by Josselin Bardet
Hi
You can use the form input name to send informations for exemple
Post by Ousti Driss
Thank you for your answer Paul,
Your solution seems logical,
but in my case these other data, I need it from the first submit,
these data are basically type of file ...
I need it to store correctly the file in the database,
Moreover, on the client side a submit is not taken into account untill
all the other data are filled.
Post by Paul Robinson
You can store the file on the server in a temporary area, returning a
key to the UI. Then, when the user is ready to submit the lot, the UI sends
the file's key to the server as well as the other data.
The server can then move the file data to a permanent home, or mark it
as permanent.
Paul
Post by Ousti Driss
Hey guys,
While browsing on the internet I found a way to upload a file in a gwt app,
I managed to reimplement the code and it works just fine using formPanel,
It just happens that this file needs to be stored in a mysql database,
the problem is before the user selects the file he wants to upload, he
needs to pick up two elements from
2 combobox,
I need those informations so I can build my sql querry, How I can get
those fields selected by the user
in the upload File servlet?
Thanks a lot,
--
You received this message because you are subscribed to the Google
Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an
<javascript:>.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+***@googlegroups.com.
To post to this group, send email to google-web-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
Maarten Daalder (ISAAC Software Solutions)
2018-09-12 13:26:52 UTC
Permalink
In our case we place all elements to be 'uploaded' in the same FormPanel as
the file input element.
Then in our servlet we first retrieve all parts
(HttpServletRequest#getParts) after which we use getParameter to read out
the filled in form inputs.
The file itself is retrieved via a getPart(name of input here).
Post by Ousti Driss
I founnd something similar,
On the client side I instanciated hidden objects,
I gave them a name and for the value it's the one selected by the user,
now, on the server side, when the result is parsed, I've got a list of
items, how can I check
that an item is the hidden one ?
Post by Josselin Bardet
Hi
You can use the form input name to send informations for exemple
Post by Ousti Driss
Thank you for your answer Paul,
Your solution seems logical,
but in my case these other data, I need it from the first submit,
these data are basically type of file ...
I need it to store correctly the file in the database,
Moreover, on the client side a submit is not taken into account untill
all the other data are filled.
Post by Paul Robinson
You can store the file on the server in a temporary area, returning a
key to the UI. Then, when the user is ready to submit the lot, the UI sends
the file's key to the server as well as the other data.
The server can then move the file data to a permanent home, or mark it
as permanent.
Paul
Post by Ousti Driss
Hey guys,
While browsing on the internet I found a way to upload a file in a gwt app,
I managed to reimplement the code and it works just fine using formPanel,
It just happens that this file needs to be stored in a mysql database,
the problem is before the user selects the file he wants to upload, he
needs to pick up two elements from
2 combobox,
I need those informations so I can build my sql querry, How I can get
those fields selected by the user
in the upload File servlet?
Thanks a lot,
--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+***@googlegroups.com.
To post to this group, send email to google-web-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
Ousti Driss
2018-09-12 13:41:23 UTC
Permalink
let's say for example the user wants to upload a txt file, and he indicates
that it's a data file type,
I'm interested in the keyword (String) "data", how can I add it to the
formPanel?
can you give the java syntax ?
thank you

On Wed, Sep 12, 2018 at 3:27 PM Maarten Daalder (ISAAC Software Solutions) <
Post by Maarten Daalder (ISAAC Software Solutions)
In our case we place all elements to be 'uploaded' in the same FormPanel
as the file input element.
Then in our servlet we first retrieve all parts
(HttpServletRequest#getParts) after which we use getParameter to read out
the filled in form inputs.
The file itself is retrieved via a getPart(name of input here).
Post by Ousti Driss
I founnd something similar,
On the client side I instanciated hidden objects,
I gave them a name and for the value it's the one selected by the user,
now, on the server side, when the result is parsed, I've got a list of
items, how can I check
that an item is the hidden one ?
Post by Josselin Bardet
Hi
You can use the form input name to send informations for exemple
Post by Ousti Driss
Thank you for your answer Paul,
Your solution seems logical,
but in my case these other data, I need it from the first submit,
these data are basically type of file ...
I need it to store correctly the file in the database,
Moreover, on the client side a submit is not taken into account untill
all the other data are filled.
Post by Paul Robinson
You can store the file on the server in a temporary area, returning a
key to the UI. Then, when the user is ready to submit the lot, the UI sends
the file's key to the server as well as the other data.
The server can then move the file data to a permanent home, or mark it
as permanent.
Paul
Post by Ousti Driss
Hey guys,
While browsing on the internet I found a way to upload a file in a gwt app,
I managed to reimplement the code and it works just fine using formPanel,
It just happens that this file needs to be stored in a mysql database,
the problem is before the user selects the file he wants to upload,
he needs to pick up two elements from
2 combobox,
I need those informations so I can build my sql querry, How I can get
those fields selected by the user
in the upload File servlet?
Thanks a lot,
--
You received this message because you are subscribed to a topic in the
Google Groups "GWT Users" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/google-web-toolkit/AkZyroxa4E0/unsubscribe
.
To unsubscribe from this group and all its topics, send an email to
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+***@googlegroups.com.
To post to this group, send email to google-web-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
Maarten Daalder (ISAAC Software Solutions)
2018-09-12 14:10:41 UTC
Permalink
There is your basic
<g:FormPanel ui:field="formPanel" encoding="multipart/form-data"
method="POST">
<g:HTMLPanel>
<g:FileUpload name="data" ui:field="dataUpload" visible="false"
/><!-- not visible due to custom UI -->
<g:RadioButton stylePrimaryName="radio-check clearfix"
name="dataType" ui:field="textDataType" debugId="textDataType" text="Plain
text"/>
<g:RadioButton stylePrimaryName="radio-check clearfix"
name="dataType" ui:field="binaryDataType" debugId="binaryDataType"
text="Binary"/>
...
During setup/creation we programmatically assign the action via
formPanel.setAction.

In the end we do a formPanel.submit() when the user clicks on the upload
button.

On our servlet we have @MultipartConfig
Then our doPost:
Collection<Part> parts = request.getParts();
try {

checkXsrfToken(request);

try {
String dataType = request.getParameter("dataType");
Part data = request.getPart("data");
try (InputStream is = data.getInputStream()) {
Do your thing with the available data
}
} catch (... e) {
your error handling
}

} finally {
for (Part part : parts) {
try {
part.delete();
} catch (IOException e) {
logger.warn("Failed to delete part '{}' from server",
part.getName(), e);
}
}
}
Post by Ousti Driss
let's say for example the user wants to upload a txt file, and he
indicates that it's a data file type,
I'm interested in the keyword (String) "data", how can I add it to the
formPanel?
can you give the java syntax ?
thank you
On Wed, Sep 12, 2018 at 3:27 PM Maarten Daalder (ISAAC Software Solutions)
Post by Maarten Daalder (ISAAC Software Solutions)
In our case we place all elements to be 'uploaded' in the same FormPanel
as the file input element.
Then in our servlet we first retrieve all parts
(HttpServletRequest#getParts) after which we use getParameter to read out
the filled in form inputs.
The file itself is retrieved via a getPart(name of input here).
Post by Ousti Driss
I founnd something similar,
On the client side I instanciated hidden objects,
I gave them a name and for the value it's the one selected by the user,
now, on the server side, when the result is parsed, I've got a list of
items, how can I check
that an item is the hidden one ?
Post by Josselin Bardet
Hi
You can use the form input name to send informations for exemple
Post by Ousti Driss
Thank you for your answer Paul,
Your solution seems logical,
but in my case these other data, I need it from the first submit,
these data are basically type of file ...
I need it to store correctly the file in the database,
Moreover, on the client side a submit is not taken into account untill
all the other data are filled.
Post by Paul Robinson
You can store the file on the server in a temporary area, returning a
key to the UI. Then, when the user is ready to submit the lot, the UI sends
the file's key to the server as well as the other data.
The server can then move the file data to a permanent home, or mark
it as permanent.
Paul
Post by Ousti Driss
Hey guys,
While browsing on the internet I found a way to upload a file in a gwt app,
I managed to reimplement the code and it works just fine using formPanel,
It just happens that this file needs to be stored in a mysql database,
the problem is before the user selects the file he wants to upload,
he needs to pick up two elements from
2 combobox,
I need those informations so I can build my sql querry, How I can
get those fields selected by the user
in the upload File servlet?
Thanks a lot,
--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+***@googlegroups.com.
To post to this group, send email to google-web-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
Ousti Driss
2018-09-12 15:45:15 UTC
Permalink
Thank you Maarten,

I've got no more questions to ask!!

On Wed, Sep 12, 2018 at 4:11 PM Maarten Daalder (ISAAC Software Solutions) <
Post by Maarten Daalder (ISAAC Software Solutions)
There is your basic
<g:FormPanel ui:field="formPanel" encoding="multipart/form-data"
method="POST">
<g:HTMLPanel>
<g:FileUpload name="data" ui:field="dataUpload" visible="false"
/><!-- not visible due to custom UI -->
<g:RadioButton stylePrimaryName="radio-check clearfix"
name="dataType" ui:field="textDataType" debugId="textDataType" text="Plain
text"/>
<g:RadioButton stylePrimaryName="radio-check clearfix"
name="dataType" ui:field="binaryDataType" debugId="binaryDataType"
text="Binary"/>
...
During setup/creation we programmatically assign the action via
formPanel.setAction.
In the end we do a formPanel.submit() when the user clicks on the upload
button.
Collection<Part> parts = request.getParts();
try {
checkXsrfToken(request);
try {
String dataType = request.getParameter("dataType");
Part data = request.getPart("data");
try (InputStream is = data.getInputStream()) {
Do your thing with the available data
}
} catch (... e) {
your error handling
}
} finally {
for (Part part : parts) {
try {
part.delete();
} catch (IOException e) {
logger.warn("Failed to delete part '{}' from server",
part.getName(), e);
}
}
}
Post by Ousti Driss
let's say for example the user wants to upload a txt file, and he
indicates that it's a data file type,
I'm interested in the keyword (String) "data", how can I add it to the
formPanel?
can you give the java syntax ?
thank you
On Wed, Sep 12, 2018 at 3:27 PM Maarten Daalder (ISAAC Software
Post by Maarten Daalder (ISAAC Software Solutions)
In our case we place all elements to be 'uploaded' in the same FormPanel
as the file input element.
Then in our servlet we first retrieve all parts
(HttpServletRequest#getParts) after which we use getParameter to read out
the filled in form inputs.
The file itself is retrieved via a getPart(name of input here).
Post by Ousti Driss
I founnd something similar,
On the client side I instanciated hidden objects,
I gave them a name and for the value it's the one selected by the user,
now, on the server side, when the result is parsed, I've got a list of
items, how can I check
that an item is the hidden one ?
Post by Josselin Bardet
Hi
You can use the form input name to send informations for exemple
Post by Ousti Driss
Thank you for your answer Paul,
Your solution seems logical,
but in my case these other data, I need it from the first submit,
these data are basically type of file ...
I need it to store correctly the file in the database,
Moreover, on the client side a submit is not taken into account
untill all the other data are filled.
Post by Paul Robinson
You can store the file on the server in a temporary area, returning
a key to the UI. Then, when the user is ready to submit the lot, the UI
sends the file's key to the server as well as the other data.
The server can then move the file data to a permanent home, or mark
it as permanent.
Paul
Post by Ousti Driss
Hey guys,
While browsing on the internet I found a way to upload a file in a gwt app,
I managed to reimplement the code and it works just fine using formPanel,
It just happens that this file needs to be stored in a mysql database,
the problem is before the user selects the file he wants to upload,
he needs to pick up two elements from
2 combobox,
I need those informations so I can build my sql querry, How I can
get those fields selected by the user
in the upload File servlet?
Thanks a lot,
--
You received this message because you are subscribed to a topic in the
Google Groups "GWT Users" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/google-web-toolkit/AkZyroxa4E0/unsubscribe
.
To unsubscribe from this group and all its topics, send an email to
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+***@googlegroups.com.
To post to this group, send email to google-web-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
Loading...