[英]Primefaces commandButton asynchronous actions not fired
我有一個Primefaces應用程序,在其中啟動了包含表單的對話框。 該對話框具有一個保存/取消按鈕對。 在此對話框中,我無法調用oncomplete,onstart等方法。 我在其他答復上看到原因是沒有執行AJAX。 但是,在這種情況下,我不知道原因,因為commandButton的類型為Submit,並且應具有ajax =“ true”(默認情況下)。 誰能給它一點光?
我的xhtml:
<composite:interface>
<composite:attribute name="bean" required="true"/>
</composite:interface>
<composite:implementation>
<h:outputScript library="careplan" name="js/utils.js" />
<p:dialog id="addEventDialog" widgetVar="addEventDialog" header="#{careplanMessages['panel.title.eventAdd']}" modal="true" resizable="false">
<h:form id="eventAddForm" widgetVar="eventAddForm">
<p:fieldset legend="#{careplanMessages['label.field.data']}" >
<h:panelGrid id="formGrid" widgetVar="formGrid" columns="2" cellpadding="5">
<p:outputLabel for="parentNode">#{careplanMessages['label.field.parentNode']}</p:outputLabel>
<p:inputText id="parentNode" label="#{careplanMessages['label.field.parentNode']}" value="#{cc.attrs.bean.parentNode}" required="true"/>
<p:outputLabel for="name">#{careplanMessages['label.field.eventName']}</p:outputLabel>
<h:panelGrid columns="2">
<p:inputText id="name" label="#{careplanMessages['label.field.eventName']}" value="#{cc.attrs.bean.name}" required="true" />
<p:message for="name" display="icon" />
</h:panelGrid>
<p:outputLabel for="description">#{careplanMessages['label.field.description']}</p:outputLabel>
<h:panelGrid columns="2">
<p:inputTextarea id="description" label="#{careplanMessages['label.field.description']}" value="#{cc.attrs.bean.description}" rows="6" cols="33" required="true"/>
<p:message for="description" display="icon" />
</h:panelGrid>
<p:outputLabel for="minutes">#{careplanMessages['label.field.minutes']}</p:outputLabel>
<h:panelGrid columns="2">
<p:spinner id="minutes" label="#{careplanMessages['label.field.minutes']}" value="#{cc.attrs.bean.minutes}" min="0">
<f:validateDoubleRange minimum="1.0" />
</p:spinner>
<p:message for="minutes" display="icon" />
</h:panelGrid>
<p:outputLabel for="active">#{careplanMessages['label.field.active']}</p:outputLabel>
<p:selectBooleanCheckbox id="active" label="#{careplanMessages['label.field.active']}" value="#{cc.attrs.bean.active}" />
</h:panelGrid>
</p:fieldset>
<p:separator />
<h:panelGrid columns="2" width="100%">
<h:commandButton
value="#{careplanMessages['button.save']}"
onclick="alert ('onclick')"
onstart="alert ('onstart')"
onsuccess="alert ('onsuccess')"
onerror="alert ('onerror')"
oncomplete="alert ('oncomplete')"
styleClass="btn btn-default btn-small" />
<h:commandButton type="button" value="#{careplanMessages['button.cancel']}" onclick="PF ('addEventDialog').hide()" styleClass="btn btn-default btn-small" />
</h:panelGrid>
</h:form>
</p:dialog>
</composite:implementation>
</ui:composition>
這是我的支持豆:
@ManagedBean
@ViewScoped
public class HouseLepEventAddBean implements Serializable {
private static final Logger LOGGER = LoggerFactory.getLogger (HouseLepEventAddBean.class);
private String name = null;
private String parentNode = "test";
private List <SelectItem> parentNodeList = null;
private String description = null;
private int minutes = 0;
private boolean active = true;
@PostConstruct
public void init () {
}
public String getName () {
return name;
}
public void setName (String name) {
this.name = name;
}
public String getParentNode () {
return parentNode;
}
public void setParentNode (String parentNode) {
this.parentNode = parentNode;
}
public List <SelectItem> getParentNodeList () {
return parentNodeList;
}
public void setParentNodeList (List <SelectItem> parentNodeList) {
this.parentNodeList = parentNodeList;
}
public String getDescription () {
return description;
}
public void setDescription (String description) {
this.description = description;
}
public int getMinutes () {
return minutes;
}
public void setMinutes (int minutes) {
this.minutes = minutes;
}
public boolean isActive () {
return active;
}
public void setActive (boolean active) {
this.active = active;
}
}
謝謝!
您正在使用<h:commandButton>
它是一個JSF組件),請替換為Primefaces的<p:commandButton>
(默認情況下已啟用AJAX)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.