2011-04-29 4 views
1

단추를 클릭했지만 대화 상자가 표시되지 않아야 대화 상자에 표시되는 JSF 유효성 검사 메시지가 필요합니다.단추 클릭시 대화 상자에 JSF 유효성 확인 메시지 표시

<h:form prependId="false"> 
    <h:panelGrid columns="1" cellpadding="5"> 
     <p:commandButton value="Modal" onclick="dlg2.show();" type="button" /> 
    </h:panelGrid> 

<p:dialog header="Modal Dialog" widgetVar="dlg2" modal="true" height="200" width="400"> 
    <h:panelGrid columns="1" > 
    <p:messages /> 
    <p:inputText id="txt" value="#{converterBean.doubleValue}" required="true"/> 
    <p:commandButton ajax="false" value="Submit" action="#{converterBean.submit}" /> 
    </h:panelGrid> 
</p:dialog> 



    </h:form> 

답변

3

귀하의 사례는 this example from the primefaces showcase과 매우 유사합니다.

<h:form>은 내부에 <p:dialog>입니다. 또한 예에서 LoginBean.java 콜백 매개 변수 설정 방법에 주목하십시오.

변경 그것은 당신이 <p:messages> (이 예에서 <p:growl>를 갱신 갱신 <p:commandButton>.

1

글쎄, 당신은 특정 필드를에만 제출합니다 아래에 표시되는 내용을 예를 들어 을 처리 할 수있다라는 과정에서 옵션이 있습니다 데이터 전체가 아닌 someID만의 데이터.

 <p:dialog id="dialog" header="Login" widgetVar="dlg" width="600" > 

      <h:panelGrid columns="3" cellpadding="5" id="someID"> 
       <h:outputLabel for="username" value="Username: *" /> 
       <p:inputText 
        id="username" required="true" label="username" requiredMessage="Field required" /> 
       <p:message for="username"/> 

       <h:outputLabel for="password" value="Password: * " /> 
       <h:inputSecret 
        id="password" required="true" label="password" requiredMessage="Field required" /> 
       <p:message for="password"/> 

       <f:facet name="footer"> 
        <p:commandButton value="Login" update="display" process="someID" onsuccess="dlg.hide()" onerror="dlg.show()" /> 
       </f:facet> 
      </h:panelGrid> 
     </p:dialog> 
관련 문제