<%-- 
 Copyright 2003 Sun Microsystems, Inc. All rights reserved
 Use is subject to license terms.
--%> 
<%@ page import=
    "com.sun.portal.providers.simplewebservice.SimpleWebServiceProviderAdapter,
	com.sun.portal.providers.simplewebservice.SimpleWebServiceParameter,
	com.sun.portal.providers.simplewebservice.util.XList,
	com.sun.portal.providers.simplewebservice.SimpleWebServiceState,
	com.sun.portal.providers.simplewebservice.SimpleWebServiceException,
	com.sun.portal.providers.simplewebservice.SimpleWebServiceProcessException,
	java.util.Iterator,
	com.sun.portal.providers.ProviderException"
%>

<%@ taglib uri="/tld/desktop.tld" prefix="dt" %>
<%@ taglib uri="/tld/desktopProviderContext.tld" prefix="dtpc" %>
<%@ taglib uri="/tld/jx.tld" prefix="jx" %>
<%@ taglib uri="/tld/desktopTheme.tld" prefix="dttheme" %>

<%
        SimpleWebServiceProviderAdapter provider = 
            (SimpleWebServiceProviderAdapter)pageContext.getAttribute("JSPProvider");
 %>
<dt:obtainChannel channel="$JSPProvider">
  <dtpc:providerContext>          
	        <dtpc:getStringProperty key="fontFace1" id="fontFace"/>
	        <jx:declare id="fontFace" type="java.lang.String"/>
	        
<table border=1>
    <tr valign=top>
        <td><font face="<%=fontFace%>" size="+0">WSDL:</font></td>
	<td><font face="<%=fontFace%>" size="+0"><form><textarea name="simple" rows="1" cols="25" wrap="OFF"><%= provider.getWSDL() %></textarea></form></font></td>
    </tr>
    <tr valign=top>
        <td><font face="<%=fontFace%>" size="+0">Method Name:</font></td>
        <td><font face="<%=fontFace%>" size="+0"><%= provider.getMethodName() %></font></td>
    </tr>
</table>
<br>
<P>
</P>

