Liferay doesn't catch form in portlet, and doesn't process

I have .jsp in liferay, and use javascript with applet, but after the form sent to the portlet, on the server side, portlet doesn't catch the form, and do not show in logs additional messages.

jsp page's snippet:

<script type="text/javascript">
    function processSigning(){
        var applet = document.applets["SignApplet"];
        var path_to_certificate = document.getElementById("certificate").value;
        var pass = document.getElementById("password").value;
        var filePath = document.getElementById("documentSign").value;
        applet.filePath = document.getElementById("documentSign").value;
        applet.profileTestPKCS12(path_to_certificate, pass);

        document.getElementById("file").value = applet.getDocumentString(filePath);
        document.getElementById("sign").value = applet.getSignString();
        document.getElementById("cert").value = applet.getCertificateString();
        document.getElementById("mainForm").submit();


    }
</script>

<form id="mainForm" action="<portlet:actionURL>
          <portlet:param name="COMMAND" value="LOAD"/>
      </portlet:actionURL>">

    <hidden id="file" value="asdf"></hidden>
    <hidden id="cert" value="asdf"></hidden>
    <hidden id="sign" value="asdf"></hidden>
    <input type="button" onClick="processSigning();" value="click here!" >
</form>

portlets snippet:

public void processAction(ActionRequest request, ActionResponse response) throws PortletException {
    session = request.getPortletSession(true);
    String command = request.getParameter("COMMAND");
    System.out.println("command=" + command);
    log.info("command=" + command);


if ("LOAD".equals(command)) {

{
System.out.println("file");
log.info("file");
String fileBase64 = request.getParameter("file");
System.out.println(request.getParameter("file"));
log.info(request.getParameter("file"));
}
}
}

Answers


Check your portlet.xml if the portlet-class is pointing to MVCPortlet or your custom portlet class. It should point to the custom portlet class.


Try this form and see if it works for you:

<portlet:actionURL var="myActionURL"></portlet:actionURL>

<form id="mainForm" action="${myActionURL}" method="post">
    <input type="hidden" name="COMMAND" id="COMMAND" value="LOAD" />
    <input type="hidden" name="file" id="file" value="asdf" />
    <input type="hidden" name="cert" id="cert" value="asdf" />
    <input type="hidden" name="sign" id="sign" value="asdf" />
    <input type="button" onClick="processSigning();" value="click here!" >
</form>

Hope this helps.


There is method for the form must be specified, because Liferay Portal works with "post" method, also the names of hidden parameters must be used with "name" attribute, because request works with name, not ids


Need Your Help

Use custom tab bar with QMdiArea

c++ qt tabs qt4 qmdiarea

I see that QMdiArea has a tabbed view mode. I want to be able to split the main window with two QMdiArea widgets and to be able to drag and drop tabs between each of them. I have already done it wi...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.