Empty values when NextPageLinks in datatable pagination

UI Components for JSF
Post Reply
nmanelli
Posts: 2
Joined: 21 Jun 2022, 15:10

21 Jun 2022, 15:18

Hello everyone,

I'm using the last version of primefaces V11 and i'm using a datatable object with pagination :

Code: Select all

						<p:dataTable id="tableContent" var="p"
							value="#{ManageUsers$SearchUpdateUsers.users}" rows="10"
							width="696" paginator="true">
							<p:column headerText="User ID">
								<h:link value="#{p.userId}" outcome="UserDetails.jsp">
									<f:param name="userId" value="#{p.userId}" />
								</h:link>
							</p:column>
							<p:column headerText="First name">
								<h:outputText value="#{p.firstName}" />
							</p:column>
							<p:column headerText="Last name">
								<h:outputText value="#{p.lastName}" />
							</p:column>
							<p:column headerText="Country">
								<h:outputText value="#{p.countryName}" />
							</p:column>
							<p:column headerText="Status">
								<h:outputText value="#{p.userLocalStatusFormatted}" />
							</p:column>
							<p:column headerText="Role">
								<h:outputText value="#{p.group}" />
							</p:column>
						</p:dataTable>
When i load my page there is data on my table but when i'm trying to access to the next page, the page 2 appear but there is no value and message "No value to display".
I don't see anyone else in my case someone got an idea about this trouble ?

This is my java :

Code: Select all

 
 @Named("SearchUpdateUsers")
public class SearchUpdateUsers extends AbstractPageBean {
 private List<UserTO> users;
 
 public List<UserTO> getUsers() {
     return users;
 }
 }
 

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

21 Jun 2022, 18:38

Your bean looks like its not scoped and so its losing your list when it tries to go to page 2. You probably need to make it @ViewScoped.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

nmanelli
Posts: 2
Joined: 21 Jun 2022, 15:10

11 Jul 2022, 11:58

I trying to change scope like but there is no difference, when i change page i lose my data

Code: Select all

@ManagedBean
@ViewScoped
public class SearchUpdateUsers extends AbstractPageBean {
 private List<UserTO> users;
 
 public List<UserTO> getUsers() {
     return users;
 }
 }

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

11 Jul 2022, 13:59

It works fine on the Showcase so you might want to follow the showcase examples.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 40 guests