incubator-adffaces-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Döring Markus <>
Subject Wrong action called
Date Wed, 10 Jan 2007 10:13:21 GMT

I'm using myfaces, Trinidad (snapshot M1) and facelets on a tomcat 5.5 webserver.


Because I'm not sure if this is a MyFaces or a Trinidad issue I write on both lists.


On one of my pages I have an <tr:selectOneChoice> to set an filter on a list of datas.
Below it I have a <tr:table> to display the data itself. In the table there are download-links
(<tr:commandLink>) for every row in the table.


All works fine: setting the filter, displaying the table and downloading the data via the

But if I first download data and than change the filter, the action from the download link
is called again (the valueChangeListener is called, too)


Here are some code snippets:


            //facelet file


            <tr:selectOneChoice label="select filter"

                  id="event" autoSubmit="false" onchange="submit()"


                  <f:selectItems value="#{globalProperties.filterTypes}" />


            <tr:table value="#{dataBean.dataList}" var="data">


                        <f:facet name="header">

                             <tr:outputText value="#{id}" />


                        <tr:outputText value="#{}" />




                  // (some more columns)




                        <f:facet name="header">

                             <tr:outputText value="data" />


                        <tr:commandLink text="download}">

                             <tr:setActionListener  //only used to get the correct id from
what to download


                                   to="#{dataBean.downloadId}" />


                                   type="de.tccproducts.dprs.basicstats.DataBean" />






      //action Listener methods

      public void processAction(ActionEvent event)

                  throws AbortProcessingException {


// get the current data Object

            Data data = getData();


// get the byte array that should be downloaded

            byte[] data = data.getByteData();


// set mime type and filename

            FacesContext context = FacesContext.getCurrentInstance();

            HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();


            response.setHeader("Content-Disposition", "attachment;filename=\"someTestFile.txt\"");


// append the byte[] to the response

            ByteArrayInputStream fis = new ByteArrayInputStream(data);

            try {

                  OutputStream os = response.getOutputStream();

                  int read = 0;

                  byte[] bytes = new byte[1024];

                  while ((read = != -1) {

                        os.write(bytes, 0, read);




            } catch (Exception ex) {








      public void filterChangeEvent(ValueChangeEvent ev) {


            // get the selected value from selectOneChoice

            String key = ev.getComponent().getAttributes().get("id").toString();

            FilterType filter = (FilterType) ev.getComponent().getAttributes().get("value");


            // set the filter and update the dataList





My thought is that the commandLink sets some hidden input fields to say the server what to
download. The download is done but the page is not reloaded and so the hidden input fields
stay as they are.

When the valueChangeListener is called, the Server recognises the hidden fields again, and
so executes the commandLink Action again.


What can I do to avoid this?

Force a refresh on the page after download is done?

Reset the hidden input fields in some way?

Check in the download action if it really should be executed?

Or is there some other problem I don't see at the moment?


Please help if you have an idea on this.



  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message