i have a Primefaces application in which i fire up a dialog that contains a form. The dialog has a save/cancel button-pair. Within this dialog, i do not manage to have the oncomplete, onstart, etc., methods called. I saw on other replies the cause is no AJAX is being executed. However, i do not know the reason in this case, since the commandButton is of type submit and should have ajax="true" (by default). Can anyone put a bit of light in it?
My 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>
And here my backing bean:
@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!
You are using <h:commandButton>
which is a JSF component, replace that with Primefaces's <p:commandButton>
which is AJAX-enabled by default.