Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
access variable passed from callServer in servlet
yanSi
I'm having problems access the object passed from javascript in my servlet. My FormAPI code looks like this:
var params = new Object();
params.title="blah";
alert(params.title);
IWDatacapture.callServer("/iw-cc/setEA.do", params, true);
My servlet delopyed using the make_toolkit.ipl script contains the code below:
String params = req.getParameter("params.title");
try
{
FileWriter fw=new FileWriter("c:/servletTemp.txt");
PrintWriter pw=new PrintWriter(fw);
pw.println(params);
pw.close();
}
catch(IOException e)
{
}
I have tried req.getParameter("params") and req.getParameter("params.title"), but both gave the output "null" in my servletTemp.txt file.
Do callServer methods absolutely have to return a response? I'm trying to set some EAs onSave and I not planning on giving a response.
Find more posts tagged with
Comments
Migrateduser
Try req.getParameter("title") insted of req.getParameter("params.title").
Valentine
If you've got access to the TS server, you can always check the access log for the web server, and see what requests are being made.
yanSi
Thanks guys. Batasari's suggestion is correct. I just used title instead of params.title and it now works. But another problem came up.
My goal is to set EAs on the dcr. I planned on calling the servlet onSaveDone, but it's not being called. Below is the code in the script tags of my DCT. Can anyone see why my onSaveDone is not being called? I manually call my onSaveDone handler in the init method and I expected to see one alert when I open the form, but I see two alerts. But no alert comes up when I save. What's going on?
IWEventRegistry.addFormHandler('onFormInit', initializeDct());
IWEventRegistry.addFormHandler('onSaveDone', mySaveDone());
function initializeDct()
{
mySaveDone(0);
}
function mySaveDone(success)
{
alert("savedone");
if(success)
{
var params = new Object();
params.title = IWDatacapture.getItem("/page/english/title").getValue();
params.description = "Home Page of DFAIT";
params.dcr=IWDatacapture.getDCRPath();
IWDatacapture.callServer("/iw-cc/setEA.do", params, false);
}
}
yanSi
After thinking WTF overnight, it turns out that I had a syntax error in the code to register the event handler.
The code CAN'T be either of these
IWEventRegistry.addFormHandler('onSaveDone', mySaveDone());
IWEventRegistry.addFormHandler('onSaveDone', mySaveDone(success));
The code has to be this
IWEventRegistry.addFormHandler('onSaveDone', mySaveDone);
Doh!