Cedric, why I need form tag here?
I dont think so. because no need to use form and submit for download file in
browser.
But tr:form is not solution, still the same behavior.
<body>
<f:view>
<h1><h:outputText value="JSF 2.0 + Trinidad 2.0"/></h1>
<tr:form id="downloadForm" >
<h:commandButton value="Download" styleClass="submit_button">
<tr:fileDownloadActionListener
filename="#{downloadBean.fileName}"
contentType="#{downloadBean.contentType}"
method="#{downloadBean.sayHello}"/>
</h:commandButton>
<tr:commandLink text="Download file">
<tr:fileDownloadActionListener
filename="hello.txt"
contentType="text/plain; charset=utf-8"
method="#{downloadBean.sayHello}"/>
</tr:commandLink>
</tr:form>
</f:view>
</body>
regards
Oleg
Cédric Durmont wrote:
>
> Ooops, looks like <tr:form> is missing...
>
> Regards,
> Cedric
>
> 2011/6/15 jitechno <[email protected]>:
>>
>> Hello,
>> I tried this example,
>> http://myfaces.apache.org/trinidad/trinidad-api/tagdoc/tr_fileDownloadActionListener.html
>>
>> Not with commandLine, not with commandButton I am nat able to fire file
>> save
>> dialog. No exceptions, no actions, nothing. Please, advice me, what is
>> wrong
>> here?
>> Thanks in advance
>>
>> <f:view>
>> <h:commandButton value="Download" styleClass="submit_button">
>> <tr:fileDownloadActionListener
>> filename="#{downloadBean.fileName}"
>>
>> contentType="#{downloadBean.contentType}"
>>
>> method="#{downloadBean.sayHello}"/>
>> </h:commandButton>
>>
>> <tr:commandLink text="Download file">
>> <tr:fileDownloadActionListener
>> filename="hello.txt"
>> contentType="text/plain; charset=utf-8"
>> method="#{downloadBean.sayHello}"/>
>> </tr:commandLink>
>> </f:view>
>> ------------------------------------------------------------------
>> faces-config contains
>> <managed-bean>
>> <managed-bean-name>downloadBean</managed-bean-name>
>> <managed-bean-class>Beans.DownloadBean</managed-bean-class>
>> <managed-bean-scope>request</managed-bean-scope>
>> <managed-property>
>> <property-name>text</property-name>
>> <value>Hi there!</value>
>> </managed-property>
>> <managed-property>
>> <property-name>contentType</property-name>
>> <value>text/plain; charset=utf-8</value>
>> </managed-property>
>> <managed-property>
>> <property-name>fileName</property-name>
>> <value>hello.txt</value>
>> </managed-property>
>> </managed-bean>
>> --------------------------------------------------------------------------------------------
>> DownloadBean is here:
>> package Beans;
>>
>> import java.io.IOException;
>> import java.io.OutputStream;
>> import java.io.OutputStreamWriter;
>> import javax.faces.context.FacesContext;
>>
>> public class DownloadBean implements java.io.Serializable{
>>
>> public DownloadBean() {
>> }
>> private String text;
>> public void setText(String text){
>> this.text = text;
>> }
>> public String getText(){
>> return this.text;
>> }
>>
>> private String fileName;
>> public void setFileName(String fileName){
>> this.fileName = fileName;
>> }
>> public String getFileName(){
>> return this.fileName;
>> }
>> private String contentType;
>> public void setContentType(String contentType){
>> this.contentType = contentType;
>> }
>> public String getContentType(){
>> return this.contentType;
>> }
>> public void sayHello(FacesContext context, OutputStream out) throws
>> IOException
>> {
>> System.out.println("sy Hello "+ getFileName()+" "+getContentType());
>> OutputStreamWriter w = new OutputStreamWriter(out, "UTF-8");
>> w.write(getText());
>> // The stream is automatically closed, but since we wrapped it,
>> // we'd better flush our writer
>> w.flush();
>> }
>> }
>> --
>> View this message in context:
>> http://old.nabble.com/What-is-wrong-with-Trinidad%27s-download-example--tp31851629p31851629.html
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
>
>
--
View this message in context:
http://old.nabble.com/What-is-wrong-with-Trinidad%27s-download-example--tp31851629p31858292.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.