Siebel Interactive Selling Transact Server Interface Reference > Working with Configurations > Modifying the Configuration List UI >

Sample Email Bean JSP Page


Use the following JSP page as a template. You can modify this template to implement the functionality that allows a user to email a configuration from the Configuration List page.

Each section of code includes an explanation. Remove the explanations to view the complete code for the JSP page. You can also open the Email JSP page (EmailConfig.jsp) from the TransactServer directory located under WebLogic/myServer/public_html.

Email JSP Page Code

<%@ page
info="JSP test"
contentType="text/html"
%>

This page statement states that you are in a JSP page.

<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<!-- BEA WebLogic -->
<jsp:useBean id="Email"
scope="page"
class="com.siebel.isscda.wl.transact.ConfigListBean">
<!-- BEA WebLogic -->

<!-- IBM WebSphere -->
<jsp:useBean id="Email"
scope="page"
class="com.siebel.isscda.ws.transact.ConfigListBean">
<!-- BEA WebLogic -->

This statement imports the bean that contains the Email Bean functions that are used on this page.

<%
Email.setSession(session);
Email.setRequest(request);
%>

These calls are placed inside the useBean tag to make sure that they are executed first. They are initialization statements designed to provide the bean with the session and request variables available to the JSP page. "Session" and "request" are passed in, and JSP is equipped to recognize them.

</jsp:useBean>

This is the end tag for useBean.

<%
if (request.getParameter("To") != null) {

This if statement searches for a parameter named "To" in the request.

There is a text field named "To" on this form. The form submits to the page that contains the form. If the "To" parameter contains information, it means the user has entered their email information and submitted the form. At this point, the email is ready to be sent.

if (!Email.sendMail(request.getParameter("To"), request.getParameter("Subject"), request.getParameter("Message"))) {
%>

This call to sendMail sends the email. Concise syntax is used by calling sendMail from within an if statement. The parameters for sendMail are obtained from the request, using the field names, which are identical to the field names in the form below (because the user filled out the form and submitted it).

<script language=JavaScript>
alert("<%=Email.getErrorMessage() %>");
</script>

If sendMail returned false, this section of code is called, displaying a JavaScript alert whose message text is supplied by a call to getErrorMessage. getErrorMessage returns an error message that attempts to explain to the user why the mail did not get sent.

<%
}
else { %>

In this section, JSP tags close the if statement and start the else statement. If we get to the else statement, we know the email was sent successfully and the next section of code is called.

<script language=JavaScript>
self.close();
</script>

Since the mail was sent successfully, this section of code closes the email window.

<% }
}
%>

This section closes the else and the if (request.getParameter("To") != null) statements.

</head>
<body bgcolor="#FFFFFF">
<form name="Email" action="<%=Email.getAction("EmailConfig.jsp") %>" method="post">

This section fills in the form action using the JSP call to getAction. The name of the template is passed in to the getAction method.

<div align="center"><center>
<table border="0">
<tr>
<td valign="top">To:</td>
<td valign="top"><input type="text" size="80" name="To" value="<%= (request.getParameter("To")!=null ? request.getParameter("To") : "") %>" ></td>

This statement says that if the user has entered a value for the "To" field, prefill the text box named "To" with that value. Otherwise, leave the text box blank.

</tr>
<tr>
<td valign="top">Subject:</td>
<td valign="top"><input type="text" size="80" name="Subject" value="<%= (request.getParameter("Subject") != null ? request.getParameter("Subject") : "") %>"></td>

This statement says that if the user has entered a value for the "Subject" field, prefill the text box named "Subject" with that value. Otherwise, leave the text box blank.

</tr>
<tr>
<td valign="top">Message: </td>
<td valign="top">
<p><textarea name="Message" rows="4" cols="80">
<%= (!Email.getMailSent()? request.getParameter("Message") : Email.getRestoreConfigURL()) %>

In this section, if the mail did not get sent, the "Message" field is prefilled with the text the user entered when he or she submitted the message. Otherwise, a URL is entered to reopen the configuration. This is the URL that the email recipient will click to launch your Siebel application and restore the saved configuration in the browser, so it is very important to include it in the message.

</textarea></p>
</td>
</tr>
<tr>
<td align="center" colspan="2"><input type="submit"
name="OK" value="OK"> <input type="button" name="Cancel"
value="Cancel" onClick="self.close()"></td>

This section creates the HTML buttons for submitting or canceling out of the email dialog box.

</tr>
</table>
</center></div>
</form>
</body>
</html>


 Siebel Interactive Selling Transact Server Interface Reference 
 Published: 18 April 2003