<t:PanelTabbedPane> 내에서 <t:inputFileUpload>를 사용할 때 <t:message>가 제대로 표시되지 않습니다.
-
09-06-2019 - |
문제
JSP 페이지에서 나는 <h:form enctype="multipart/form-data">
일부 요소 포함: <t:inputText>
, <t:inputDate>
, 등.또한, 나는 몇 가지를 추가했습니다. <t:message for="someElement">
그리고 사용자가 양식 내에서 여러 파일을 한 번에 하나씩 업로드할 수 있도록 하고 싶었습니다. <t:inputFileUpload>
) 이 시점에서 내 코드는 정상적으로 작동합니다.
양식을 안에 넣으려고 할 때 두통이 발생합니다. <t:panelTabbedPane serverSideTabSwitch="false">
(물론, 내부에서는 <t:panelTab>
)
TabbedPane 예제의 소스 코드에 표시된 구조를 다음에서 복사했습니다. 토마호크의 예, <f:subview>
태그를 추가하고 panelTab 태그를 새 jsp 페이지에 넣습니다(사용 <jsp:include page="somePage.jsp">
지령)
우선, <t:inputFileUpload>
Managed Bean UploadedFile 속성에 할당된 값으로 파일을 로드하지 못했습니다. #{myBean.upFile}
그 다음에, 단서를 찾기 위해 인터넷 검색, 그럴 줄 알았어 <t:panelTabbedPane>
"autoform"이라는 양식을 생성하므로 중첩된 양식이 생성됩니다.좋아, 생성하는 문제를 해결했습니다. <h:form>
밖으로 <t:panelTabbedPane>
그리고 유레카!파일 입력이 다시 작동했습니다!(자동 양식은 생성되지 않습니다)
그런데 아, 깜짝이야!아 끔찍한 머피 법칙!나의 모든 <h:message>
실패하기 시작합니다.Eclipse 콘솔의 출력은 나에게 모든 것을 보여줍니다. <t:message>
존재하지 않는 요소 ID를 찾고 있습니다(ID가 찾고 있는 것과 부분적으로 동일하지만 ID 끝에서 이름이 변경됨).
이 시점에서 나는 <t:mesagges>
패널 시작 부분에 모든 유효성 검사 오류를 한 번에 표시하려면 태그(끝 부분의 "s" 참고)를 사용하면 정상적으로 작동합니다.따라서 유효성 검사 오류가 존재하며 패널 시작 부분에 올바르게 표시됩니다.
이 페이지에서 생성된 모든 유효성 검사 오류 메시지는 JSF 내장 유효성 검사 메시지입니다.현재 Backing Bean에는 정의된 유효성 검사기가 없습니다.
¿어떻게 얻을 수 있나요? <t:message for="xyz">
제대로 작동하나요?
저는 Geronimo를 애플리케이션 서버로 사용하는 Eclipse Ganymede 프로젝트에서 myFaces-impl-1.2.3과 함께 Tomahawk-1.1.6을 사용하고 있습니다. (Geronimo는 tomahawk jar를 WEB-INF/lib 폴더에 넣는 동안 myFaces jar 구현을 제공합니다. 애플리케이션)
"해결됨":이 문제는 myFaces 포럼에 보고된 문제입니다.
빠른 응답과 정보를 제공한 Kyle Renfro에게 감사드립니다.(잘했어 카일!)문제 보기
편집 1
1.- 빠른 답변을 주신 Kyle Renfro에게 감사드립니다.입력 요소 내부에 사용된 forceID 속성은 처음에는 작동하지 않지만 몇 가지 매우 까다로운 조정을 수행하면 <t:message for="xyz">
태그가 작동합니다.
내가 한 일은 다음과 같습니다.
1.내 태그를 갖는 중 <inputText id="name" forceId="true" required="true">
그만큼 <t:message>
작동하지 않습니다.
2.그런 다음 Eclipse 콘솔에서 오류 메시지를 살펴본 후 "id" 속성의 이름을 다음과 같이 변경했습니다.<inputText ID="이름j_id_1" forceId="true" 필수="true">
삼.그런 다음 <t:message>
일했다!!그러나 양식의 "제출" 버튼을 두 번째로 누른 후입니다.¡두번째!(JSF 라이프사이클에 무슨 일이 일어나고 있는 것 같습니다)
4.이는 페이지에 오류 메시지가 표시되도록 하려면 사용자가 제출 버튼을 두 번 눌러야 함을 의미합니다.
5.그리고 ID 끝에 "j_id_1" 문구를 사용하는 것은 매우 이상합니다.
편집 2
좋아, 여기에 코드가 있습니다. 귀찮지 않기를 바랍니다.
1.- 메인페이지.jsp (여기는 <t:panelTabbedPane>
그리고 <f:subview>
태그)
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@ taglib prefix="t" uri="http://myfaces.apache.org/tomahawk"%>
<html>
<body>
<f:view>
<h:form enctype="multipart/form-data">
<t:panelTabbedPane serverSideTabSwitch="false" >
<f:subview id="subview_tab_detail">
<jsp:include page="detail.jsp"/>
</f:subview>
</t:panelTabbedPane>
</h:form>
</f:view>
</body>
</html>
2.- 디테일.jsp (여기는 <t:panelTab>
꼬리표)
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@ taglib prefix="t" uri="http://myfaces.apache.org/tomahawk"%>
<t:panelTab label="TAB_1">
<t:panelGrid columns="3">
<f:facet name="header">
<h:outputText value="CREATING A TICKET" />
</f:facet>
<t:outputLabel for="ticket_id" value="TICKET ID" />
<t:inputText id="ticket_id" value="#{myBean.ticketId}" required="true" />
<t:message for="ticket_id" />
<t:outputLabel for="description" value="DESCRIPTION" />
<t:inputText id="description" value="#{myBean.ticketDescription}" required="true" />
<t:message for="description" />
<t:outputLabel for="attachment" value="ATTACHMENTS" />
<t:panelGroup>
<!-- This is for listing multiple file uploads -->
<!-- The panelGrid binding make attachment list grow as the user inputs several files (one at a time) -->
<t:panelGrid columns="3" binding="#{myBean.panelUpload}" />
<t:inputFileUpload id="attachment" value="#{myBean.upFile}" storage="file" />
<t:commandButton value="ADD FILE" action="#{myBean.upload}" />
</t:panelGroup>
<t:message for="attachment" />
<t:commandButton action="#{myBean.create}" value="CREATE TICKET" />
</t:panelGrid>
</t:panelTab>
편집 3
Kyle Renfro의 후속 조치에 대한 응답:
카일 말한다:
"페이지의 첫 번째 보기에서 inputText에 아무것도 없고 파일도 업로드되지 않은 상태에서 "CREATE TICKET" 버튼을 누르면 메시지 태그가 inputText에 대해 작동합니까?(즉.필수 = true) inputTexts에 대한 메시지는 작동하지만 inputFileUpload에 대한 메시지는 작동하지 않는지 궁금합니다."
발견된 동작은 다음과 같습니다.
1.- 유효성 검사 오류 메시지가 전혀 표시되지 않습니다. (메시지 태그가 작동하지 않습니다.) 하나의 유효성 검사 오류 메시지만 테스트하려고 해도(예: 첫 번째 입력 텍스트에 대한 메시지 테스트) 아무 것도 표시되지 않습니다. .
2.- Eclipse 콘솔에 다음과 같은 내부 오류가 표시됩니다.
ERROR [HtmlMessageRendererBase] Could not render Message. Unable to find component 'ticket_id' (calling findComponent on component 'j_id_jsp_1383779881_1:subview_tab_detail:j_id_jsp_1716158401_0j_id_1:j_id_jsp_1716158401_5j_id_1'). If the provided id was correct, wrap the message and its component into an h:panelGroup or h:panelGrid.
ERROR [HtmlMessageRendererBase] Could not render Message. Unable to find component 'description' (calling findComponent on component 'j_id_jsp_1383779881_1:subview_tab_detail:j_id_jsp_1716158401_0j_id_1:j_id_jsp_1716158401_8j_id_1'). If the provided id was correct, wrap the message and its component into an h:panelGroup or h:panelGrid.
ERROR [HtmlMessageRendererBase] Could not render Message. Unable to find component 'attachment' (calling findComponent on component 'j_id_jsp_1383779881_1:subview_tab_detail:j_id_jsp_1716158401_0j_id_1:j_id_jsp_1716158401_14j_id_1'). If the provided id was correct, wrap the message and its component into an h:panelGroup or h:panelGrid.
내가 본 것은 바로 여기다. "j_id_1"
생성된 ID의 단어(예: "ticket_id" ID):
j_id_jsp_1383779881_1:subview_tab_detail:j_id_jsp_1716158401_0j_id_1:j_id_jsp_1716158401_5j_id_1
그리고 생성된 HTML 결과 페이지를 보면 ID 이름이 다음과 같은 것을 확인했습니다("ForceId" 특성을 사용하지 않음).
<input id="j_id_jsp_1383779881_1:subview_tab_detail:j_id_jsp_1716158401_0j_id_1:ticket_idj_id_1" name="j_id_jsp_1383779881_1:subview_tab_detail:j_id_jsp_1716158401_0j_id_1:ticket_idj_id_1">
해결책
myfaces의 버그와 관련된 것 같습니다.시도해 볼 수 있는 최신 버전의 myfaces 및 tomahawk가 있습니다.빠른 테스트로 하위 보기 기능을 제거하겠습니다. Detail.jsp 페이지를 기본 페이지에 다시 복사합니다.
다른 팁
그만큼 forceId 토마호크 구성요소의 속성이 이 문제를 해결해야 합니다.
다음과 같은 것:
<t:outputText id="xyz" forceId="true" value="#{mybean.stuff}"/>
페이지의 첫 번째 보기에서 inputText에 아무것도 없고 파일이 업로드되지 않은 상태에서 "CREATE TICKET" 버튼을 누르면 메시지 태그가 inputText에 대해 작동합니까?(즉.필수 = true) inputTexts에 대한 메시지는 작동하지만 inputFileUpload에 대한 메시지는 작동하지 않는지 궁금합니다.