Add a Reserve button to the web page
This lab guides you to add a new Reserve action to the web client page as an example for extending the functionality. Since the web client access the database through the web services, you must first implement the new function in the web services layer and then it can be exposed in the web client application.
1. Create a customized Web Service: Click Add a Reserve Web Service method and follow the steps to add a customized Reserve Web Service to the existing Web Service architecture.
2. Add an action Java Server Page (JSP) component: This JSP component contains the code in the web client application which communicates with the web service. Create a file, for example, ReserveAction.jsp as follows,
<%@ page import="java.util.*" %>
<%@ page import="com.acme.ReserveWebService" %>
<%@taglib prefix="osm" uri="/WEB-INF/tlds/Manager.tld" %>
<osm:license writeAccess="true"/>
<%
final String referrer = request.getHeader("referer");
final String elid = request.getParameter("elid");
final ReserveWebService service = new ReserveWebService();
service.reserveElement(elid);
if(referrer!=null) {
response.sendRedirect(referrer);
} else {
response.sendRedirect("/");
}
%>
* 
In a standard deployment the web client application and the web services are running in the same Jetty server service and thus share the classpath. Therefore, there is no need to make a remote call to the web service. For more information on development of remote clients of the web services, see How to write a Java client for Creo Elements/Direct Model Manager Web Services.
3. Create a component JSP: This component contains a HTML form which triggers the reserve action. You can insert the component into the final JSP pages. Create a file, for example, ReserveComponent.jsp as follows,
<%@ page import="java.util.*" %>
<%
final String elid = request.getParameter("elid");
%>
<div class="reserve">
<form id="reserve" method="get" action="action/ReserveAction.jsp">
<input type="hidden" name="elid" value="<%=elid%>">
<input type="submit" name="reserve" value="Reserve"/>
</form>
</div>
4. Deploy the JSP pages:
Copy ReserveAction.jsp to webapps\mmweb\action.
Copy ReserveComponent.jsp to webapps\mmweb\component.
5. Place the component: The Details pages of the Creo Elements/Direct Manager Web Client provides a convenient way to add the user interface components through the web client XML configuration file. For example, to add the Reserve button to the details page of a MODEL_3D element,
a. Open <Manager Server Installation Directory>\WebConfig.xml.
b. Add the following entry to MODEL_3D class configuration:
<Class>
<Name>MODEL_3D</Name>
...
<Components>
<Component>
<Name>Reserve</Name>
<Component>component/ReserveComponent.jsp</Component>
</Component>
</Components>
...
</Class>
c. Control the component layout through the style sheet. For example, add the following to the style sheet webapps\mmweb\style\ptc_creo\format.css:
.reserve {
float: left;
display: block;
position: absolute;
left:370px;
top:280px;
}
.reserve input {
width: 150px;
}
6. Restart the Java Services using the Creo Elements/Direct Model Manager – Java Services Manager dialog box. For more information, see the Start, Stop, or Restart the Java Services topic of this guide. You may also choose to use the Windows Services panel.
Was this helpful?