的变化事件AJAX请求之前我有一个primefaces selectOneMenu用于对象和下方,其具有基于所述selectOneMenu用于有条件值呈现多个面板的面板。所以我在SelectOneMenu中包含了primefaces p:ajax请求。 ajax请求正确触发,面板显示正常,没有任何问题。确认对话框呼吁selectOneMenu用于
但现在我要他们改变了selectOneMenu用于继续进行Ajax请求,警告他们,他们在面板中输入的任何值都将丢失之前添加的确认。所以我添加了一个p:ajax的onstart事件,并包含一个javascript函数,它具有javascript确认。问题是,当用户选择“取消”按钮,阿贾克斯在不触发,但我selectOneMenu用于有选择的新的价值。我想在click事件中调用ajax请求。但是PrimeOne SelectOneMenu没有点击事件。
JSF代码:
<p:selectOneMenu id="methodOfId" value="#{cc.attrs.comboBoxValue}">
<f:selectItem itemValue="-1" itemLabel=""/>
<f:selectItems value="#{cc.attrs.comboBoxOptions}" var="methodOfId" itemValue="#{methodOfId.id}" itemLabel="#{methodOfId.name}"/>
<f:param name="cid" value="#{cc.attrs.beanConversationID}" />
<p:ajax update="dynamicPanels" process="@this" onstart="return confirmMethodOfIdChange()"/>
</p:selectOneMenu>
<p:panel id="dynamicPanels">
<ui:include src="#{cc.attrs.panelSrc}" />
</p:panel>
JavaScript代码:
function confirmMethodOfIdChange() {
var userResponse = confirm("Are you sure you want to change your selection?");
return userResponse;
}
现在,我怎么改变selectOneMenu用于显示其旧的价值?我想甚至使用下面的JavaScript代码在JSF SelectOneMenu中使用f:ajax。它要求确认,但我在确认框中按OK,它不执行ajax请求。
function confirmMethodOfIdChange(data) {
alert("inside confirm");
var ajaxStatus = data.status; // Can be "begin", "success" and "complete"
if (ajaxStatus == 'begin'){
var userResponse = confirm("Are you sure you want to change your selection?");
if (userResponse) {
return true;
} else {
return false;
}
}
return true;
}
简单和容易 –