我有一个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;
}
}
THX!
答案 0 :(得分:0)
您正在使用<h:commandButton>
这是一个JSF组件,将其替换为默认情况下启用了AJAX的Primefaces的<p:commandButton>
。