ページの先頭行へ戻る
Interstage List Works V11.0.0 APIリファレンス
FUJITSU Software

D.1 ListPrintのサンプルプログラム

ListPrintのメソッドを用いたJavaスクリプトの記述例を示します。


帳票の一覧からの印刷機能

帳票の一覧から帳票を印刷するには、以下のJSPファイルとJavaScriptファイルが必要です。

  • 帳票の一覧から帳票を印刷するJSPファイル

  • JSPファイルから呼ばれるActiveXコントロールを定義しているJavaScriptファイル


帳票の一覧から帳票を印刷するJSPファイル
<%@ page session="false" import="com.fujitsu.systemwalker.listworks.gateway.util.*,
                                 com.fujitsu.systemwalker.listworks.common.info.*" %>
<%@ page contentType="text/html; charset=Windows-31J" %>

<jsp:useBean id="listConfig" class="com.fujitsu.systemwalker.listworks.gateway.util.ListConfig" scope="request" />

<HTML>

<%
// ListGatewayの情報および選択されている帳票の情報を取得します。
boolean fByteSwap                  = false;
long    lActivePage                = 0;
int     iSheetNo                   = 0;
int     iClTraceOut                = 1;
int     iClTraceLocalMaxSize       = 1000;
int     iClTraceLevel              = 0;
int     iClInformationOut          = 0;
int     iClInformationLocalMaxSize = 1000;

if (listConfig.getSheetNo() != -1)
{
 fByteSwap                    = listConfig.getByteSwap();
 lActivePage                  = listConfig.getActivePage();
 iClTraceOut                  = listConfig.getClTraceOut();
 iClTraceLocalMaxSize         = listConfig.getClTraceLocalMaxSize();
 iClTraceLevel                = listConfig.getClTraceLevel();
 iClInformationOut            = listConfig.getClInformationOut();
 iClInformationLocalMaxSize   = listConfig.getClInformationLocalMaxSize();
 iSheetNo                     = listConfig.getSheetNo();
}
%>

<HEAD>
<META http-equiv="Content-type" content="text/html; charset=Shift_JIS">
<TITLE>帳票を自動的に印刷する</TITLE>
<LINK rel=stylesheet href="/listworks/jsp/style.css" type="text/css">
<SCRIPT language="JavaScript" src="/listworks/jsp/listprint.js">
</SCRIPT>
</HEAD>

<SCRIPT language="JavaScript">
<!--
var Error = false;

function init()
{
 // Internet Explorerを使用している場合
 if (app == "M")
 {
  // ListPrintのダウンロードでエラーが発生した場合は処理を中断します。
  if (Error == true)
   return;

  // ListPrintをアクティブにします。
  setFocusListPrint();

  // 選択されている帳票の5ページから10ページまでを
  // 用紙サイズをA4、用紙の向きを縦、1部、
  // ダイアログボックスを表示しないで印刷します。
  if (document.ListPrint.localPrint(1, 5, 10, 1, 13, 0, 0, 0) != 0)
  {
   alert("選択されている帳票の印刷に失敗しました。")
  }
 }
}

function exit()
{
 // Internet Explorerを使用している場合
 if (app == "M")
 {
  // ListPrintをアクティブにします。
  document.write("");
 }
}

function setFocusListPrint()
{
 // Internet Explorerを使用している場合
if (app == "M")
 {
  // バージョン・レベルをチェックします。
  if (ver >= 4)
  {
   // ListPrintをアクティブにします。
   document.ListPrint.focus();
  }
 }
}

function error()
{
  // ListPrintのダウンロードエラーフラグを、TRUEにします。
  Error = true;
}
// -->
</SCRIPT>

<BODY background="/listworks/image/background.gif" bgcolor="#FFFFFF" text="#000000" onload="init()"onunload="exit()">

<!----- ListPrint コントロール/プラグインの起動 ----->
<SCRIPT language="JavaScript">
<!--
app = navigator.appName.charAt(0);
ver = navigator.appVersion.charAt(0);

