Re: Save File Dialog after response building

2016-02-12 Thread h3ph3st0s

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:value="classificationNode">



t:event="leafSelected" t:context="classificationNode.name" 
t:zone="selectedZone" class="prop:leafClass"

href="#">
${treeNode.label}



${treeNode.label}


/

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






Re: Save File Dialog after response building

2016-02-12 Thread Nathan Quirynen

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:value="classificationNode">



t:event="leafSelected" t:context="classificationNode.name" 
t:zone="selectedZone" class="prop:leafClass"

href="#">
${treeNode.label}



${treeNode.label}


/

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



Save File Dialog after response building

2016-02-12 Thread h3ph3st0s

Hi,

I am new to  Tapestry version 5. where I built a treemodel, which 
presents the files inside the catalog,


/t:value="classificationNode">



t:event="leafSelected" t:context="classificationNode.name" 
t:zone="selectedZone" class="prop:leafClass"

href="#">
${treeNode.label}



${treeNode.label}


/

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



Re: Save File Dialog after response building

2016-02-12 Thread h3ph3st0s
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:
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 zonesI 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:value="classificationNode">



t:event="leafSelected" t:context="classificationNode.name" 
t:zone="selectedZone" class="prop:leafClass"

href="#">
${treeNode.label}



${treeNode.label}


/

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, 

Re: Save File Dialog after response building

2016-02-12 Thread Kalle Korhonen
Yes, so if you respond to an ajax request with a page response, T5 will
send you a json snippet {"redirectURL" : "your.redirect.url"} and handles
redirecting to it from the client. In this case you are responding with a
StreamResponse so T5 gets confused. If you wanted to do an ajax update,
it's totally possible. You just need to move your StreamResponse to a new
page and return (a link to) this page from your event handler. The possible
advantage is that you can have testable download urls for your files, like
/downloadfile/somefile.tmp.

The DownloadFile page would simply contain something like this:

public class DownloadFile {
StreamResponse onActivate(String fileId) throws IOException {
return new StreamResponse() {...}
}
}

Your event handler should return a page object or an URL, check
http://tapestry.apache.org/page-navigation.html for more info.

Kalle



On Fri, Feb 12, 2016 at 1:46 PM, h3ph3st0s  wrote:

> Found the solution. I did have the zone part. So it was really ajax call.
> ( But this is as defined from the tutorial ).
> I removed that and now this works smoothly.
>
> As a case is closed from me. But what if I put back the zone in order to
> update in ajax way the form ?
>
> Best regards, happy to test a very simple framework such as this
>
> 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:value="classificationNode">
 
 
 >>> t:event="leafSelected" t:context="classificationNode.name"
 t:zone="selectedZone" class="prop:leafClass"
 href="#">
 ${treeNode.label}
 
 
 
 ${treeNode.label}
 
 
 /

 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

 }


Re: Save File Dialog after response building

2016-02-12 Thread h3ph3st0s
Found the solution. I did have the zone part. So it was really ajax 
call. ( But this is as defined from the tutorial ).

I removed that and now this works smoothly.

As a case is closed from me. But what if I put back the zone in order to 
update in ajax way the form ?


Best regards, happy to test a very simple framework such as this

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:value="classificationNode">



t:event="leafSelected" t:context="classificationNode.name" 
t:zone="selectedZone" class="prop:leafClass"

href="#">
${treeNode.label}



${treeNode.label}


/

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








-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org