JSF is not printing the numbers

am trying to print these list of numbers below values in my page but these values are not printing in my jsf page, the rest of the tags in the page prints perfectly, i looked in my controller class whether the list has elements are not it has the values as [1,2,3,4] and I looked in the view source but these values are not available in the view source. can some one please let me know where am doing wrong. Thanks!!!

<h:dataTable value="#{pagination.pagesList}" var="page"> <h:outputText value="#{page}"></h:outputText> </h:dataTable>

Backing Code:

for (int i = 0; i < plth; i++) { pageInt[i] = ++pageno1; pagesList = Arrays.asList(pageInt); }

-------------Problems Reply------------

Add a column to your table:

<h:dataTable value="#{pagination.pagesList}" var="page">
<h:outputText value="#{page}"></h:outputText>


So you have a List<Integer>? This might be the problem because list elements are addressed by an integer index. As far as I know the list elements for h:dataTable have to be beans.

Apart from the missing <h:column>, as rightly mentioned by Matt, you've another problem here:

pagesList = Arrays.asList(pageInt)

This creates a List<int[]>, not a List<Integer>. If you have had used Generics properly (so if you have really used List<Integer> instead of List or List<?>), then you should already be trapped on this mistake by a compilation error.

Your current list has only one item which is an int[]. When you print it plain as an item inside the JSF datatable, it'll look something like

[[email protected]

Where the part after @ is the hashcode of the int[] object instance.

Your code makes at its own very little sense, so it is hard to give a suitable answer. I think you made another mistake by attempting to convert it to a list inside the loop instead of after the loop (so the list get overridden everytime until it holds the converted list of the last iteration). This is unnecessary.

But to the point, to convert an int[] to a List<Integer>, you need to loop over it again after you have filled the pageInt:

for (int i = 0; i < plth; i++) {
pageInt[i] = ++pageno1;

pagesList = new ArrayList<Integer>();

for (int page : pageInt) {

Or, maybe better, get rid of pageInt altogether and use pagesList all the way:

pagesList = new ArrayList<Integer>();

for (int i = 0; i < plth; i++) {

Category:java Views:1 Time:2012-03-07
Tags: java jsf

Related post

  • How can we print line numbers to the log in java 2008-09-22

    How to print line numbers to the log. Say when outputting some information to the log, I also want to print the line number where that output is in the source code. As we can see in the stack trace, it displays the line number where the exception has

  • How to Print Hexadecimal Numbers in PHP or Java 2009-08-13

    I need to print some data (a little bit strange formatted). I was writing it in PHP with if ($num%10==9) but it was impossible for me to get correct output. So take a look at this for example. We have x of files in folder. For this example x=36. X is

  • Print simple numbers on label printer (Brother, Dymo, etc) from C# (.NET) 2009-09-28

    As part of a project I'm working on, I need to automate a label printer. It will be one of those inexpensive USB printers from Brother or Dymo (open to other suggestions). All it needs to do is print two numbers on one label. The challenge is that I'

  • Printing 5 numbers in a row 2009-11-19

    I have to write a program to print the numbers 1 to 50, but with 5 numbers in a row, like: 1,2,3,4,5 6,7,8,9,10 like that till 50 without using lists for i in range(2,51): if i%5==0: print i this is giving me 5,10,15,20 Please help me --------------S

  • program to print odd numbers and even numbers on seperate threads 2010-04-30

    I am learning programming using pthreads. How can I write a program to print odd numbers and even numbers on separate threads. --------------Solutions------------- You need two synchronization objects such as a semaphore or a condition variable. The

  • My Char array is print out numbers when it is supposed to print out a Char 2010-09-23

    here is my code Scanner in = new Scanner(new File("words.txt")); int choice = 0; String str = in.next(); int FileSize = Integer.parseInt(str); char[] wordPlay = new char[100]; System.out.println("Filesize = " + FileSize); int i = 0; int count = 0; St

  • How to print line numbers for textbox in c# 2010-10-06

    This is going to be a long post. I would like to have suggestions if any on the procedure I am following. I want the best method to print line numbers next to each CRLF-terminated-line in a richtextbox. I am using C# with .NET. I have tried using Lis

  • Print consecutive numbers 2011-03-29

    How do i print consecutive numbers in using a single sql query .. like 1 , 2 , 3 ... --------------Solutions------------- Not sure if I've understood your question correctly, but if you just want to PRINT consecutive numbers I don't see why you could

  • Problems printing page numbers in either a selection or a section 2012-10-02

    For some reason I can't print the page numbers in the footer if I wish to print a selection although the pg numbers are shown in print preview, if I print the current page then the pg number is printed. As an aside how can I duplex print a multi sect

  • New IE9 will not print phone numbers on page? 2013-04-20

    Have skype so the phone numbers work as buttons. I have tried print preview and they do not show up if I print ftom there as well. Any help would be great on how to correct this problem? --------------Solutions------------- Hi, 1. When did the issue

  • print copy numbers on documents 2014-04-16

    Dear experts, I need to set up a way to print copy numbers on documents. The conditions: - documents will be different every time (it is labels - so it really depends on product; we will have to print e.g. 50 times label1, 40 times label 2, etc); - d

  • How to print line numbers for a multi-line character variable in R? 2014-05-09

    I'm trying to identify line numbers in a JAGS script stored in a scalar character variable. I want to add line numbers to cat output in R. To simplify the example, if I had a string: x <- "A\nB\nC" and I do cat(x), I get: A B C How can I print lin

  • Printing Prime Numbers in Assembly 2014-09-19

    I'm trying to print prime numbers from 1-100 in assembly, but not only is my code printing out extra numbers, but also excluding some prime numbers. Here is my main procedure: mov min, 1 loopStart: inc min ; min++ mov eax, min cmp eax, max ; compare

  • I wish to print page numbers only on a previously created document. 2015-03-16

    I have a previously printed document which I wish to reinsert in the printer and print page numbers only on it. Does anyone know how to do this? I'm using Word 2007. Thanks. --------------Solutions------------- In a new blank document, open the heade

  • Learning F# - printing prime numbers 2009-07-08

    Yesterday I started looking at F# during some spare time. I thought I would start with the standard problem of printing out all the prime numbers up to 100. Heres what I came up with... #light open System let mutable divisable = false let mutable j =

  • How to print hex numbers to a file? 2010-11-09

    I am trying to store every hex value from 0000 to fffe into a file. How would I use fwrite or fprintf to place these values into a file? At the moment, I have a while loop that prints all the numbers using printf (which is to the console screen), but

  • Printing prime numbers from 1 through 100 2011-03-05

    This c++ code prints out the following prime numbers: 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97. But I don't think that's the way my book wants it to be written. It mentions something about square root of a number. So I did

  • Java Thread synchronization - printing out numbers in right order 2011-04-11

    I'm learning how to work with threads in Java and I need some advice.. I want to print on the standard output numbers from 0..50 with the name of the thread that has done it using three threads. I have two classes - class Counter that implements Runn

  • Print largest number in a 2d array - why do my code print three numbers 2011-05-03

    I am trying to print out the largest number in a 2D array. My problem is that my output are three numbers instead of one - the largest. Why? Here is my code: public class Main { /** * @param args the command line arguments */ public static void main(

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.074 (s). 11 q(s)