facebook

Primefaces calling JSF Component Method multiple times

  1. MyEclipse IDE
  2.  > 
  3. Spring Development
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #319173 Reply

    Peter
    Member

    Hi,

    I am using Primefaces with JSF and I am noticing that some prime faces components are calling methods like 17 times!

    I am using a simple Primefaces DataGrid and when i click the paginator to change the page up or down it calls the method 17 times. Here is the xhtml file containing the DataGrid and the mothod its calling to populate the it.

    
    <ui:composition xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:p="http://primefaces.prime.com.tr/ui"
        template="/WEB-INF/jsf/template.xhtml">
    
        <ui:define name="head">
        </ui:define>
    
        <ui:define name="content">
    <a id="#{SessionComponent.setMainPanelHeader('Take Role')}"/>    
            <h:form prependId="false">  
        <p:dataGrid var="member" value="#{AttendanceComponent.listEventGroupMembers()}" columns="2"  
            rows="1" paginator="true" effect="true"  paginatorPosition="bottom" 
            paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
            >  
              
            <p:column >
              
                <p:panel header="#{member.firstname} #{member.lastname}" style="text-align:center">  
                    <h:panelGrid columns="1" style="width:100%">  
    
                            <h:selectBooleanCheckbox id="attended_${member.no}" value="#{member.attendedevent}" />
                            </h:panelGrid>  
                </p:panel>  
            </p:column>  
      
        </p:dataGrid>  
      
          <p:commandButton image="save" ajax="false" style="margin-right:20px;" value="#{eventmsgs['navigation.save']}" action="#{AttendanceComponent.saveEventAttendance()}"/>
    </h:form>     
        
        </ui:define>
    </ui:composition>
    
    
        @Transactional
    
        public List<Member> listEventGroupMembers() {
    
    
    
            System.out.println(i++);
    
            eventMembers = attendanceEvent.getGroup().getMembers();
    
    
    
            for (Iterator iterator = eventMembers.iterator(); iterator.hasNext();) {
    
                Member member = (Member) iterator.next();
    
    
    
                List<Attendance> attendance = attendanceDAO.findAttendancesforMember(member.getId(), attendanceEvent.getId());
    
    
    
                if (attendance.size() == 1) {
    
    
    
                    member.setAttendedevent(true);
    
                } else {
    
                    member.setAttendedevent(false);
    
                }
    
    
    
            }
    
    
    
            return eventMembers;
    
        }
    
    #319273 Reply

    jayperkins
    Member

    Hi,

    Can you answer a few questions:

    What version of MyEclipse for Spring you are using?
    Did you scaffold the jsf application?
    Do the 17 method calls happen when the page is initially loaded or only when the page up/down buttons are clicked?
    Is there any significance to the number 17 – are you displaying 17 records or are there 17 total records and you are displaying a subset of that number?
    I assume that it is the listEventGroupMembers() method that is being called repeatedly, correct?

    Thanks,

    Jay

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Primefaces calling JSF Component Method multiple times

You must be logged in to post in the forum log in