// Internet Explorerを使用している場合
if (app == "M")
{
 // バージョン・レベルをチェックします。
 if (ver >= 4)
 {
  // jsファイルから<OBJECT>タグを書き出します。
  writeObject(<%=iSheetNo%>,
             "<%=fByteSwap%>",
              <%=lActivePage%>,
              <%=iClTraceOut%>,
              <%=iClTraceLocalMaxSize%>,
              <%=iClTraceLevel%>,
              <%=iClInformationOut%>,
              <%=iClInformationLocalMaxSize%>,
              1);
 }
}
// -->
</SCRIPT>

</BODY>
</HTML>

JSPファイルから呼ばれるActiveXコントロールを定義しているJavaScriptファイル
//
// jsファイルから<OBJECT>タグを書き出します。
//   param   iSheetNo                   帳票番号
//   param   fByteSwap                  バイトスワップ
//   param   lActivePage                アクティブページ
//   param   iClTraceOut                Webクライアントのトレース出力情報を
//出力するかどうか
//   param   iClTraceLocalMaxSize       Webクライアントのローカルトレースファイル
//サイズ
//   param   iClTraceLevel              Webクライアントのトレースレベル
//   param   iClInformationOut          Webクライアントの情報ログ出力情報を
//出力するかどうか
//   param   iClInformationLocalMaxSize Webクライアントのローカル情報ログファイル
//サイズ
//   param   iFunc                      要求機能
//
function writeObject(iSheetNo,
                     fByteSwap,
                     lActivePage,
                     iClTraceOut,
                     iClTraceLocalMaxSize,
                     iClTraceLevel,
                     iClInformationOut,
                     iClInformationLocalMaxSize,
                     iFunc)
{
 if (iFunc == 0)
 {
  document.write('<OBJECT ID="ListPrint" WIDTH="100%" HEIGHT="100%"')
  document.write(' CLASSID="CLSID:BF8410EB-E3B7-11D3-B833-00000EBCC7B8"')
  document.write(' CODEBASE="' + location.protocol + '//' + location.host + '/listworks
/f5cwwpti.cab#Version=2,0,0,2" onError="error()">')
  document.write('    <PARAM NAME="_Version" VALUE="65536">')
  document.write('    <PARAM NAME="_ExtentX" VALUE="2646">')
  document.write('    <PARAM NAME="_ExtentY" VALUE="1323">')
  document.write('    <PARAM NAME="_StockProps" VALUE="0">')
  document.write('    <PARAM NAME="Session" VALUE="' + document.cookie + '">')
  document.write('    <PARAM NAME="RequestFunc" VALUE="' + iFunc + '">')
  document.write('    <PARAM NAME="KeeplistNo" VALUE="' + iSheetNo + '">')
  document.write('    <PARAM NAME="ServletUrl" VALUE="' + location.protocol + '//' +
location.host + '/listworks/servlet/ListGateway">')
  document.write('    <PARAM NAME="Byteswap" VALUE="' + fByteSwap + '">')
  document.write('    <PARAM NAME="ActivePage" VALUE="' + lActivePage + '">')
  document.write('    <PARAM NAME="ListGatewayVL" VALUE="1504020">')
  document.write('    <PARAM NAME="Message" VALUE="1">')
  document.write('    <PARAM NAME="TraceFileOut" VALUE="' + iClTraceOut + '">')
  document.write('    <PARAM NAME="TraceMaxSize" VALUE="' + iClTraceLocalMaxSize + '">')
  document.write('    <PARAM NAME="TraceLevel" VALUE="' + iClTraceLevel + '">')
  document.write('    <PARAM NAME="Recycle" VALUE="0">')
  document.write('    <PARAM NAME="PeekMessage" VALUE="0">')
  document.write('    <PARAM NAME="InformationFileOut" VALUE="' + iClInformationOut + '">')
  document.write('    <PARAM NAME="InformationMaxSize" VALUE="' + iClInformationLocalMaxSize + '">')
  document.write('    <PARAM NAME="Navigator" VALUE="' + navigator.appName + navigator.appVersion + '">')
  document.write('</OBJECT>')
 }
 else if (iFunc == 1)
 {
  document.write('<OBJECT ID="ListPrint" WIDTH="0" HEIGHT="0"')
  document.write(' CLASSID="CLSID:BF8410EB-E3B7-11D3-B833-00000EBCC7B8"')
  document.write(' CODEBASE="' + location.protocol + '//' + location.host + '/listworks/f5cwwpti.cab#Version=2,0,0,2" onError="error()">')
  document.write('    <PARAM NAME="_Version" VALUE="65536">')
  document.write('    <PARAM NAME="_ExtentX" VALUE="2646">')
  document.write('    <PARAM NAME="_ExtentY" VALUE="1323">')
  document.write('    <PARAM NAME="_StockProps" VALUE="0">')
  document.write('    <PARAM NAME="Session" VALUE="' + document.cookie + '">')
  document.write('    <PARAM NAME="RequestFunc" VALUE="' + iFunc + '">')
  document.write('    <PARAM NAME="KeeplistNo" VALUE="' + iSheetNo + '">')
  document.write('    <PARAM NAME="ServletUrl" VALUE="' + location.protocol + '//' + location.host + '/listworks/servlet/ListGateway">')
  document.write('    <PARAM NAME="Byteswap" VALUE="' + fByteSwap + '">')
  document.write('    <PARAM NAME="ActivePage" VALUE="' + lActivePage + '">')
  document.write('    <PARAM NAME="ListGatewayVL" VALUE="1504020">')
  document.write('    <PARAM NAME="Message" VALUE="1">')
  document.write('    <PARAM NAME="TraceFileOut" VALUE="' + iClTraceOut + '">')
  document.write('    <PARAM NAME="TraceMaxSize" VALUE="' + iClTraceLocalMaxSize + '">')
  document.write('    <PARAM NAME="TraceLevel" VALUE="' + iClTraceLevel + '">')
  document.write('    <PARAM NAME="Recycle" VALUE="0">')
  document.write('    <PARAM NAME="PeekMessage" VALUE="0">')
  document.write('    <PARAM NAME="InformationFileOut" VALUE="' + iClInformationOut + '">')
  document.write('    <PARAM NAME="InformationMaxSize" VALUE="' + iClInformationLocalMaxSize + '">')
  document.write('    <PARAM NAME="Navigator" VALUE="' + navigator.appName + navigator.appVersion + '">')
  document.write('</OBJECT>')
 }
}

帳票の表示機能

帳票を表示するには、以下のJSPファイルとJavaScriptファイルが必要です。

  • 帳票を表示するJSPファイル

  • JSPファイルから呼ばれるActiveXコントロールを定義しているJavaScriptファイル


帳票を表示するJSPファイル
<%@ page session="false" import="com.fujitsu.systemwalker.listworks.gateway.util.*,
                                 com.fujitsu.systemwalker.listworks.common.info.*" %>
<%@ page contentType="text/html; charset=Windows-31J" %>

<jsp:useBean id="listConfig" class="com.fujitsu.systemwalker.listworks.gateway.util.ListConfig" scope="request" />

<HTML>

<%
// ListGatewayの情報および選択されている帳票の情報を取得します。
boolean fByteSwap                  = false;
long    lActivePage                = 0;
int     iSheetNo                   = 0;
int     iClTraceOut                = 1;
int     iClTraceLocalMaxSize       = 1000;
int     iClTraceLevel              = 0;
int     iClInformationOut          = 0;
int     iClInformationLocalMaxSize = 1000;

if (listConfig.getSheetNo() != -1)
{
 fByteSwap                    = listConfig.getByteSwap();
 lActivePage                  = listConfig.getActivePage();
 iClTraceOut                  = listConfig.getClTraceOut();
iClTraceLocalMaxSize          = listConfig.getClTraceLocalMaxSize();
iClTraceLevel                 = listConfig.getClTraceLevel();
iClInformationOut             = listConfig.getClInformationOut();
iClInformationLocalMaxSize    = listConfig.getClInformationLocalMaxSize();
iSheetNo                      = listConfig.getSheetNo();
}
%>

<HEAD>
<META http-equiv="Content-type" content="text/html; charset=Shift_JIS">
<TITLE>検索で絞り込んで表示する</TITLE>
<LINK rel=stylesheet href="/listworks/jsp/style.css" type="text/css">
<SCRIPT language="JavaScript" src="/listworks/jsp/listprint.js">
</SCRIPT>
</HEAD>

<SCRIPT language="JavaScript">
<!--
var Error = false;

function init()
{
 // Internet Explorerを使用している場合
 if (app == "M")
 {
  // ListPrintのダウンロードでエラーが発生した場合は処理を中断します。
  if (Error == true)
   return;

  // ListPrintをアクティブにします。
  setFocusListPrint();

  // 検索する条件をすべて削除します。
  if (document.ListPrint.findClear() != 0)
  {
   alert("検索する条件の削除に失敗しました。");
   return;
  }

  // 範囲名「振込先」で「東京支店」と等しい文字列を
  // 検索する条件を設定します。
  if (document.ListPrint.findString("振込先",
                                    "東京支店",
                                    0,
                                    0,
                                    0,
                                    0) != 0)
  {
   alert("文字列の検索する条件の設定に失敗しました。");
   return;
  }

  // 範囲名「振込金額」で「1,000,000」以上
  // かつ「3,000,000」以下の数値を検索する条件を設定します。
  if (document.ListPrint.findNumeric("振込金額",
                                     "1000000",
                                     4,
                                     1,
                                     "3000000",
                                     5,
                                     0,
                                     0) != 0)

  {
   alert("数値の検索する条件の設定に失敗しました。");
   return;
  }

  // 設定した条件で絞り込みを行います。
  if (document.ListPrint.extractFind() != 0)
  {
   alert("検索による絞り込みに失敗しました。");
  }
 }
}

function exit()
{
 // Internet Explorerを使用している場合
 if (app == "M")
 {
  // ListPrintを破棄します。
  document.write("");
 }
}

function setFocusListPrint()
{
 // Internet Explorerを使用している場合
 if (app == "M")
 {
  // バージョン・レベルをチェックします。
  if (ver >= 4)
  {
   // ListPrintをアクティブにします。
   document.ListPrint.focus();
  }
 }
}

function error()
{
 // ListPrintのダウンロードエラーフラグを、TRUEにします。
 Error = true;
}
// -->
</SCRIPT>

<BODY background="/listworks/image/background.gif" bgcolor="#FFFFFF" text="#000000" onload="init()" onunload="exit()">

<!----- ListPrint コントロール/プラグインの起動 ----->
<SCRIPT language="JavaScript">
<!--
app = navigator.appName.charAt(0);
ver = navigator.appVersion.charAt(0);

// Internet Explorerを使用している場合
if (app == "M")
{
 // バージョン・レベルをチェックします。
 if (ver >= 4)
 {
  // jsファイルから<OBJECT>タグを書き出します。
  writeObject(<%=iSheetNo%>,
             "<%=fByteSwap%>",
              <%=lActivePage%>,
              <%=iClTraceOut%>,
              <%=iClTraceLocalMaxSize%>,
              <%=iClTraceLevel%>,
              <%=iClInformationOut%>,
              <%=iClInformationLocalMaxSize%>,
              0);
 }
}
// -->
</SCRIPT>

</BODY>
</HTML>

JSPファイルから呼ばれるActiveXコントロールを定義しているJavaScriptファイル

当JavaScriptファイルは、“帳票の一覧からの印刷機能”で使用するJavaScriptファイルと共通のため、“帳票の一覧からの印刷機能”で説明している“JSPファイルから呼ばれるActiveXコントロールを定義しているJavaScriptファイル”を参照してください。