Adapter Webjects and JSP Pages
Action and query webjects are defined for the Info*Engine adapters installed at your site. Each adapter is designed to access data from a specific type of information system. For detailed adapter webject descriptions and syntax, see the adapter guide for the information system you want to access.
Even though each adapter provides a unique set of webjects (each with their own set of parameters), Info*Engine has standardized a way to access the adapter through each webject. To do this, Info*Engine requires that you include the INSTANCE parameter in each adapter webject. This parameter identifies the adapter that is to be used. Although the name used to identify the adapter can take on many different forms, the most common name used is the service name defined for the adapter when it is configured.
A common way to name adapters is to include a domain name as part of the service name so that the adapter service name is unique across your entire Info*Engine environment. For example, if the domain name of the computer used to define the service name is “myHost.myCompany.com,” then a JDBC adapter service name might be:
com.myCompany.myHost.jdbcAdapter
Your site can also use simpler service names. For example, if there are only two JDBC adapters installed at your site, they can be named “JDBCadapter1” and “JDBCadapter2.” Your site administrator determines what the adapter service names are when the adapters are installed and configured. Generally, all service names must be unique, and maintaining uniqueness is the responsibility of the Windchill administrator.
Specify the INSTANCE parameter on each adapter webject. For example, it is specified on the following Query-Objects webject, which queries a database table using the JDBC adapter:
<%@page language="java" session="false"
errorPage="IEError.jsp"%>

<%@ taglib uri="http://www.ptc.com/infoengine/taglib/core"
prefix="ie"%>

<html>
<head>
<title> JSP TableList </title>
</head>
<body bgcolor="#FFFFFF">
<h2> I*E JSP Test - TableList </h2>
<%
String where = request.getParameter ("where");
if ( where == null )
where = "()";

String table = request.getParameter ("table");
if ( table == null )
table = "EMP";

String instance = request.getParameter ("instance");
if ( instance == null )
instance = "jdbcAdapter";
%>

<p><b>
Searching table <%= table%> with where clause <%= where%>.
</b></p>

<ie:webject name="Query-Objects" type="OBJ">
<ie:param name="INSTANCE" data="<%=instance%>"/>
<ie:param name="ATTRIBUTE" data="*"/>
<ie:param name="CLASS" data="<%=table%>"/>
<ie:param name="WHERE" data="<%=where%>"/>
<ie:param name="GROUP_OUT" data="myGroupOut"/>
</ie:webject>

<p>
<ie:webject name="Display-Table" type="DSP"/>
</body>
</html>
* 
In most cases, the preferable and standard way to enter parameter values is to use Info*Engine syntax. Instead of using HTML syntax:
<ie:param name="INSTANCE" data="<%=instance%>"/
You should use Info*Engine syntax:
<ie:param name="INSTANCE" data="$(@FORM[]instance[])" default=
"jdbcAdapter"/>
The INSTANCE parameter is just one of the required parameters. To execute the example page, you must specify the following information on the URL:
An adapter name, such as “jdbcAdapter1”
A table name, such as “EMP”
A where clause, such as where=DEPTNO=10
You use this to create the following URL:
http://localhost/Windchill/infoengine/com/company/TableList.jsp?...
In this case, jdbcAdapter1 becomes the value of the INSTANCE parameter, EMP becomes the value for CLASS, and the where clause is where=DEPTNO=10. The output displayed in the browser could be similar to the following:
If the adapter named “jdbcAdapter1” had not been available, an error would have been returned. To minimize the effect of an adapter being unavailable, you can specify multiple adapters if you know that there is more than one adapter that can process a specific webject.
To specify multiple adapters, include multiple INSTANCE parameter values on the webject. Info*Engine attempts to connect to the adapters in the order specified on the webject. For example, if you know that both adapters “jdbcAdapter1” and “jdbcAdapter2” are defined in your Info*Engine environment, you could include both in the Query-Objects webject as follows:
<%
String where = request.getParameter ("where");
if ( where == null )
where = "()";

String table = request.getParameter ("table");
if ( table == null )
table = "EMP";

String instance1 = request.getParameter ("instance1");
if ( instance1 == null )
instance1 = "jdbcAdapter1";
String instance2 = request.getParameter ("instance2");
if ( instance2 == null )
instance2 = "jdbcAdapter2";
%>

<p><b>
Searching table <%= table%> with where clause <%= where%>.
</b></p>

<ie:webject name="Query-Objects" type="OBJ">
<ie:param name="INSTANCE" data="<%=instance1%>"/>
<ie:param name="INSTANCE" data="<%=instance2%>"/>
<ie:param name="ATTRIBUTE" data="*"/>
<ie:param name="CLASS" data="<%=table%>"/>
<ie:param name="WHERE" data="<%=where%>"/>
<ie:param name="GROUP_OUT" data="myGroupOut"/>
</ie:webject>
The URL to execute the updated TableList.jsp page is as follows:
http://localhost/Windchill/infoengine/com/company/TableList.jsp?...
If “jdbcAdapter1” is available, it is used; if it is not available, “jdbcAdapter2” is used. If neither is available, an error is returned.
Info*Engine also provides the following parameters that can be added to each adapter webject and may be useful when attempting to connect to an adapter:
CONNECTION_ATTEMPTS
Defines the maximum number of times to attempt establishing a connection to an adapter before returning an error. If multiple INSTANCE parameter values are specified, the value of CONNECTION_ATTEMPTS defines the maximum number of times to iterate through the list of adapter instances.
CONNECTION_ATTEMPT_INTERVAL
Defines the amount of time, in seconds, to delay between connection attempts. If multiple INSTANCE parameter values are specified, the value of CONNECTION_ATTEMPT_INTERVAL defines the number of seconds to wait between the attempts to iterate through the entire list of adapter instances.
For example, these parameters could also be added to the previous Query-Objects webject example as follows:
<ie:webject name="Query-Objects" type="OBJ">
<ie:param name="INSTANCE" data="<%=instance1%>"/>
<ie:param name="INSTANCE" data="<%=instance2%>"/>
<ie:param name="CONNECTION_ATTEMPTS" data="3"/>
<ie:param name="CONNECTION_ATTEMPT_INTERVAL" data="30"/>
<ie:param name="ATTRIBUTE" data="*"/>
<ie:param name="CLASS" data="<%=table%>"/>
<ie:param name="WHERE" data="<%=where%>"/>
<ie:param name="GROUP_OUT" data="myGroupOut"/>
</ie:webject>
Adding the parameters sets up three attempts to connect to either adapter and provides a 30 second delay after attempting both connections and before trying again.
For additional information about the using adapter webjects, see the adapter guides for the adapters you are using.
這是否有幫助?