<%
try {
boolean isDefaultAvailable = provider.isDefaultAvailable();

%>
	<FORM NAME="content_form" METHOD=POST 
				ENCTYPE="application/x-www-form-urlencoded">

	    <INPUT TYPE=HIDDEN NAME="myProvider" SIZE=-1 
					VALUE=<%= provider.getName() %> >
	    <% if (provider.showInputForm(request)) { %>
		<INPUT TYPE=HIDDEN 
			NAME=<%= provider.makeUniqueStr("invokeAction") %> 
			SIZE=-1 VALUE="true" >
		<table border=1>
		<% 
		SimpleWebServiceParameter[] fields = 
			provider.defineInputForWebService(request);
		for ( int i = 0; fields != null && i < fields.length; i++) {
			if (!fields[i].getType().equals(XList.class)) {
		%>
				<tr>
					<td align=right>
						<font face="<%=fontFace%>" size="+0"><b><LABEL FOR="<%= fields[i].getName()%>">
						<%= fields[i].getName() %></LABEL></b></font>
					</td>
					<td>
						<% if (isDefaultAvailable) { %>
							<font face="<%=fontFace%>" size="+0">
								<input type=text 
								name="<%= provider.makeUniqueStr(fields[i].getName())%>" 
								value="<%= fields[i].getStrValue() %>"
								size=20 ID="<%=fields[i].getName()%>">
							</font>
						<% } else { %>
							<font face="<%=fontFace%>" size="+0">
								<input type=text 
								name="<%= provider.makeUniqueStr(fields[i].getName())%>" 
								value="<%= fields[i].getTypeHint() %>"
								size=20 ID="<%=fields[i].getName()%>">
							</font>
						<% } %>

					</td>
				</tr>
			<%
			} else if ( fields[i].getValue() != null) {
			%>
				<tr>
				<td>
				<b><%= fields[i].getName() %></b>
				</td>
				<td>
					<table border=1>
					<%
					Iterator x = ((XList)fields[i].getValue()).iterator(); 
					while ( x.hasNext()) {
						SimpleWebServiceParameter child = 
									(SimpleWebServiceParameter) x.next();
						
					%>
						<tr>
							<td align=right>
							<font face="<%=fontFace%>" size="+0"><b><LABEL FOR="<%=child.getName()%>">
							<%= child.getName() %></LABEL></b></font>
							</td>
							<td>
							<% if (isDefaultAvailable) { %>
								<font face="<%=fontFace%>" size="+0">
									<input type=text 
									name="<%= provider.makeUniqueStr(child.getStrValue()) %>"
									value="<%= child.getTypeHint() %>"
									size=20 ID="<%=child.getName()%>">
								</font>
							<% } else { %>
								<font face="<%=fontFace%>" size="+0">
									<input type=text 
									name="<%= provider.makeUniqueStr(child.getFullName()) %>"
									value="<%= child.getTypeHint() %>"
									size=20 ID="<%=child.getName()%>">
								</font>
							<% } %>
							</td>
						</tr>
			
					<%
					}
					%>
					</table>
				</td>
				</tr>
				<%
				}
			}
			%>
		</table>
		<INPUT TYPE=SUBMIT NAME="Submit" VALUE="Run" style='background-color:<dttheme:getAttribute name="titleBarColor"/>;color:<dttheme:getAttribute name="titleFontColor" default="#FFFFFF"/>'>
	    <% } else { 
		SimpleWebServiceState result = provider.processRequest(request);
		SimpleWebServiceParameter output = result.getOutputState();
		SimpleWebServiceParameter[] input = result.getInputState();
		SimpleWebServiceProcessException processError = result.getProcessError();
	    %>

		<%-- 
			DISPLAY STATIC INPUT USED
		--%> 
		<P>
		<font face="<%=fontFace%>" size="+0"><b>INPUT VALUES</b></font>
		</P>
		<table border=1>
		<% 
		for ( int i = 0; input != null && i < input.length; i++) {
		%>
			<%
		    if (!input[i].getType().equals(XList.class)) {
			%>

				<tr>
					<td align=right>
						<font face="<%=fontFace%>" size="+0"><b>
						<%= input[i].getName() %></b></font>
					</td>
					<td>
						<font face="<%=fontFace%>" size="+0">
						<%= input[i].getStrValue() %> 
						</font>
					</td>
				</tr>
			<%
			} else if ( input[i].getValue() != null) {
			%>
				<tr>
					<td>
						<b><%= input[i].getName() %></b>
					</td>
					<td>
						<table border=1>
						<%
						Iterator x = ((XList)input[i].getValue()).iterator(); 
						while ( x.hasNext()) {
							SimpleWebServiceParameter child = 
										(SimpleWebServiceParameter) x.next();
							
						%>
							<tr>
								<td align=right>
									<font face="<%=fontFace%>" size="+0"><b>
									<%= child.getName() %></b></font>
								</td>
								<td>
									<font face="<%=fontFace%>" size="+0">
									<%= child.getStrValue() %> 
									</font>
								</td>
							</tr>
							<%
						}
						%>
						</table>
					</td>
				</tr>
			<%
			}
			%>
		
		<%
		}
		%>
		</table>
		
		<%-- 
			DISPLAY OUTPUT 
		--%> 
		<INPUT TYPE=HIDDEN 
			NAME=<%= provider.makeUniqueStr("invokeAction") %> 
			SIZE=-1 VALUE="false" >

			<%
			if ( output != null) {
			%>
				<P>
				<b>OUTPUT VALUES</b>
				</P>
				<%
		    	if (!output.getType().equals(XList.class)) {
				%>

					<font face="<%=fontFace%>" size="+0">
						<%= output.getName() %> : <%=output.getValue() %></font>
				<%
				} else if ( output.getValue() != null) {
				%>
					<p>
					<b><%= output.getName() %></b>
					<table border=1>
					</p>
					<%
					Iterator x = ((XList)output.getValue()).iterator(); 
					while ( x.hasNext()) {
						SimpleWebServiceParameter child = 
									(SimpleWebServiceParameter) x.next();
						
					%>
						<tr>
							<td align=right>
								<font face="<%=fontFace%>" size="+0"><b>
								<%= child.getName() %></b></font>
							</td>
							<td>
								<font face="<%=fontFace%>" size="+0">
								<%= child.getStrValue() %> 
								</font>
							</td>
						</tr>
					<%
					}
					%>
					</table>
			<%
				}
			}
			if ( processError != null ) {
			%>
				<P>
				<b>ERROR</b>
				</P>
				<table border=1>
					<tr valign=top>
						<td>Error:</td>
						<td><%= processError.getMessage() %></td>
					</tr>
				</table>
			<%
			}
			%>
				
		<br>
		<INPUT TYPE=SUBMIT NAME="Submit" VALUE="OK" style='background-color:<dttheme:getAttribute name="titleBarColor"/>;color:<dttheme:getAttribute name="titleFontColor" default="#FFFFFF"/>'>
	    <% 
	    }
	    %>
	</FORM>
<%
}
catch(SimpleWebServiceException ex) {
%>
	<table border=1>
	    <tr valign=top>
		<td>Error:</td>
		<td><%= ex.getMessage() %></td>
	    </tr>
	</table>
<%
}
%>
	
  </dtpc:providerContext>          
</dt:obtainChannel>




<!-- Channel width is p.getWidth() -->
<%-- This is a JSP comment, should not appear in HTML source --%>
