AnsweredAssumed Answered

Webscript, portlet and form

Question asked by b.valentin on Apr 8, 2009
Hello everybody,

I have a Tomcat server with a Liferay Portal (v5.1.x) and Alfresco (v3.0). I followed some tutorials to have webscripts as portlets, and everything seems to work well with out-of-the-box UI portlet.

But, I have a problem with my own webscripts, especially when I have:
- a webscript with a form
form.get.html.ftl:

<form method="post" action="${url.service}" enctype="multipart/form-data">
     Name : <input type="text" name="name"/>
     File : <input type="file" name="myfile"/>
     <input type="submit"/>
</form>

- a webscript with the formdata object to catch informations from the previous webscript
form.post.js:

var filename = null;
var content = null;
var title = "";

// locate file attributes
for each (field in formdata.fields)
{
   if (field.name == "name")
   {
      title = field.value;
   }
   else if (field.name == "myfile" && field.isFile)
   {
      filename = field.filename;
      content = field.content;
   }
}
// treatment….

My problems:
- When I press the submit button, I leave the portal. I found a solution with the scripturl() method

<form method="post" action="${scripturl("")}" enctype="multipart/form-data">
- But POST webscripts don't seem to be supported by the WebScriptPortlet class. A first solution was to bring together the both webscripts.

<form method="post" action="${scripturl("?step=1")}" enctype="multipart/form-data">

if (args.step == 1)
{
     //treatment with the formdata object
}
else
{
     //treatment to build the form
}
- But now, I have this exception when I submit the form: Exception: org.mozilla.javascript.EcmaError - ReferenceError: "formdata" is not defined (AlfrescoScript#10)

Is there an issue with POST webscripts in portlet? Is there a solution to my problem?

Thank you, and excuse me for my english

Outcomes