2016-01-20 139 views
1

有一个cq页面,页面中有很多组件。在一个组件中,我们有HTML表单代码。提交表单数据后,我需要在PageContext中设置所有值,并在同一页面上的其他组件中使用这些值。在AEM/CQ中使用post方法提交表单数据时出错提示

为了实现这一点,我创建了名为“MySamplecomponent”的组件。并在所有的HTML代码如下所示。我也创建了一个POST.jsp在同一个组件下。 Mysamplecompnent.jsp代码

<%@include file="/libs/foundation/global.jsp"%> 

<% 
    //String collapsed = properties.get("selection",""); 
    String collapsed= request.getParameter("testKey"); 
    out.println("value++"+collapsed); 
String category= request.getParameter("skill"); 
out.println("Category++"+category); 
pageContext.setAttribute("collapsed1",collapsed,PageContext.REQUEST_SCOPE); 

%> 

<form name="form1" id="form1" action="${currentPage.path}.html" method="post"> 
    <input type ="text" name="testKey" id="testKey" value="collapsed" /> 
    <input type ="hidden" name="pathValue" id="pathValue" value="myValue" /> 
    <select name="skill" style="display:block"> 
    <option value="1">Cricket</option> 
     <option value="2">Volley ball</option> 
     <option value="3">Tennis</option> 
</select> 
    <input type="radio" name="ravi" id="radiobutton" value="success" > radiobutton<br> 
     <input id="SubmitButton" name="SubmitButton" type="submit" value="SubmitButton" onclick="javascript:location.href='#'" /> 
</form> 

点击提交按钮得到下面误差

出错后处理的同时/内容/ MYPAGE/

状态
消息 javax.jcr.nodetype.ConstraintViolationException :没有找到匹配的属性定义:testKey =折叠 位置/内容/ myPage/ 父位置/内容 路径
/内容/ MYPAGE/ Referer的http://localhost:4502/content/myPage.html 更新日志

 

返回

修改后的资源

修改后的资源

回答

2

首先,我相信你的意思是PageContentPageContext中。如果您想使用Sling Post Servlet,则需要更改操作。

${currentPage.path}指的是Page节点而不是PageContent节点。页面节点对属性有非常严格的限制,你不能放置任何自定义道具,如testKey。因此,为了使您的代码正常工作,请将您的action属性替换为${currentPage.path}/jcr:content,它将起作用。

相关问题