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.


Need Your Help

JSF h:outputScript ordering and PrimeFaces jQuery

javascript jsf-2 primefaces

I want to use (Primefaces with TwitterBootstrap). Currently the DropDown menu it's not working if e.g. a p:dataTable is present. I've figured out, that it's working (without any Primefaces componen...

Convert VB.NET --> C# Projects

c# .net vb.net

Can anyone recommend a good application that could be used to convert VB.NET projects to C#, without having to do too much manual work?