In continuation of my research on the topic I placed one button that
hardcoded downloads one file. The button is on the form.
So in the function
public boolean activatePage(ComponentResources pageResources,
EventContext activationContext,
ComponentEventResultProcessor resultProcessor) throws
IOException
the following line's resultProcessor :
TrackableComponentEventCallback callback = new
ComponentResultProcessorWrapper(resultProcessor);
is of as eclipse reports:
<Proxy for
ComponentEventResultProcessor(org.apache.tapestry5.services.ComponentEventResultProcessor)>
When I try to download a file from the TreeBrowser links the
resultProcessor eclipse reports :
org.apache.tapestry5.internal.services.AjaxComponentEventRequestHandler$1@427301fe
So...it seems that when I click the link from the TreeBrowser the
download response is not intercepted as expected. Though I didn't use
mixin or zones....I don't understand the "ajax" part.
Is it possible someone to know more ?
Dimitris
On 2016-02-12 16:50, h3ph3st0s wrote:
Hi,
The thing is that I see the tree of directories and files. That's
awesome.
But to download file really, I need to right click and choose the
"save target as....". Then file dialog pops up and I can download
really the file to my client disk.
If I don't, the response is getting some how lost in the communication
since I have error like this:
*Communication with the server failed: TypeError: Unable to get
property 'redirectURL' of undefined or null *
It seems for me that, the StreamResponse expects something as output,
which in the Jumpstart tutorial is there but I can not see it myself.
On the other hand I need to trigger somehow this file dialog in order
to allow user choose the folder to leave the file.
Dimitris
On 2016-02-12 16:32, Nathan Quirynen wrote:
You mean the file gets downloaded immediately to some download folder?
I think this is a setting of the used browser where a default
location has been set opposed to the setting where the browser will
always ask for the location.
So I'm afraid you don't really have control over this if I am correct.
Nathan
On 12/02/16 15:15, h3ph3st0s wrote:
Hi,
I am new to Tapestry version 5. where I built a treemodel, which
presents the files inside the catalog,
/<t:tree t:id="tree" t:model="stuffModel" t:node="treeNode"
t:value="classificationNode">
<p:label>
<t:if test="treeNode.leaf">
<a t:type="EventLink"
t:event="leafSelected" t:context="classificationNode.name"
t:zone="selectedZone" class="prop:leafClass"
href="#">
${treeNode.label}
</a>
</t:if>
<t:if test="!treeNode.leaf">
${treeNode.label}
</t:if>
</p:label>
</t:tree>/
and by clicking one of the files I build a StreamResponse ( I used
the snippet from the jumpstart code ( page:
http://jumpstart.doublenegative.com.au/jumpstart/examples/navigation/returntypes1
)
The function is :
/public Object onLeafSelected(final String classificationId) {
System.out.println(classificationId);
System.out.println(regFile.get(classificationId));
final File file = new File( regFile.get(classificationId) );
return new StreamResponse() {
InputStream inputStream;
@Override
public void prepareResponse(Response response) {
ClassLoader classLoader =
Thread.currentThread().getContextClassLoader();
try {
inputStream = new FileInputStream(file);
try {
response.setHeader("Content-Length", "" +
inputStream.available());
}
catch (IOException e) {
// Ignore the exception in this simple example.
}
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}//classLoader.getResourceAsStream(regFile.get(classificationId));
// Set content length to prevent chunking - see
//
http://tapestry-users.832.n2.nabble.com/Disable-Transfer-Encoding-chunked-from-StreamResponse-td5269662.html#a5269662
}
@Override
public String getContentType() {
return "text/plain";
}
@Override
public InputStream getStream() throws IOException {
return inputStream;
}
};
}/
My problem and my question is how do I present a save-file-dialog
that will help the user to point the download folder. In order to
really download the file I must make right-click and then choose
"save file as..." ?
Thanks in advance
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org