<p:inputSwitch display growl message for fraction of second

UI Components for JSF
Post Reply
senthinil
Posts: 54
Joined: 10 Jul 2013, 14:53

15 Nov 2014, 18:19

Hi

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>
and the Java code snippet

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);
    }
Please help me with a possible solution.

Regards
sentil

senthinil
Posts: 54
Joined: 10 Jul 2013, 14:53

16 Nov 2014, 11:35

Hi

Having made some investigations in the inputSwitch, Click on the Text (on/off) passes two requests rather one, if clicked on the empty button it sends only one request.

The number of requests passed can be seen in Firfox Inspect element with the Network tab in it. But in primefaces showcase inputSwitch demo only one request is sent for text on/off button and empty buttons

Please help me with the resolution asap

Regards
sentil

bsanders1979
Posts: 69
Joined: 02 Jun 2013, 18:37

15 Dec 2014, 21:28

Greetings,
Chances are, your growl is set to autoUpdate. So, when the first request completes, the growl displays. Then the second request fires, but there is nothing to display for the growl, so it disappears. Couple of things you need to ask yourself: Is the second request necessary? Can the growl not autoUpdate? Hope this helps.
PF 5.0
PF Ext 0.7.1
OmniFaces 1.7
Tomcat 7.0.37
JSF 2.1.24

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

16 Dec 2014, 17:55

This has most likely also got to do with differences in expectation. I expect the growl to at least show message for a certain period, even if the component is updated. When updated, new messages should be added, not overwrite existing ones, and if there are no new messages, the existing ones should at least remain displayed a certain amount of time...

senthinil
Posts: 54
Joined: 10 Jul 2013, 14:53

01 Jan 2015, 14:36

Thanks so much, u r right, I set the autoUpdate to false in <p:growl. Now its working as expected. Its my doubt for a long time, what is the difference between autoUpdate = true and autoUpdate=false?

Regards
sentil

bsanders1979
Posts: 69
Joined: 02 Jun 2013, 18:37

26 Jan 2015, 05:23

Sorry for the looong delay. But, for the sake of at least answering the question... On every ajax request, you have your process/update attributes which basically specify your inputs/outputs (respectively) for the request. When autoUpdate=false, you have to explicitly specify that you want to update/re-draw the component whereas when autoUpdate=true, it will be included in the payload automatically.
PF 5.0
PF Ext 0.7.1
OmniFaces 1.7
Tomcat 7.0.37
JSF 2.1.24

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 27 guests