I've written Java servlets and used them in callServer() calls successfully. I've done two things:1) return JSON data from the servlet and use jQuery/FromAPI to populate fields in DCTs2) return Javascript code that populates a drop down list in the calling DCT - see page 31-34 of ts_671sp1_fpapi_v01_en.pdfFor a inline call your Java program would have to return well formed XML as indicated on page 39 of ts_671sp1_fpdev_v01_en.pdf.For callouts, you could use a Java program, but I think using callserver() is easier and better and the docs say it supersedes callouts ...John
Hi John,Thanks for your response.I have few queries here:1) I got your first point, where you are returning JSON object you might have done something like response.getWriter(JSON.toString); Please confirm?2) In II point you are returning JAVSCript can you send a code snippet for the same.Just returning part of javascript.3) In inline command my question is we want to call a java class so wot you think it should be a servlet again which will return well formed XML in response or will it be a stantalone java program with void static main method but how will it return XML ??Thanks in Advance.
request.setAttribute("jsonData", json.toString());getServletContext().getRequestDispatcher("/WEB-INF/jsp/info.jsp").forward(request, response);
String jsonData = (String)request.getAttribute("jsonData");out.println(jsonData);
1) You can do something like this in your servlet: request.setAttribute("jsonData", json.toString());getServletContext().getRequestDispatcher("/WEB-INF/jsp/info.jsp").forward(request, response); In the info.jsp: String jsonData = (String)request.getAttribute("jsonData");out.println(jsonData); 2) I suggest you look at the FormAPI docs. There is a clear example there. If you follow it you'll see exactly how to use callserver() to return Javascript.3) From the posts I've seen here, it seems that Perl is used by the majority of IW developers for inline commands. We are a Java shop, but for certain tasks I think Perl is really the best option. That being said, if you want to write a standalone Java program, it will need to return well formed XML to standard out. If I'm not mistaken, inline commands call standalone programs and not a web resources like a servlet. So to answer your question, if you want to use a standalone Java program use inline commands. If you want to use a servlet use callServer().Hope that helps.John
Regarding your servlet where you are returning JSON, I don't understand that how will you populate the values in DCR if you returning the object to jsp?
Thanks John,I had written a standalone program in java where I am creating a xml under tag amd my last line of code is given belowSystem.out.println(doc.asXML());here doc is the document with well formed xml. But how will I call this java class in dct and where will I set the classpath.
Do you think my Java Code will work fine because I think System.out will just print on console. Can you provide a code snippet.
Regarding your servlet where you are returning JSON, I don't understand that how will you populate the values in DCR if you returning the object to jsp?Thanks
function getData(item) { var myOptions = item.getOptions(); var asstId = myOptions[parseInt(item.getValue())].value; var url = "/iw-cc/assocInfo?service=asstinfo&asstID="+asstId; $.ajax( { type: "GET", async: false, url: url, dataType: "json", success: function(json,textStatus){ IWDatacapture.getItem("/associates/associateName").setValue(json.am.fullName); IWDatacapture.getItem("/associates/associateTitle").setValue(json.acm.displayTitles); IWDatacapture.getItem("/associates/associateCredential").setValue(json.acm.displayCredentials); IWDatacapture.getItem("/associates/associateDegree").setValue(json.adm.displayDegrees); }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert("An error occured accessing your data. Please contact your administrator. Error: "+errorThrown+ " - "+textStatus); } }); }
function getData(item) { var myOptions = item.getOptions(); var asstId = myOptions[parseInt(item.getValue())].value; var url = "/iw-cc/assocInfo?service=asstinfo&asstID="+asstId; .... }
I noticed in your code that the servlet assocInfo is built into teamsite.does this mean that if you have to make changes to this servlet you will have to run maketoolkit?since you are java shop, ever thought of hosting these functionalities outside teamsite?
CSClient client = (CSClient) request.getAttribute("iw.csclient");CSUser user = null;String userID = "";if (client != null) { user = client.getCurrentUser(); userID = user.getName();}
The reason why I put the functions inside Teamsite is...
...It is a bit of a pain, but it works.
I put the functions inside Teamsite is because I need to know who the logged in user ...
haha that is why i commented, the pain of having to take down teamsite every time... i wonder if it is still the same process in TeamSite 7, maybe they could come up with process to just rebuild customer.jar and some how update it in TeamSite without taking down the entire application...
I haven't tried it, so I am just thinking out loud... isn't possible to get this remotely? you could still use cssdk outside teamsite? i would think the same attributes get passed to the same servlet even if it was running outside teamsite? maybe you could use the session string to get the csclient remotly?
I'm not sure about TS 7. For now this works.Haven't tried it either. Though, the session is created on the Teamsite server so it wouldn't be available on anther server even if you have the session string.
import com.interwoven.datasource.examples.CSClientUtil;... // read the properties file Properties props = new Properties();...// create the factoryfactory = CSFactory.getFactory(props);... Map params = new HashMap();String sessionID = ...; params.put("servername", "TSAPP"); params.put("serviceBaseURL", props.getProperty("serviceBaseURL")); params.put("csFactory", factory.toString()); currentClient = CSClientUtil.getCSClient(sessionID, params);
something like this : import com.interwoven.datasource.examples.CSClientUtil;... // read the properties file Properties props = new Properties();...// create the factoryfactory = CSFactory.getFactory(props);... Map params = new HashMap();String sessionID = ...; params.put("servername", "TSAPP"); params.put("serviceBaseURL", props.getProperty("serviceBaseURL")); params.put("csFactory", factory.toString()); currentClient = CSClientUtil.getCSClient(sessionID, params); of course, it is not as straight forward as getting csclient inside teamsite, but if it works then there is a way to get away from maketoolkit ...See 254 page of wfm_1011_user_v01_en.pdf
Thanks ... on Page 180 of my version wfm_1010_user_v02_en.pdf, it says to deploy your datasource you must copy your jar file to customer_src and run make_toolkit.ipl ... so what is the benefit? Am I missing something here? Can this same code be used outside of Teamsite and will the API still be able to get your session?
the data source example that will give the CSClientUtil is already part of TeamSite packages (i cant recall the name of the jar file), so there is no need to do teamsite build.yes, the sample code in that page is for a datasource which (as you stated) must be built into teamsite to use it. but my intentions here were to show sample code that you can tweak and build on to get the CSClient remotely. if the only reason you are running your code inside teamsite is to get the current client, then maybe you can get the current client using the session id string, or even using the httprequest attribute which you are doing now (if you can get the servelt to run outside teamsite)... Again i was just thinking out loud of ways to avoid running maketoolkit. but I guess almost everything is possible if you are willing to write a lot more code to get the same functionality outside teamsite...
can share java servlet program