-1
다음 JSF 기반 xhtml 페이지의 명령 단추 actionListener
이벤트가 작동하지 않습니다. 페이지에 대한 유효성이 없습니다. 이벤트는 버튼 태그에 속성 process="@this"
을 추가 할 때만 작동합니다. 유효성 검사가 없으므로 유효성 검사 오류도 발생하지 않습니다. 하지만 프로세스 특성을 사용하면 Java 측 처리기 메서드에서 반환 된 성공 메시지를받습니다. 그래서 나는 원치 않는 프로세스 속성없이 막혔다.JSF 페이지 - 아직 검증이 필요하지 않은 이유는 무엇입니까?
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body style="margin:0 auto !important;width:80% !important;">
<h:form id="form1">
<p:panel id="rootPanel"
style="background-color:#E8E8E8 ;width=90%;padding:10px;margin:10px;border:2px solid black;">
<p:panel id="logoHeaderPanel"
style="background-color:#E8E8E8 ;width=70%;padding:30px;margin:30px;border:1px solid black;">
<h:panelGrid columns="2">
<h:graphicImage library="images" name="./headerImage.gif" />
<h:outputLabel style="font-size:2.1em;margin-left:30px"
value="Demo App" />
</h:panelGrid>
</p:panel>
<p:messages id="messages" autoUpdate="true"/>
<p:panel id="mainContentPanel"
style="background-color:#E8E8E8 ;width=70%;padding:60px;margin:30px;border:1px solid black;">
<h:panelGrid columns="4">
<h:outputLabel for="a" value="State Search" style="margin:10px;" />
<p:inputText id="a" value="" style="margin:10px;" />
<h:outputLabel for="b" value="Value" style="margin:10px;" />
<p:inputText id="b" value="" style="margin:10px;" />
<h:outputLabel for="c" value="City Search" style="margin:10px;" />
<p:inputText id="c" value="" style="margin:10px;" />
<h:outputLabel for="d" value="Value" style="margin:10px;" />
<p:inputText id="d" value="" style="margin:10px;" />
</h:panelGrid>
<h:panelGrid columns="2" style="float:right;">
<p:commandButton style="height:80px;" value="Generate Report"
id="reporting" actionListener="#{sampleBean.handlerMethod}" update="a"/>
</h:panelGrid>
</p:panel>
</p:panel>
</h:form>
</h:body>
</html>
자바 측 코드는
public void handlerMethod(ActionEvent actionEvent) {
System.out.println("Inside Listener");
FacesContext.getCurrentInstance().addMessage(
null,
new FacesMessage("Success! Action called."));
}