Hi all,

I'm experiencing a little difficulty in getting SEAM's PDF functionality to 
work.

I can get what I want if I put all my variables into a SESSION scope. But as 
soon as I want to try use a CONVERSATION scope the PDF has no data in it.

Now I'm assuming that this is because of the way that PDF's are handled. So, I 
guess my question is, What is the work around? 

I have a page where users search for records based on some criteria. My aim is 
to have a button on the page which will generate a PDF document with these 
results in them and display them in an iframe or equivalent below, allowing 
them to get a print friendly version of the records.

Currently I'm experiencing considerable difficulty in passing data to the xhtml 
page where my pdf is defined.

here is some of the more necessary code

Don't worry too much about the reference to GekkoReport it is just a bunch of 
getters and setters at the moment.


  | package gekko.web.actionbean.enquiry;
  | 
  | import static org.jboss.seam.ScopeType.CONVERSATION;
  | import static org.jboss.seam.ScopeType.PAGE;
  | import static org.jboss.seam.ScopeType.SESSION;
  | import gekko.domain.calculator.ltlr.UvAveraging;
  | import gekko.domain.reference.ltl.SubcategoryCode;
  | import gekko.web.actionbean.search.CatSubcatDateSearch;
  | import gekko.web.services.GekkoReport;
  | 
  | import java.util.HashMap;
  | import java.util.List;
  | 
  | import org.jboss.seam.annotations.Begin;
  | import org.jboss.seam.annotations.In;
  | import org.jboss.seam.annotations.Name;
  | import org.jboss.seam.annotations.Out;
  | import org.jboss.seam.annotations.Scope;
  | import org.jboss.seam.annotations.datamodel.DataModel;
  | import org.jboss.seam.annotations.datamodel.DataModelSelection;
  | 
  | 
  | @Name("averagingEnquiry")
  | @Scope(PAGE)
  | public class AveragingEnquiry {
  |     
  |     @Out(required=false, scope=SESSION, value="gekkoPDFReport")
  |     @In(create=true, value="gekkoReport")
  |     private GekkoReport gekkoPDFReport;
  |     
  |     @Out(required=false, scope=SESSION, value="searchResults")
  |     private List<UvAveraging> searchResults;
  |     
  |     @In(value="#{catSubcatDateSearch}", create=true, scope=CONVERSATION)
  |     private CatSubcatDateSearch searchBean; //NOPMD
  |     
  |     @DataModel(value="averagingEnquiry_uvAveragings")
  |     private List<UvAveraging> uvAveragingList;
  |     
  |     @DataModelSelection(value="averagingEnquiry_uvAveragings")
  |     @Out(required=false, scope=CONVERSATION, 
value="averagingEnquiry_uvAveraging")
  |     private UvAveraging uvAveraging;
  |     
  |     @Out(required=false, scope=CONVERSATION, value="selectedSubcategory")
  |     private SubcategoryCode selectedSubcategory;
  |     
  |     private boolean showReport = false;
  |     
  |     ....getters and setters...
  | 
  |     @Begin(join=true)
  |     public String editUvAveraging() {
  |             selectedSubcategory = uvAveraging.getSubcategory();
  |             return "createEditAveraging";
  |     }
  |     
  |     @Begin(join=true)
  |     public String createUvAveraging() {
  |             uvAveraging = new UvAveraging();
  |             selectedSubcategory = new SubcategoryCode();
  |             return "createEditAveraging";
  |     }
  | 
  |     public boolean getShowReport() {
  |             return showReport;
  |     }
  |     
  |     @Begin(join=true)
  |     public void displayReport() {
  |             HashMap<String, String> criteria = new HashMap<String, 
String>();
  |             criteria.put("Category", 
searchBean.getCatSubcatEnquiry().getCategoryCode().getName());
  |             
  |             //TODO: do criteria a better way
  |             
  |             gekkoPDFReport.setCriteria(criteria);
  |             searchResults = uvAveragingList;
  |                             
  |             showReport = true;
  |     }
  |     
  |     public void hideReport() {
  |             showReport = false;
  |     }
  |     
  | }
  | 

The search page

  | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
  | <html xmlns="http://www.w3.org/1999/xhtml";
  |       xmlns:ui="http://java.sun.com/jsf/facelets";
  |       xmlns:h="http://java.sun.com/jsf/html";
  |       xmlns:f="http://java.sun.com/jsf/core";
  |       xmlns:rich="http://richfaces.org/rich";
  |       xmlns:a4j="https://ajax4jsf.dev.java.net/ajax";
  |       xmlns:s="http://jboss.com/products/seam/taglib";
  |       xmlns:gekko="http://gekkoTagLibs.com";
  |       xmlns:c="http://java.sun.com/jstl/core";>
  |     
  |     <ui:composition template="/web/templates/gekkoTemplate.xhtml">
  |             <ui:define name="title">Average Years Enquiry</ui:define>
  |             <ui:define name="titlebar">Average Years Enquiry</ui:define>
  |             <ui:define name="content">
  |                     <ui:decorate 
template="/web/compositions/search/catSubcatDateSearch.xhtml">
  |                             <ui:define name="cScSearchCommand">
  |                                     <h:commandButton 
id="averagingCScSearchCommand"
  |                                                     value="Search"
  |                                                     
action="#{averagingEnquiry.getUvAveragings}">
  |                                             <gekko:defaultAction/>
  |                                     </h:commandButton>
  |                             </ui:define>
  |                     </ui:decorate>  
  |                     
  |                     <h:form id="results" styleClass="resultsForm">
  |                             <rich:panel header="Averagings">
  |                                     <rich:dataTable id="averagingTable"
  |                                                     
