In this example we will query a WTDocument by name and by a range of dates. The first thing that we need to do is create a simple JSP page that contains a form with some inputs in order to submit or data.
This is our code, we will call it
formDocument.jsp
As you can see we used GET in order to pass parameters to our
test.jsp page this is simple to debug because you will see the parameters over the URL. Save /codebase/com//www/jsp/ .
formDocument.jsp we will put into
Now, we need to receive those parameters to execute a query and display a table with the results using Webjects from Windchill Adapter. We can do it all inside a JSP Page because we will declare the Info*Engine TagLib. We will assume that you have your instance and an session of your server.
<%@page language="java"%>
<%@taglib uri="http://www.ptc.com/infoengine/taglib/core" prefix="ie"%>
<%
String documentName = request.getParameter("documentName");
String beginDate = request.getParameter("beginDate");
String endDate = request.getParameter("endDate");
String beginDateWhere = "";
String endDateWhere ="";
String documentNameWhere = "name='"+documentName+"'";
if(beginDate == null || beginDate==""){
beginDateWhere = "thePersistInfo.modifyStamp>=1900-01-01";
}else{
beginDateWhere = "thePersistInfo.modifyStamp>=" +beginDate;
}
if(endDate == null || endDate==""){
endDateWhere = "thePersistInfo.modifyStamp<=9999-01-01";
}else{
endDateWhere = "thePersistInfo.modifyStamp<=" +endDate;
}
%>
As you can see, we received our parameters with some Java code using HttpServletRequest object and we manipulate that parameters in order to match ours where clauses inside the webject, after that we simply replace those manipulated parameters and put it into webject directly. We named our GROUP-OUT output, we will use this group in our Display-Table webject
Already inside of our HTML page, we will display the result of our query using a Display-Table webject, we specified our WT.Document attributes to be displayed and our Headers for those attributes.
And that's all!. Thanks to Alan Morales because together found out how to make this work!
Thanks for such clean description...!
ResponderEliminar