2017-11-14 19 views
0

기본 키와 다른 두 개의 필드가있는 엔티티가 있습니다. 기본 View JSP의 검색 컨테이너에 해당 컨테이너를 표시 할 수 있으며 편집/업데이트 기능을 구현하고자하므로 다른 JSP를 만들었습니다. renderURL포틀릿 : 나는 포틀릿에서 편집하고자하는 기업의 특성에 합격 PARAM을 그냥이 같은 태그 : 나는 어떤를 설정하면 업데이트 페이지 JSP에서Liferay 7 : hidden aui 입력이 매개 변수에 따라 값을 설정하지 않습니다.

<portlet:renderURL var="editEntity"> 
    <portlet:param name="jspPage" value="/update-page.jsp" /> 
    <portlet:param name="primaryKey" value="<%= entityId %>" /> 
    <portlet:param name="name" value="<%= entityName%>" /> 
    <portlet:param name="description" value="<%= entityDesc%>" /> 
</portlet:renderURL> 

입력 필드가 숨겨지면 매개 변수 기반 값이 사라져서 컨트롤러가 필드의 값을 처리 할 수 ​​없습니다.

예 :

<aui:input name="primaryKey" type="hidden" value="${primaryKey}" /> 
<aui:input name="primaryKey" type="hidden" value="${name}" /> 
<aui:input name="primaryKey" type="hidden" value="${description}" /> 

참고 :

: 난 단지 기본 키 필드를 숨기려면, 컨트롤러 서블릿은 다음과 같이 기본 키를 기반으로 내 엔티티를 처리하고 업데이트 할 수 있어야한다 ...

어떤 아이디어를 내가 입력 텍스트 입력 필드 설정하면 재미있는 것은이

<aui:input name="primaryKey" type="text" value="${name}" /> 
<aui:input name="primaryKey" type="text" value="${description}" /> 

은, 그 모든 것이 작동하지만 사용자가 기본 키, 뜨아를 입력하고 싶지 않아요 내가 어떻게 고칠 수 있니?

+0

이 내부 입니까? –

+0

물론. 왜 제대로 작동하지 않는지 모르겠다. – MEZesUBI

답변

0

문제의 해결책을 찾았습니다.

장시간 테스트 한 결과, 단순한 HTML 태그의 어느 곳에서나 $ {paramName}과 같은 매개 변수에 저장된 값을 가져올 수 없다는 것을 알았지 만 그 이유는 여전히 알 수 없습니다. 내가 무슨 짓을

는이 같은 JSP 스크립틀릿 내부의 매개 변수에 저장된 필요한 값을 요청했다 :

<aui:form action="<%= updateAbbreviationURL %>" method="post"> 
    <aui:input name="primaryKey" type="hidden" value="<%= primaryKey %>" /> 
    <aui:input name="entityName" label="Name" type="text" value="<%= name %>" /> 
    <aui:input name="entityDesc" label="Description" type="text" value="<%= description %>" /> 
    <aui:button name="submit" value="submit" type="submit" /> 
    <aui:button name="cancel" value="cancel" type="button" onClick="<%= viewURL %>" />   
</aui:form> 

I :

<% 
String primaryKey = request.getParameter("primaryKey"); 
String name = request.getParameter("name"); 
String description = request.getParameter("description"); 
%> 

는 그럼 난 내 양식에 갈 수 있었다 내 초기 구현은, 위의

감사의를 $ {paramName에}을 언급 한 바와 같이 나는 매개 변수 값을 참조 의미, 작동하지 않았다 왜 누군가가 나에게 말했다가 '정말 감사 거라고 전진!

0

을 View.jsp

<%@ include file="init.jsp" %> 
<portlet:actionURL name="testURL" var="testURL" /> 
<aui:form name="fm" method="post" action="<%= testURL.toString()%>"> 
<aui:input name="primaryKey" type="hidden" value="123" /> 
<aui:button-row> 
     <aui:button name="submit" type="submit" value="OK" /> 
    </aui:button-row> 
</aui:form> 

TestmvcportletPortlet.java

package com.example.portlet; 

import com.liferay.portal.kernel.exception.SystemException; 
import com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet; 
import com.liferay.portal.kernel.util.ParamUtil; 

import javax.portlet.ActionRequest; 
import javax.portlet.ActionResponse; 
import javax.portlet.Portlet; 
import javax.portlet.ProcessAction; 

import org.osgi.service.component.annotations.Component; 

@Component(
immediate = true, 
property = { 
    "com.liferay.portlet.display-category=category.sample", 
    "com.liferay.portlet.instanceable=true", 
    "javax.portlet.display-name=Test Portlet", 
    "javax.portlet.init-param.template-path=/", 
    "javax.portlet.init-param.view-template=/view.jsp", 
    "javax.portlet.resource-bundle=content.Language", 
    "javax.portlet.security-role-ref=power-user,user" 
}, 
service = Portlet.class 
) 
public class TestmvcportletPortlet extends MVCPortlet { 

@ProcessAction(name = "testURL") 
    public void addBook(ActionRequest actionRequest,ActionResponse actionResponse) throws SystemException { 
     String a = ParamUtil.getString(actionRequest, "primaryKey"); 
     System.out.println("Value is "+a); 

    } 
} 

당신이 코드를 놓친 것을 발견 나를 위해 일입니까?

+0

미안하지만, 아마도 너무 분명하지 않았다. 내 문제는 매개 변수 기반 값입니다. 내가 명확하게하기 위해 내 게시물을 수정하겠습니다. – MEZesUBI