value="#{averagingEnquiry_uvAveragings}"
  |                                                     var="uvAveraging"
  |                                                     style="width:100%;"
  |                                                     rows="20">
  |                                             <f:facet name="header">
  |                                                     <rich:columnGroup>
  |                                                             <rich:column>
  |                                                                     
<rich:spacer width="2px;"/>
  |                                                             </rich:column>
  |                                                             <rich:column>
  |                                                                     
<h:outputText value="Num Years"/>
  |                                                             </rich:column>
  |                                                             <rich:column>
  |                                                                     
<h:outputText value="Effective Date"/>
  |                                                             </rich:column>
  |                                                             <rich:column>
  |                                                                     
<h:outputText value="Expiry Date"/>
  |                                                             </rich:column>
  |                                                             <rich:column>
  |                                                                     
<h:outputText value="Comment"/>
  |                                                             </rich:column>
  |                                                     </rich:columnGroup>
  |                                             </f:facet>
  |     
  |                                             <rich:column>
  |                                                     <h:commandLink 
value="Edit" action="#{averagingEnquiry.editUvAveraging}"/>
  |                                             </rich:column>
  |                                             <rich:column>
  |                                                     <h:outputText 
value="#{uvAveraging.years}"/>
  |                                             </rich:column>
  |                                             <rich:column>
  |                                                     <h:outputText 
value="#{uvAveraging.effective}"/>
  |                                             </rich:column>
  |                                             <rich:column>
  |                                                     <h:outputText 
value="#{uvAveraging.expiry}"/>
  |                                             </rich:column>
  |                                             <rich:column>
  |                                                     <h:outputText 
value="#{uvAveraging.comment}"/>
  |                                                     <rich:spacer 
rendered="#{empty uvAveraging.comment}"/>
  |                                             </rich:column>
  |                                             
  |                                             <f:facet name="footer">
  |                                                     <rich:columnGroup>
  |                                                             <rich:column 
colspan="5">
  |                                                                     
<rich:datascroller align="left" for="averagingTable" 
renderIfSinglePage="false"/>
  |                                                             </rich:column>
  |                                                     </rich:columnGroup>
  |                                             </f:facet>
  |                                             
  |                                     </rich:dataTable>
  |                                     
  |                                     <a4j:commandButton id="reportButton" 
value="Report" reRender="pdfReportForm" 
action="#{averagingEnquiry.displayReport}"/>
  |                                     <h:commandButton id="newButton" 
action="#{averagingEnquiry.createUvAveraging}" value="New"/>
  |                             </rich:panel>
  |                     </h:form>
  |                     <a4j:log/>
  |             </ui:define>
  | 
  |             
  |             <ui:define name="pdfReport">
  |                     <h:form id="pdfReportForm">
  |                             <rich:panel header="Report" 
rendered="#{averagingEnquiry.showReport}">
  |                                     <f:facet name="header">
  |                                             <h:outputText value="Report"/>
  |                                             <a4j:commandLink 
action="#{averagingEnquiry.hideReport}"
  |                                                             value="Hide 
Report"
  |                                                             
reRender="pdfReportForm"/>
  |                                     </f:facet>
  |                                     <iframe frameborder="0" width="98%" 
height="600" src="/gekko-tje/web/reports/averageYearsReport.jsf" />
  |                     </rich:panel>
  |                     </h:form>
  |             </ui:define>
  |     </ui:composition>
  | </html>
  | 

And finally the pdf xhtml file

  | <p:document xmlns:ui="http://java.sun.com/jsf/facelets";
  |             xmlns:p="http://jboss.com/products/seam/pdf";
  |             xmlns:s="http://jboss.com/products/seam/taglib";
  |             xmlns:f="http://java.sun.com/jsf/core";
  |             pageSize="A4">
  | 
  |     <f:facet name="header">
  |             <p:font size="12">
  |                     <p:footer borderWidthTop="1" borderColorTop="Gray" 
borderWidthBottom="0" alignment="center">
  |                             <p:pageNumber/>
  |                     </p:footer>
  |             </p:font>
  |     </f:facet>
  |     
  |     <p:font size="18">
  |             <p:paragraph>Average Years</p:paragraph>
  |     </p:font>
  |     
  |     <p:table columns="2" headerRows="1">
  |             <p:cell colspan="2">
  |                     <p:font size="14">
  |                             <p:paragraph>Search Criteria</p:paragraph>
  |                     </p:font>
  |             </p:cell>
  |             
  |             <ui:repeat value="#{gekkoReport.criteria.keySet}" var="key">
  |                     <p:cell>#{key}</p:cell>
  |                     <p:cell>#{gekkoReport.criteria.get(key)}</p:cell>
  |             </ui:repeat>
  |     </p:table>
  |     
  |     <p:table columns="4" headerRows="1">
  |     
  |             <ui:repeat value="#{gekkoReport.columns}" var="column">
  |                     <p:font size="14">
  |                             <p:cell>#{column}</p:cell>
  |                     </p:font>
  |             </ui:repeat>
  |             
  |             <ui:repeat value="#{searchResults}" var="uvAveraging">
  |                     <p:cell>#{uvAveraging.years}</p:cell>
  |                     <p:cell>#{uvAveraging.effective}</p:cell>
  |                     <p:cell>#{uvAveraging.expiry}</p:cell>
  |                     <p:cell>#{empty uvAveraging.comment}</p:cell>
  |             </ui:repeat>
  |     </p:table>
  | 
  | </p:document>
  | 



That code is the best implementation I've had so far in that I at least get 
results on my page but...... I don't want to be putting all this data into my 
SESSION scope.

I'll keep looking for some decent examples and reading doco but... any ideas 
would be great. :)

Thanks




View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4105908#4105908

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4105908
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to