我希望p:confirmDialog
显示p:selectBooleanButton
,p:commandButton
代码p: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:confirmDialog
当我在p:selectBooleanButton
整页中放置<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>
标记时,不可见。
这是我的代码
{{1}}
答案 0 :(得分:0)
selectBooleanButton无法确认。另一种选择是使用
<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>
在您的托管bean中
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;
}
<强>输出强>