Right - I have a work around. It's a bit cumbersome but works well and avoids
the need to create a custom export servlet. It involves Rest Faces so I will
go through what I have done to hopefully let others avoid the pain and
frustration!

- First I added the restfaces libs to my project (see
https://restfaces.dev.java.net/ for further info).
- Add a new XML to the WEB-INF dir called rest-faces-rules.xml. Mine has the
following content:

<?xml version="1.0" encoding="UTF-8"?>

<rest-faces>

  <action name="exportpo" value="#{exportBean.downloadPO}">
    <property param="poid" value="#{exportBean.purchaseOrderId}"/>
    <navigation-case>
      <from-outcome>*</from-outcome>
      <to-view-id>/maintainpurchaseorder.jsp</to-view-id>
    </navigation-case>
  </action>

</rest-faces>

- I added a new Export Bean with request scope and moved my downloadPO
method there as there will be other downloads required within the app. 

- I added the rest faces taglib to the calling page:

<%@ taglib uri="http://restfaces.dev.java.net"; prefix="rest" %>

- I replaced the troublesome commandlink with the following:

<rest:link value="/exportpo.jsf">
  <h:outputText value="Download PDF"/>
  <f:param value="#{maintainPurchaseOrderBean.purchaseOrder.id}"
name="poid"/>
</rest:link>

- Note that the Export bean did not need to have the purchase order id
defined as a managed property in the faces-config.xml as the rest-faces
config must have done this wiring for me. There is no additional config
required to get rest-faces up and running. 

This is my first attempt with rest faces, and although it may not be the
most elegant way of achieving my goal, it works.

If anybody does have a solution to make the standard commandlink work I
would still be very happy to hear it!

Cheers, Carl

-- 
View this message in context: 
http://www.nabble.com/commandLink-commandButton-differences-in-file-download-behaviour-problem-tf2375460.html#a13874507
Sent from the MyFaces - Users mailing list archive at Nabble.com.

Reply via email to