cancel
Showing results for 
Search instead for 
Did you mean: 

JSF Crystal report viewer component and parameters

Former Member
0 Kudos

My JSF Page Markup


<h:form>
    <bocrv:reportPageViewer reportSource="#{multiParam.getGetReport(param['reportId'])}" 
allowParameterPrompting="true"/>
</h:form>

The Backing Bean


import com.crystaldecisions.sdk.occa.report.lib.ReportSDKException;
import com.crystaldecisions.sdk.occa.report.reportsource.IReportSource;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;

import javax.faces.context.FacesContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@Name("multiParam")
public class MultiParam {
    private static Log log = LogFactory.getLog(MultiParam.class);
    @In
    ReportingServiceImpl reportingService;

    public IReportSource getGetReport(String id) throws ReportSDKException, IOException, ServletException {
        log.debug("Report ID: " + id);
        String reportId;
        FacesContext facesContext = FacesContext.getCurrentInstance();
        HttpSession session = (HttpSession) facesContext.getExternalContext().getSession(false);
        if (session != null) {
            reportId = (String) session.getAttribute("reportId");
            if (StringUtils.isNotEmpty(reportId)) { //found in session
                return reportingService.getReportSource(reportId);
            } else if (StringUtils.isNotEmpty(id)) { // get from the request param
                session.setAttribute("reportId", id);
                return reportingService.getReportSource(id);
            }
        }
        return null;
    }
}

Now When the JSF page is accessed the first time around It readily prompts for the parameter, But when The parameter is supplied and the ok button is pressed, the form is posted back to itself and the screen asking for parameter is being displayed again.

Can someone please guide me as to where am i going wrong with this...

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Please bear with me I am new to Crystal reports.

Former Member
0 Kudos

In case someone is wondering my setup is the following... I am still thinking if a Crystal reports server would be required in this scenario or not.


   +--------------+     +---------------------------------+
   |   Tomcat 6   -------  Some .rpt files deliverd to    |
   |--------------|     | a folder via the CMS delivery   |
   |(JSF 1.2)     |     | channels                        |
   |(JBOSS SEAM)  |     +---------------------------------+
   |(FACELETS)    |
   |(Eclipse Cry  |
   | stal reports |              +----------+
   | plugin CR12) |              | Or...    |
   |              |              | I use a  |
   |              |              | Crystal  |
   |              |              | Reports  |
   |              |              | Server   |
   |              |              +----------+
   |              |
   |              |      I am really not sure if Crystal reports server
   |              |      will be an ideal solution here.
   +--------------+

I would appreciate any help in this or a shove in the right direction

ted_ueda
Employee
Employee
0 Kudos

The viewer - whether the JSPtag, JSF, or CrystalReportViewer class - all use postback for functionality.

What you're seeing is that the viewer isn't keeping state. You need to ensure the viewer - whichever you use - keeps the ReportSource in session state.

Because of all the different JSF implementations out there, where server-side or client-side session state persistence are handled slightly differently, you may instead want to use the CrystalReportViewer class instance directly, outside of JSF framework.

If so, I'd recommend reading the Viewer SDK Developer Guide for information.

Sincerely,

Ted Ueda

Former Member
0 Kudos

that was very helpful Ted...

Then how are people solving this problem as most of my reports are to be pretty complex (with drill downs and parameter prompting)...

I gave it a try here...but the backing bean sticks in the session and is not created afresh for a different report name parameter (I am picking the report name from a request parameter) as a result no new ReportSource is generated.

How are people solving this...as i don't see any other way than writing a jsf page and a backing bean per report...which entirely defeats the purpose of a CMS delivery channel of dumping the report files there.

Best Regards Ted...

Asif

ted_ueda
Employee
Employee
0 Kudos

You didn't find reading the SDK guide helpful?

The report state is preserved using the ReportSource object - so what's happening apparently is that a new ReportSource object, and not the one being used for the parameter prompting is being passed to the viewer.

Sincerely,

Ted Ueda

Answers (0)