You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by James Sherwood <js...@romulin.com> on 2004/10/15 20:26:57 UTC

Another file serve question:

I have the file service working except for a few bugs:

1:When the file comes out to download it's name is the servlet name in the
web.xml
2: Zip files are corrupt(maybe because of the name?)

Does anyone know how to change the name of the name in the save box that
comes up?

The code(dummed down version without the security checks) I use is:

public void service(

IEngineServiceView engineView,

IRequestCycle cycle,

ResponseOutputStream out)

throws ServletException, IOException {

String[] args = getServiceContext(cycle.getRequestContext());

if (args == null || args.length != 1) {

return;

}

try {

Files file = FilesPeer.retrieveByPK(Integer.parseInt(args[0]));

Fileblob fb = (Fileblob) file.getFileblobs().get(0);

//content type is taken from a huge static content type hashmap

out.setContentType((String)_mimeTypes.get(file.getExtension().toLowerCase())
);


out.forceFlush();

//fb.getFile() returns a byte[]

out.write(fb.getFile());

} catch (Exception e) {

e.printStackTrace();

return;

}

out.flush();

out.close();

}





---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Another file serve question:

Posted by Paul Ferraro <pm...@columbia.edu>.
Try this:
cycle.getRequestContext().getResponse().setHeader("Content-Disposition", 
"attachment; filename=myfilename.doc");

Paul

James Sherwood wrote:

>I have the file service working except for a few bugs:
>
>1:When the file comes out to download it's name is the servlet name in the
>web.xml
>2: Zip files are corrupt(maybe because of the name?)
>
>Does anyone know how to change the name of the name in the save box that
>comes up?
>
>The code(dummed down version without the security checks) I use is:
>
>public void service(
>
>IEngineServiceView engineView,
>
>IRequestCycle cycle,
>
>ResponseOutputStream out)
>
>throws ServletException, IOException {
>
>String[] args = getServiceContext(cycle.getRequestContext());
>
>if (args == null || args.length != 1) {
>
>return;
>
>}
>
>try {
>
>Files file = FilesPeer.retrieveByPK(Integer.parseInt(args[0]));
>
>Fileblob fb = (Fileblob) file.getFileblobs().get(0);
>
>//content type is taken from a huge static content type hashmap
>
>out.setContentType((String)_mimeTypes.get(file.getExtension().toLowerCase())
>);
>
>
>out.forceFlush();
>
>//fb.getFile() returns a byte[]
>
>out.write(fb.getFile());
>
>} catch (Exception e) {
>
>e.printStackTrace();
>
>return;
>
>}
>
>out.flush();
>
>out.close();
>
>}
>
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Another file serve question:

Posted by Lars Hoss <wo...@acidware.net>.
> 1:When the file comes out to download it's name is the servlet name in 
> the
> web.xml

Simple trick:

Just assign the servlet to /files/* and produce links such as 
/files/<filename>.

Yours
Lars


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


RE: Help with Contrib Table

Posted by Lindsay Steele <ls...@iinet.net.au>.
Try using <span jwcid="table@contrib:Table"

  Notice the : instead of the . 


-----Original Message-----
From: Timothy McKnight [mailto:tamcknight@sbcglobal.net] 
Sent: Sunday, 17 October 2004 7:53 AM
To: Tapestry users
Subject: Help with Contrib Table


Hello,

When I build the following Web app using Contrib Table
i get "Tag <span> on line 16 contains an invalid jwcid
'table@contrib.Table'."...

ognl:completeStatsList is a LinkedList of
IndividualStats

<span jwcid="table@contrib.Table" 
    width="90%"  
    source="ognl:completeStatsList" 
    columns="Place, Name, Score, Location"/>

<property-specification name="statsList"
type="java.util.List" persistent="yes"/> <property-specification
name="istats" type="com.mikesamuse.components.IndividualStats"/>


package com.mikesamuse.components;

import java.io.Serializable;
public class IndividualStats implements Serializable {
	
	private String mPlace;
	private String mName;
	private String mScore;
	private String mLocation;
	
	public IndividualStats(String aPlace, String aName,
String aScore, String aLocation){
		
		this.mPlace = aPlace;
		this.mName = aName;
		this.mScore = aScore;
		this.mLocation = aLocation;
	}
	public String getLocation() {
		return mLocation;
	}
	public String getName() {
		return mName;
	}
	public String getPlace() {
		return mPlace;
	}
	public String getScore() {
		return mScore;
	}
}

       
I have contrib defined in my .application file.  
<library id="contrib"
specification-path="/org/apache/tapestry/contrib/Contrib.library"/>
And the contrib jar file is in my classpath.

Even a good example will be appreciated.

Thanks,
Tim

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Help with Contrib Table

Posted by Timothy McKnight <ta...@sbcglobal.net>.
Hello,

When I build the following Web app using Contrib Table
i get "Tag <span> on line 16 contains an invalid jwcid
'table@contrib.Table'."...

ognl:completeStatsList is a LinkedList of
IndividualStats

<span jwcid="table@contrib.Table" 
    width="90%"  
    source="ognl:completeStatsList" 
    columns="Place, Name, Score, Location"/>

<property-specification name="statsList"
type="java.util.List" persistent="yes"/>
<property-specification name="istats"
type="com.mikesamuse.components.IndividualStats"/>


package com.mikesamuse.components;

import java.io.Serializable;
public class IndividualStats implements Serializable {
	
	private String mPlace;
	private String mName;
	private String mScore;
	private String mLocation;
	
	public IndividualStats(String aPlace, String aName,
String aScore, String aLocation){
		
		this.mPlace = aPlace;
		this.mName = aName;
		this.mScore = aScore;
		this.mLocation = aLocation;
	}
	public String getLocation() {
		return mLocation;
	}
	public String getName() {
		return mName;
	}
	public String getPlace() {
		return mPlace;
	}
	public String getScore() {
		return mScore;
	}
}

       
I have contrib defined in my .application file.  
<library id="contrib"
specification-path="/org/apache/tapestry/contrib/Contrib.library"/>
And the contrib jar file is in my classpath.

Even a good example will be appreciated.

Thanks,
Tim

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org