I am using PF 5.1 and inputSwitch(which has a Blank switch and ON/OFF switch,) in the cellEditor of datalist, the display of growl message is happening for a fraction of a second when clicked on ON/OFF switch, if clicked on the other BLANK switch works fine. Here is the sample of the xhtml code:
Code: Select all
<h:form id="UploadCreateForm"
>
<p:panel>
<p:dataTable id="datalist"
value="#{taskListController.items}"
var="item"
rowKey="#{item.taskId}"
paginator="true"
rows="10"
rowsPerPageTemplate="10,20,30,40,50"
selectionMode="single"
selection="#{taskListController.selected}">
<p:column>
<f:facet name="header">
<h:outputText value="Task Id"/>
</f:facet>
<h:outputText value="#{item.taskId}"/>
</p:column>
<p:ajax event="rowSelect" />
<p:ajax event="rowUnselect" />
<p:column headerText="Task Status">
<f:facet name="header">
<h:outputText value="Task Status"/>
</f:facet>
<p:cellEditor>
<f:facet name="output">
<p:inputSwitch value="#{item.taskArchived}" >
<p:ajax listener="#{taskListController.listen(item)}" event="change" update=":growl">
<f:setPropertyActionListener target="#{taskListController.selected}" value="#{item}"/>
</p:ajax>
</p:inputSwitch>
</f:facet>
<f:facet name="input">
<p:inputSwitch value="#{item.taskArchived}" >
<p:ajax listener="#{taskListController.listen(item)}" event="change" update=":growl">
<f:setPropertyActionListener target="#{taskListController.selected}" value="#{item}" />
</p:ajax>
</p:inputSwitch>
</f:facet>
</p:cellEditor>
</p:column>
</p:dataTable>
</p:panel>
</h:form>
Code: Select all
public void listen(TaskList l) throws Exception
{
System.out.println(l.getTaskArchived());
super.setSelected(l);
super.save();
String summary = l.getTaskArchived()? "Checked" : "Unchecked";
FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO,summary,summary);
FacesContext.getCurrentInstance().addMessage("successInfo", facesMsg);
}
Regards
sentil