<tr:document>
<tr:form>
<tr:commandButton text="Download file">
<tr:fileDownloadActionListener
filename="#{downloadBean.fileName}"
contentType="#{downloadBean.contentType}"
method="#{downloadBean.sayHello}"/>
</tr:commandButton>
</tr:form>
</tr:document>
is enough?
Scott O'Bryan wrote:
>
> You need a tr:form.
>
> Sent from my iPhone
>
> On Jun 17, 2011, at 8:37 AM, jitechno <[email protected]> wrote:
>
>>
>> hello Martin,
>> now I want only determine is next fragment of code appropriate or not:
>> if no, what I have change to fire download dialog?
>>
>> <tr:document>
>> <tr:commandButton text="Download file">
>> <tr:fileDownloadActionListener
>> filename="#{downloadBean.fileName}"
>>
>> contentType="#{downloadBean.contentType}"
>>
>> method="#{downloadBean.sayHello}"/>
>> </tr:commandButton>
>> </tr:document>
>>
>>
>> inside Firefox -> Tools -> Error Console I see this message;
>> Error: _checkLoad is not defined
>> Source File: http://localhost:8080/TrinidadUpload/faces/download.jsp
>> Line: 1
>>
>> it is not so informative to debug...
>> regards
>>
>>
>> Martin Koci-2 wrote:
>>>
>>> Hi,
>>>
>>> jitechno píše v Pá 17. 06. 2011 v 01:41 -0700:
>>>> Scott, may be, there is a little misunderstanding. My question is not
>>>> about
>>>> debugging and reverse engineering, but about general approach.
>>>> I am trying realize example from "official" Trinidad's page. At least,
>>>> I
>>>> am
>>>> considering as official. Am I right?
>>>>
>>>> http://myfaces.apache.org/trinidad/trinidad-api/tagdoc/tr_fileDownloadActionListener.html
>>>>
>>>> Usually, such examples give a good base to start with more deep
>>>> development. In this case, it is no.
>>>> This example doesnot cover complete solution, or obsolete, or belongs
>>>> to
>>>> other version.
>>>
>>> That example is ok, we use it over 4 years in many production systems.
>>>
>>>> I have not time to explore ans investigate basic elementary
>>>> construction,
>>>> it is not a subject of research for programmer. May be, I am wrong or
>>>> my
>>>> understanding of myfaces.apache's policy is incorrect?
>>>>
>>>> I dont know which tag is giving the problems, because I dont see any
>>>> action
>>>> after clicking on commandLink or button, inside form or outside. Also I
>>>> dont
>>>> see any exceptions/messages form Tomcat.
>>>
>>> Firefox -> Tools -> Error Console. You'll see javascripts errors. The
>>> main probem is that you have no tag for including resources in your
>>> view. In case of JSP, use tr:document as Scott suggests. I case of
>>> facelets, you can use tr:document too or new h:head/h:body tags. Anyway,
>>> please read this resource:
>>> http://andyschwartz.wordpress.com/2009/07/31/whats-new-in-jsf-2/#resource-loading
>>>
>>> Regards,
>>>
>>> Kočičák
>>>
>>>> Regards
>>>> Oleg
>>>>
>>>>
>>>> Scott O'Bryan wrote:
>>>>>
>>>>> Oleg, events usually require a form in order to submit the data needed
>>>>> to process the event. Additionally, which tag is giving you the
>>>>> problems? To debug this problem, I would start by trying a simpler
>>>>> page without mixing render kits and then go from there. Use the
>>>>> <tr:document> tag at the root, include to form, and so on. Once you
>>>>> do this, you can reverse engineer your app to see what's happening.
>>>>> Understand also that JSF and TRINIDAD also have replacements for some
>>>>> elements that you usually use with HTML. You need to use these
>>>>> replacements for things to get inserted properly.
>>>>>
>>>>> Scott
>>>>>
>>>>> Sent from my iPad
>>>>>
>>>>> On Jun 16, 2011, at 2:18 AM, jitechno <[email protected]> wrote:
>>>>>
>>>>>>
>>>>>> 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.
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/What-is-wrong-with-Trinidad%27s-download-example--tp31851629p31869565.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--tp31851629p31869649.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.