on 10-01-2008 2:49 PM
hello,
i use infowiew by programm via url
the reports display one page (connection cms ok , connection db ok )
When i clik on button export or button next page
or button zoom 400% (Toolbar) i have an error
com.crystaldecisions.sdk.exception.sdkExecption$InvalidCMSSyntax
Have you an idea ?
option of viewer ?
Thanks Michel
<%@ page import = "com.crystaldecisions.sdk.occa.infostore.*,
com.crystaldecisions.sdk.plugin.desktop.common.*,
com.crystaldecisions.sdk.framework.*,
com.crystaldecisions.sdk.occa.security.*,
com.crystaldecisions.sdk.exception.SDKException,
com.crystaldecisions.sdk.occa.managedreports.IReportSourceFactory,
java.util.Locale,
java.util.*,
java.lang.String,
com.crystaldecisions.sdk.occa.report.data.*,
com.crystaldecisions.report.web.viewer.*"
%>
<%
// CMS : Nom de la machine exemple sethseth
// user : nom de l'utilisateur CMS exemple Administrator
// pass : mot de passe de l'utilisateur example vide
// Sdocname : nom du rapport Rpt
// notes avant il faut l'integrer dans InfoView
// userDb : utilisateur de la base de donnee exemple rcteaxeriah
// passDb : Mot de passe de la Bd exemple rcteaxeriah
// MM : recupére les infos passés en paramétre par l'url
String cms = request.getParameter("cms");
String user = request.getParameter("user");
String pass = request.getParameter("pass");
String sdocName = request.getParameter("sdoc");
String userDb = request.getParameter("userdb");
String passDb = request.getParameter("passdb");
// Multiparametre
String[] tab_schamp = request.getParameterValues("schamp");
String[] tab_stype = request.getParameterValues("stype");
String[] tab_svaleur = request.getParameterValues("svaleur");
try {
//Log in.
IEnterpriseSession enterpriseSession = CrystalEnterprise.getSessionMgr().logon(user,pass,cms,"secEnterprise");
//Grab the InfoStore from the httpsession
IInfoStore infoStore = (IInfoStore)enterpriseSession.getService("", "InfoStore");
//Query for the report object in the CMS. See the Developer Reference guide for more information the query language.
IInfoObjects oInfoObjects = (IInfoObjects)infoStore.query("SELECT TOP 1 * " +
"FROM CI_INFOOBJECTS " +
"WHERE SI_PROGID = 'CrystalEnterprise.Report' AND SI_INSTANCE=0 AND SI_NAME='" + sdocName + "'" );
if (oInfoObjects.size() > 0) {
//Retrieve the latest instance of the report
IInfoObject oInfoObject = (IInfoObject) oInfoObjects.get(0);
//Use the PS report factory to obtain a report source that will be processed on the Page Server.
IReportSourceFactory factoryPS = (IReportSourceFactory)enterpriseSession.getService("PSReportFactory");
Object reportSource = factoryPS.openReportSource((oInfoObject), Locale.ENGLISH);
session.setAttribute("reportSource", reportSource);
//Build database logon connection infos object. A connection info object containing the logon
//credentials must be created for each connection in the report. This will be passed into the report via
//the Viewer SDK so that the user is not prompted for report database logon credentials.
ConnectionInfo dbLogonInfo = new ConnectionInfo();
dbLogonInfo.setUserName(userDb);
dbLogonInfo.setPassword(passDb);
ConnectionInfos dbLogonInfos = new ConnectionInfos();
dbLogonInfos.add(dbLogonInfo);
//Put this object in session so that it can be retrieved and used by the viewer.
session.setAttribute("dbLogonInfos", dbLogonInfos);
CrystalReportViewer viewer = new CrystalReportViewer();
viewer.setName("CrystalReportViewer");
// Active l'exportation et l'impression sur le visualisateur
viewer.setOwnPage(true);
//Impression possible sur le mode ActiveX
viewer.setPrintMode(CrPrintMode.ACTIVEX);
//le rapport sera affiché sur le Viewer
//Object reportSource = session.getAttribute("reportSource");
viewer.setReportSource(reportSource);
//cache la fenetre d'authentification à la BD (Nom utilisateur et mot de passe)
// et se connecte directement à la base de donnée oracle
//ConnectionInfos dbLogonInfos = (ConnectionInfos)session.getAttribute("dbLogonInfos");
viewer.setDatabaseLogonInfos(dbLogonInfos);
Fields fields = new Fields();
// multi parametre entree
for (int l_i_Nbr_Champ = 0; l_i_Nbr_Champ < tab_schamp.length; l_i_Nbr_Champ++)
{
////////////// Paramétre entrée = DATE //////////////////////////////////////////////////////
/// TEST = if (tab_stype[l_i_Nbr_Champ].equals("DATE"))
{
// extraction du format JJ/MM/AAAA et déclaration des variables
// Année
int iannee = Integer.parseInt(tab_svaleur[l_i_Nbr_Champ].substring(6,10));
// le mois de janvier commence a 0
int imois = Integer.parseInt(tab_svaleur[l_i_Nbr_Champ].substring(3,5)) -1 ;
// Jour
int ijour = Integer.parseInt(tab_svaleur[l_i_Nbr_Champ].substring(0,2));
setParameterValueDate(fields,tab_schamp[l_i_Nbr_Champ],"",iannee,imois,ijour,out);
}
////////////// Fin Parametre entree = DATE ////////////////////////////////////////
////////////// Paramétre entrée = STRING //////////////////////////////////////////////////////
if (tab_stype[l_i_Nbr_Champ].equals("STR"))
{
setParameterValueStr(fields,tab_schamp[l_i_Nbr_Champ],"",tab_svaleur[l_i_Nbr_Champ],out);
}
////////////// Fin Parametre entree = STRING ////////////////////////////////////////
}
// force le parametre dans le browser
viewer.setParameterFields(fields);
// prompt du parametre de saisie caché
// car on veut que le rapport s'affiche automatiquement
viewer.setEnableParameterPrompt(false);
// // Rafraichissement
viewer.refresh();
// appel browser
viewer.processHttpRequest(request, response, getServletConfig().getServletContext(), null);
// Nettoyage
viewer.dispose();
}
else {
out.println("Report " + sdocName + " not found.");
}
}
catch(SDKException sdkEx) {
out.println(sdkEx);
}
%>
<%!
static void setParameterValueDate(Fields oFields, String paramName, String reportName,int annee,int mois,int jour,JspWriter out) throws javax.servlet.jsp.JspException
{
// FORMAT DATE
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_MONTH, jour);
calendar.set(Calendar.MONTH, mois);
calendar.set(Calendar.YEAR, annee);
Object value = calendar.getTime();
ParameterField oParameterField = new ParameterField();
oParameterField.setReportName(reportName);
Values oValues = new Values();
ParameterFieldDiscreteValue oParameterFieldDiscreteValue = new ParameterFieldDiscreteValue();
oParameterField.setName(paramName);
oParameterFieldDiscreteValue.setValue(value);
oValues.add(oParameterFieldDiscreteValue);
oParameterField.setCurrentValues(oValues);
oFields.add(oParameterField);
}
%>
<%!
private void setParameterValueStr(Fields oFields, String paramName, String reportName, Object value,JspWriter out) throws javax.servlet.jsp.JspException
{
ParameterField oParameterField = new ParameterField();
oParameterField.setReportName(reportName);
Values oValues = new Values();
ParameterFieldDiscreteValue oParameterFieldDiscreteValue = new ParameterFieldDiscreteValue();
oParameterField.setName(paramName);
oParameterFieldDiscreteValue.setValue(value);
oValues.add(oParameterFieldDiscreteValue);
oParameterField.setCurrentValues(oValues);
oFields.add(oParameterField);
}
%>
<%!
static void Affiche(JspWriter out, String s) throws javax.servlet.jsp.JspException
{
try
{
out.println(s);
}
catch(java.io.IOException e)
{ throw new javax.servlet.jsp.JspException(e); }
return;
}
%>
{code]
ok i have use an session with getattribute and setattribute it's ok
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The reason this is happening is because of how you are storing your CMS name. You are storing the CMS name in the request object
String[] tab_schamp = request.getParameterValues("schamp");
String[] tab_stype = request.getParameterValues("stype");
String[] tab_svaleur = request.getParameterValues("svaleur");
but when you change the zoom level - a postback occurs and your code is run again. However this time the request object is empty and there's no values to retrieve.
So your options are:
1. After you run through the first time, save the report / reportsource in session and just retrieve that on each subsequent postback. This is a common technique.
2. Save the values that you retrieved from the request object into something that persists between postbacks - such as session or a cookie.
Shawn
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.