我在liferay中有.jsp,并且使用javascript和applet,但是在发送到portlet的表单之后,在服务器端,portlet没有捕获表单,也没有在日志中显示其他消息。
jsp page的片段:
<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片段:
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"));
}
}
}
答案 0 :(得分:1)
如果portlet-class指向MVCPortlet或您的自定义portlet类,请检查portlet.xml。它应该指向自定义portlet类。
答案 1 :(得分:1)
试试此表单,看看它是否适合您:
<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>
希望这有帮助。
答案 2 :(得分:0)
必须指定表单的方法,因为Liferay Portal使用“post”方法,隐藏参数的名称也必须与“name”属性一起使用,因为请求使用name而不是id