1 Reply Latest reply on Jan 22, 2009 10:59 PM by Daniel Deneka

    Problem accessing DataModel field when generating a PDF

    Anthony Ogier Newbie

      My goal is to create a PDF containing all the products ordered from my orderHome page.

      The problem is that the @DataModel field from the OrderHome object can be accessed from the HTML view, but not for the PDF view. I've got the following Error :

      /pdf/order/printOrder.xhtml @171,62 <c:forEach items="#{orderLines}"> Must evaluate to a Collection, Map, Array, or null.

      My question is : is there any problem with @DataModel (which is here in Conversation context, as its owner class) and PDF generated with <p:document/> tag ?

      Here is the orderHome.xml file :

      <ui:composition ... >
        <rich:dataTable value="#{orderLines}" ...>
          <rich:column ...>
        <h:commandButton value="#{messages['order.print']}" action="#{OrderHome.print()}"/>

      The OrderHome.java file :

      public class OrderHome extends EntityHome<Order> {
        protected List<OrderLine> orderLines;
        protected void initInstance() {
        public void initOrderProducts() {
          orderedProducts = getInstance().getOrderLines()
        public void print() {
          computeTotalOrder(); // specific method
        private void computeTotalOrder() {
          double total = 0;
          for(final OrderLine orderLine : orderLines) {
            total += orderLine.getPrice();

      The orderHome.page.xml file :

      <?xml ...?>
      <page ...>
        <begin-conversation join="true" flush-mode="manual" />
        <navigation from-action="#{orderHome.print()}">
          <redirect view-id="/pdf/order/printOrder.xhtml"/>

      And finaly the printOrder.xhtml page :

      <p:document ...>
        <c:forEach items="#{orderLines}" var="orderLine">

      I've googled for a long time and already tried to replace my <h:commandButton> with some <s:link> or <a:commandButton>, but nothing changed ...