2014-02-05 4 views
0
나는 때라도 p:selectBooleanButtonp:confirmDialog을 보여주고 싶은

는 잘하지만 p:selectBooleanButton 전체 페이지가 아닌 내가 함께 p:confirmDialog 태그를 넣어 p:selectBooleanButton표시 P : P와 confirmDialog : selectBooleanButton

<p:commandButton value="#{confirm.message}" icon="#{confirm.image}" actionListener="#{confirm.handleChange()}" update="messages"> 
     <p:confirm header="Confirmation" message="Are you sure?" icon="ui-icon-alert" /> 
    </p:commandButton> 
<p:confirmDialog global="true" showEffect="fade" hideEffect="fade"> 
     <p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/> 
     <p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>  
    </p:confirmDialog> 

와 함께 작동 p:commandButton와 코드 명백한. 여기 내 코드

<p:selectBooleanButton value="false" onLabel="Yes" offLabel="No" onIcon="ui-icon-check" offIcon="ui-icon-close"> 
      <p:confirm header="Confirmation" message="Are you sure?" icon="ui-icon-alert" /> 
</p:selectBooleanButton> 
<p:confirmDialog global="true" showEffect="fade" hideEffect="fade"> 
    <p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/> 
    <p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>  
</p:confirmDialog> 
+0

내 생각의 온 클릭 이벤트가 selectBooleanButton에서 사용할 수 없습니다 때문입니다. 생성 된 HTML에서 p :에 대한 javascript가 첫 번째 경우에 p : commandButton의 onclick 이벤트에 추가됩니다. – 757071

+0

p : selectBooleanButton을 확인할 수 없습니다. 확인 상자를 추가 할 수 있습니다 – Makky

+0

'p : confirmDialog'의 인터페이스가'p : selectBooleanButton'에 의해 구현되지 않고 등록되지 않은 비헤이비어 예외가 throw되기 때문에 가능하지 않습니다. – Sarz

답변

0

selectBooleanButton을 확인할 수 없습니다. 다른 옵션은

private boolean selectedOption; 

    public BeanClass() { 

    } 

    public void showDialog() { 
     RequestContext context = RequestContext.getCurrentInstance(); 
     if (selectedOption) { 
      context.execute("testW.show()"); 
     } else { 
      context.execute("testW.hide()"); 
     } 

    } 

    public boolean isSelectedOption() { 
     return selectedOption; 
    } 

    public void setSelectedOption(boolean selectedOption) { 
     this.selectedOption = selectedOption; 
    } 

출력

<h:body> 
     <h:form id="form"> 

      <p:selectBooleanButton value="#{testBeanTwo.selectedOption}" onLabel="Yes" offLabel="No" 
       onIcon="ui-icon-check" offIcon="ui-icon-close"> 
       <p:ajax listener="#{testBeanTwo.showDialog}" /> 
      </p:selectBooleanButton> 

     </h:form> 
     <p:dialog id="test" widgetVar="testW" dynamic="true" modal="true" draggable="false"> 
      <p:panelGrid columns="2"> 

       <f:facet name="header"> 
       Are you sure ? 
       </f:facet> 
       <p:commandButton value="Yes"></p:commandButton> 
       <p:commandButton value="No"></p:commandButton> 
      </p:panelGrid> 


     </p:dialog> 


    </h:body> 

로 그리고 당신의 관리 빈에서 사용하는 것입니다

output

+0

감사합니다. 대체로 유용합니다. – Sarz

관련 문제