Seam conversation bean as custom datasource

Help
2010-11-16
2012-10-10
  • Ihor Haydaychuk

    Ihor Haydaychuk - 2010-11-16

    Hi,
    I use JasperReports JSF Plugin together with Seam framework. More precisely -
    I use custom datasource that is statefull session bean. Code snippet:

    <jr:dataSource id="ds" type="custom" value="#{InputTrans.ds}"/>

    Session Bean is declared as

    @Stateful
    @Scope(ScopeType.CONVERSATION)
    @Name("InputTrans")
    public class InputTransBean implements InputTrans, Serializable {
    private JRDataSource ds;
    ……………………………………………………………………………
    public JRDataSource getDs() {
    return ds;
    }
    }

    If bean has SESSION scope - tag displays report properly. But when bean is
    declared as CONVERSATION scope - report has no data. Any ideas how to resolve
    this problem?
    Thanks,

    Ihor

     
  • Alonso Dominguez

    Hi Ihor,

    The seam conversation scope is not supported yet, however it should work with
    REQUEST scope as long as the JRDataSource instance is built in the last
    request of the "conversation"...

    Is there any stacktrace/log messages when using the CONVERSATION scope?

    regards

     
  • joe joseph

    joe joseph - 2011-02-24

    Hi,

    I have a similar problem. I used a bean datasource. This is the code:

    <jr:dataSource type="bean" id="dataSource" value="#{dataBeanMaker.dataBeanList}" />
    
                      <jr:report path="/report/report1.jrxml" dataSource="dataSource" format="pdf"> View Report
    
                                <f:param name="PaysChart" value="#{dataBeanManager.createPaysChartImage}" />
    
                      </jr:report>
    

    I have the following error:

    net.sf.jasperreports.jsf.spi.ResourceFactoryNotFoundException: No factory for resource: report/report1.jrxml

    I have tried to change the path but yet don't have any good result. Can I have
    some help on maybe customizing the Filler, FillerLoaderClass.

    I am the first trying to use this plugin in my place please help.

     
  • joe joseph

    joe joseph - 2011-02-24

    these are my beans:

    DataBean

    package model;
    
    public class DataBean {  
        private String name;  
        private String occupation;  
        private String place;  
        private String country; 
        private int numberOfTowns;
    
        public void setName(String name) {  
            this.name = name;  
        }
    
        public String getName() {  
            return name;  
        }
    
        public void setOccupation(String occupation) {  
            this.occupation = occupation;  
        }
    
        public String getOccupation() {  
            return occupation;  
        }
    
        public void setPlace(String place) {  
            this.place = place;  
        }
    
        public String getPlace() {  
            return place;  
        }
    
        public void setCountry(String country) {  
            this.country = country;  
        }
    
        public String getCountry() {  
            return country;  
        }
    
        public void setNumberOfTowns(int numberOfTowns) {
            this.numberOfTowns = numberOfTowns;
        }
    
        public int getNumberOfTowns() {
            return numberOfTowns;
        }  
    }
    

    DataBeanMaker (the Datasource):

    package model;
    import java.util.ArrayList;
    
    import model.DataBean;
    
    public class DataBeanMaker {
    
        public ArrayList<DataBean> getDataBeanList() {  
            ArrayList<DataBean> dataBeanList = new ArrayList<DataBean>();
    
            dataBeanList.add(produce("Babji, Chetty", "Engineer", "Nuremberg", "Germany",9));    
            dataBeanList.add(produce("Albert Einstein", "Engineer", "Ulm", "Germany",10));  
            dataBeanList.add(produce("Alfred Hitchcock", "Movie Director", "London", "UK",5));  
            dataBeanList.add(produce("Wernher Von Braun", "Rocket Scientist", "Wyrzysk","Poland (Previously Germany)",8));  
            dataBeanList.add(produce("Sigmund Freud", "Neurologist", "Pribor", "Czech Republic (Previously Austria)",15));  
            dataBeanList.add(produce("Mahatma Gandhi", "Lawyer", "Gujarat", "India",6));  
            dataBeanList.add(produce("Sachin Tendulkar", "Cricket Player", "Mumbai", "India",5));  
            dataBeanList.add(produce("Michael Schumacher", "F1 Racer", "Cologne", "Germany",8));
    
            return dataBeanList;  
        }
    
        private DataBean produce(String name, String occupation, String place, String country, int numberofTowns) {  
            DataBean dataBean = new DataBean();
    
            dataBean.setName(name);  
            dataBean.setOccupation(occupation);  
            dataBean.setPlace(place);  
            dataBean.setCountry(country);
            dataBean.setNumberOfTowns(numberofTowns);
    
            return dataBean;  
        }  
    }
    

    I have been on it for a week.

     
  • Alonso Dominguez

    Hi nkojunior,

    Your problem is very different and it's not related with the Seam's
    CONVERSATION scope. The reason why your report rendering is failing is because
    you are using a ".JRXML" report resource (a source report) and the plugin only
    works with ".JASPER" files (compiled reports).

    This is a common mistake, I could implement a mechanism that could compile the
    report on the fly to solve this mistake but, in that situation, the view
    rendering gets very slow, so due to the plentiful number of tools that can be
    used to compile the report sources at the same time that the Java sources are
    compiled I preferred to leave it this way and encourage every one to deploy
    compiled items.

    Regards

     
  • joe joseph

    joe joseph - 2011-02-24

    Hi Alonsoft,

    Thank you for prompt response.

    I compiled the report into ".JASPER" and my code is now like this:

    <jr:dataSource type="bean" id="dataSource" value="#{dataBeanMaker.dataBeanList}" />
    
                      <jr:report path="report/report1.jasper" dataSource="dataSource" format="pdf"> View Report
    
                                <f:param name="PaysChart" value="#{dataBeanManager.createPaysChartImage}" />
    
                      </jr:report>
    

    but I still have the same error:

    WARN phase(RENDER_RESPONSE 6,com.sun.faces.context.FacesContextImpl@f82fe7) threw exception: net.sf.jasperreports.jsf.spi.ResourceFactoryNotFoundException: No factory for resource: report/report1.jasper No factory for resource: report/report1.jasper

    I was wondering if I don't have to customise the Filler, FillerLoader and
    FillerFactory . If so, can I have an example? I browsed through the net and
    couldn't find one.

    thank you

     
  • Alonso Dominguez

    Hi again nkojunior,

    As far as I can see you have changed your resource reference from

    /report/report1.jrxml
    

    to

    report/report1.jasper
    

    did you notice that now there is not any leading slash?
    you have changed your context-relative resource reference to a view-relative
    resource reference. beta3 version is not able to manage view-relative
    resources (next releases will do) so you need to add a slash character at the
    begining of your resource reference.

    Regards

     
  • joe joseph

    joe joseph - 2011-02-27

    Thx! Just want to tell it works and even perfectly!

    Best regards

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks