How to send values entered in two separate <h:inputText/> elements to a single method in java? [duplicate] - jsf

This question already has an answer here:
How to send form input values and invoke a method in JSF bean
(1 answer)
Closed last month.
I have a problem as I mentioned in the topic title. I want to pass the values from two different <h:inputText/> elements as parameters to a method that takes two parameters in Java and send the result to a single <h:outputText/> element. I don't know how to do this.
For this problem, I created the setter and getter methods separately on the CDI Bean to represent both <h:inputText/> elements. Sample codes are as follows.
XHTML Code:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://xmlns.jcp.org/jsf/passthrough"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Ana Sayfa</title>
</h:head>
<h:body>
<h:form id="indexForm">
<h:outputLabel value="Tarih1"/><br/>
<h:inputText id="tarih1Text" p:placeholder="gg/aa/yyyy" value="#{dateCDIBean.date1}"/>
<br/>
<h:outputLabel value="Tarih2"/><br/>
<h:inputText id="tarih2Text" p:placeholder="gg/aa/yyyy" value="#{dateCDIBean.date2}"/>
<br/>
<h:commandButton id="btn" value="Farkı Hesapla"/>
<br/>
<h:outputText id="cikti" value="#{dataCDIBean.value}"/>
</h:form>
</h:body>
</html>
CDI Bean Code:
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/JSF/JSFManagedBean.java to edit this template
*/
package tr.com.bilisim.cdibeans;
import jakarta.enterprise.context.SessionScoped;
import jakarta.inject.Named;
import java.io.Serializable;
import tr.com.selimfatih.tarihfark.TarihFark;
import tr.com.selimfatih.tarihkontrol.TarihKontrol;
/**
*
* #author Mehmet Fatih ÇİN
*/
#Named
#SessionScoped
public class dateCDIBean implements Serializable {
private String date1;
private String date2;
private String value;
/**
* Creates a new instance of dateCDIBean
*/
public dateCDIBean() {
}
public String getDate1() {
return date1;
}
public void setDate1(String date1) {
TarihKontrol tk1 = new TarihKontrol();
tk1.Kontrol(date1);
if (tk1.hataliMi == false) {
this.date1 = date1;
}
}
public String getDate2() {
return date2;
}
public void setDate2(String date2) {
TarihKontrol tk2 = new TarihKontrol();
tk2.Kontrol(date2);
if (tk2.hataliMi == false) {
this.date2 = date2;
}
}
public String hesapla() {
if (date1 != null && date2 != null) {
TarihFark fark = new TarihFark(date1, date2);
date1 = "";
date2 = "";
return fark.GunFark() + " gün, " + fark.AyFark() + " ay, " + fark.YilFark() + " yıl";
} else {
return "Yukarıdaki alanlara \"gg/aa/yyyy\" ya da \"gg.aa.yyyy\" formatında tarih değeri giriniz.";
}
}
public String getValue() {
return hesapla();
}
public void setValue(String value) {
this.value = value;
}
}
How can I apply the solution in the topic title as an alternative to what I did above? Or can you tell me if this is possible?

<h:form id="indexForm">
<h:outputLabel value="Tarih1"/><br/>
<h:inputText id="tarih1Text" value="#{dateCDIBean.date1}"/>
<br/>
<h:outputLabel value="Tarih2"/><br/>
<h:inputText id="tarih2Text" value="#{dateCDIBean.date2}"/>
<br/>
<h:commandButton id="btn" value="Farkı Hesapla" action="#{dateCDIBean.concdata()}"/>
<br/>
<h:outputLabel id="cikti" value="#{dateCDIBean.value}"/>
</h:form>
public void concdata() {
value = date1 + date2;
PrimeFaces.current().ajax().update("indexForm:cikti");
}

Related

javax.el.PropertyNotFoundException: /index.xhtml #23,97 action="#{execise04.getInput}": Target Unreachable, identifier 'execise04' resolved to null [duplicate]

This question already has answers here:
Identifying and solving javax.el.PropertyNotFoundException: Target Unreachable
(18 answers)
Closed 4 years ago.
I've been getting the same constant problem. Currently now I'm getting the error
javax.el.PropertyNotFoundException: /index.xhtml #23,97 action="#{execise04.getInput}": Target Unreachable, identifier 'execise04' resolved to null
I'm not entirely sure what I'm doing wrong here is the code. I've looked at the other post that they say solved my issue and it doesn't solve my issue, and I don't understand a single thing its saying. Its not really giving a solution just turning me around in circles. Also I have had other issues such as once i press the button before I was getting a different error and it wouldn't open the second window that is supposed to display the output. Someone please help. I've been stuck on this for days and its getting incredibly frustrating.
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Exercise04</title>
</h:head>
<h:body>
<h:form>
<center>
<h3>
Compute Loan Payment
</h3>
<h:panelGrid columns="2">
<h:outputLabel value="Loan Amount"/>
<h:inputText id="amount" value="#{exercise04.loanAmount}"/>
<h:outputLabel value="Annual Interest Rate"/>
<h:inputText id="rate" value="#{exercise04.annualInterestRate}"/>
<h:outputLabel value="Number Of Years"/>
<h:inputText id="years" value="#{exercise04.numberOfYears}"/>
</h:panelGrid>
<br />
<h:commandButton value="Compute Loan Payment" action = "#{execise04.getInput}"/>
</center>
</h:form>
</h:body>
</html>
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<title>Exercise02</title>
</h:head>
<h:body>
<center>
<h:outputText escape="false" value="{exercise02.table}" />
</center>
</h:body>
</html>
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
#ManagedBean(name = "exercise04")
#SessionScoped
public class Exercise04 implements Serializable {
private double annualInterestRate;
private int numberOfYears;
private double loanAmount;
private java.util.Date loanDate;
public Exercise04() {
this(10, 1, 1000);
}
public Exercise04(double annualInterestRate, int numberOfYears, double loanAmount) {
this.annualInterestRate = annualInterestRate;
this.numberOfYears = numberOfYears;
this.loanAmount = loanAmount;
loanDate = new java.util.Date();
}
public double getAnnualInterestRate() {
return annualInterestRate;
}
public void setAnnualInterestRate(double annualInterestRate) {
this.annualInterestRate = annualInterestRate;
}
public int getNumberOfYears() {
return numberOfYears;
}
public void setNumberOfYears(int numberOfYears) {
this.numberOfYears = numberOfYears;
}
public double getLoanAmount() {
return loanAmount;
}
public void setLoanAmount(double loanAmount) {
this.loanAmount = loanAmount;
}
public double getMonthlyPayment() {
double monthlyInterestRate = annualInterestRate / 1200;
double monthlyPayment = loanAmount * monthlyInterestRate / (1
- (1 / Math.pow(1 + monthlyInterestRate, numberOfYears * 12)));
return monthlyPayment;
}
public double getTotalPayment() {
double totalPayment = getMonthlyPayment() * numberOfYears * 12;
return totalPayment;
}
public java.util.Date getLoanDate() {
return loanDate;
}
public String getInput() {
return "<p style=\"color:red\"><br />"
+ "Loan Amount: " + loanAmount + "<br />"
+ "Annual Interest Rate: " + annualInterestRate + "<br />"
+ "Number Of Years: " + numberOfYears + "<br />"
+ "Monthly Payment: " + getMonthlyPayment() + "<br />"
+ "Total Payment: " + getTotalPayment() + "</p>";
}
}
You are mixing CDI with JSF annotations. #ManagedBean and #RequestScoped (with this package) are JSF annotations. #Named is a CDI annotation. If you want to use CDI remove #ManagedBean and change #RequestScoped package to javax.enterprise.context. If you don't want to use CDI (which I do not recommend because these annotations are deprecated) remove #Named annotation and add name attribute to #ManagedBean annotation.

Affect of immediate attribute, and small discrepancy in found in JSF documentation

Below is the except from JSF official documentation - The immediate Attribute
Suppose that you have a page with a button and a field for entering
the quantity of a book in a shopping cart. If the immediate attributes
of both the button and the field are set to true, the new value
entered in the field will be available for any processing associated
with the event that is generated when the button is clicked. The event
associated with the button as well as the events, validation, and
conversion associated with the field are all handled when request
parameter values are applied.
If the button's immediate attribute is set to true but the field's
immediate attribute is set to false, the event associated with the
button is processed without updating the field's local value to the
model layer. The reason is that any events, conversion, and validation
associated with the field occur after request parameter values are
applied.
This suggests that, if immediate attribute is set TRUE for input component like textbox and command component then submit button then textbox value will be available for processing, however I think this isn't true, if immediate attribute of the submit button is true, then any data entered by the user on the form is not available for processing because event handling of the submit button will occur during the "apply request values" phase and will result in form submission, so it means that "update data model" phase will not be executed and hence managed bean properties will not be updated with the data entered by the user.
I even tried out this with code and my understanding looks true. However since the excerpt is from official Oracle documentation so I would like to know if I am missing something.
Below is my code sample:
greeting.xhtml:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>Guess Number Facelets Application</title>
</h:head>
<h:body>
<h:form>
<h:graphicImage value="#{resource['images:OracleLogo.png']}"
alt="Duke waving his hand" />
<h2>
Hi, my name is #{userNameBean.lName}, #{userNameBean.fName}. I am thinking of a number from
#{userNumberBean.minimum} to #{userNumberBean.maximum}. Can you guess it?
</h2>
<p>
User number: <h:inputText id="userNo" title="Enter a number from 0 to 10:" value="#{userNumberBean.userNumber}">
<f:validateLongRange minimum="#{userNumberBean.minimum}" maximum="#{userNumberBean.maximum}" />
</h:inputText><br></br>
User fName: <h:inputText id="userFName" value="#{userNameBean.fName}" immediate="true" required="true"/><br></br>
User lName: <h:inputText id="userLName" value="#{userNameBean.lName}" immediate="true"/><br></br>
<h:commandButton id="submit" value="Submit" action="#{userNameBean.submitRequest}" immediate="true"/>
</p>
<h:message showSummary="true" showDetail="false"
style="color: #d20005;
font-family: 'New Century Schoolbook', serif;
font-style: oblique;
text-decoration: overline"
id="errors1" for="userNo" />
</h:form>
</h:body>
</html>
response.xhtml:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>Guess Number Facelets Application</title>
</h:head>
<h:body>
<h:form>
<h:graphicImage value="#{resource['images:OracleLogo.png']}"
alt="Duke waving his hand" />
<h2>
<h:outputText id="result" value="${'hip' lt 'hit'}" /><br></br>
<h:outputText id="result2" value="#{userNumberBean.response}" /><br></br>
<h:outputText id="result3" value="#{userNameBean.lName}" />, <h:outputText id="result4" value="#{userNameBean.fName}" />
</h2>
<h:commandButton id="back" value="Back" action="greeting" />
</h:form>
</h:body>
</html>
UserNumberBean:
import java.io.Serializable;
import java.util.Random;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;
#Named
#SessionScoped
public class UserNumberBean implements Serializable {
private static final long serialVersionUID = 5443351151396868724L;
Integer randomInt = null;
Integer userNumber = null;
String response = null;
private int maximum = 10;
private int minimum = 0;
public UserNumberBean() {
Random randomGR = new Random();
randomInt = new Integer(randomGR.nextInt(maximum + 1));
System.out.println("Duke's number: " + randomInt);
}
public void setUserNumber(Integer user_number) {
userNumber = user_number;
}
public Integer getUserNumber() {
return userNumber;
}
public String getResponse() {
if ((userNumber == null) || (userNumber.compareTo(randomInt) != 0)) {
return "Sorry, " + userNumber + " is incorrect.";
} else {
return "Yay! You got it!";
}
}
public int getMaximum() {
return (this.maximum);
}
public void setMaximum(int maximum) {
this.maximum = maximum;
}
public int getMinimum() {
return (this.minimum);
}
public void setMinimum(int minimum) {
this.minimum = minimum;
}
}
UserNameBean:
package com.db.nsw.izt;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
#Named
#RequestScoped
public class UserNameBean {
private String fName = "";
private String lName = "";
public String getfName() {
return fName;
}
public void setfName(String fName) {
this.fName = fName;
}
public String getlName() {
return lName;
}
public void setlName(String lName) {
this.lName = lName;
}
public String submitRequest(){
System.out.println("### " + fName + " | " + lName);
return "response";
}
}
UPDATE 1:
My environment details: JEE6, JSF 2.0, Mojara, WL 12.1.2 (glassfish.jsf_1.0.0.0_2-1-20.jar)

p:dataTable selected value setter doesn't work

I'm new in JSF and PrimeFaces and I can't understand why my setter for selected value doesn't set:
I've got main XHTML in which after click on <p:commandButton> I want to change selected row. But after changing selection of the row on data setter setSelectedBook() get null value on entrance.
I already set selection and rowKey for <p:dataTable>.
It looks like :
main XTML:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://xmlns.jcp.org/jsf/html"
>
<body>
<ui:composition template="./../../WEB-INF/pagesTemplate.xhtml">
<form>
<ui:define name="content">
<p:dataTable id="eventsDT" var="book" value="#{bookHolder.books}"
selectionMode= "single" selection="#{bookController.selectedBook}"
rowKey="#{book.id}">
<p:ajax event="rowSelect"/>
<p:ajax event="rowDblselect" listener="#{bookController.onDoubleRowSelect}" />
<p:column headerText="ID">
<h:outputText value="#{book.id}" />
</p:column>
<p:column headerText="Title">
<h:outputText value="#{book.longName}" />
</p:column>
</p:dataTable>
</ui:define>
<ui:define name="right">
<h:panelGrid columns="1" cellpadding="5">
<p:commandButton id="btnEdit" value="Edit"
action="#{navigationController.moveToBookEditPageSimple}"
style="width: 100px;height: 28px; margin-left: 10%"/>
</h:panelGrid>
</ui:define>
</form>
</ui:composition>
</body>
</html>
BookController that can't get value:
#Named("bookController")
#SessionScoped
#Local(BookView.class)
public class BookController implements Serializable {
public BookController() {
navigator = new NavigationController();
}
NavigationController navigator;
#Inject
BookHolder bookHolder;
private Book selectedBook;
public Book getSelectedBook() {
return selectedBook;
}
public void setSelectedBook(Book selectedBookValue) {
this.selectedBook = selectedBookValue;
}
public void onDoubleRowSelect(SelectEvent event) throws IOException {
String str = navigator.showPage("BookEdit");
FacesContext.getCurrentInstance().getExternalContext().redirect(str + ".xhtml");
}
}
BookHolderBean that contains data:
#Named("bookHolder")
#ApplicationScoped
public class BookHolder {
public BookHolder() {
}
#PostConstruct
void setValues() {
this.books = new ArrayList<>();
for (int i = 0; i < 10; i++) {
this.books.add(new Book(new ParkType(i, i,
"Book #: " + i + " (long name)",
"Book #: " + i + " (short name)",
"Book #: " + i + " (note)")));
}
}
private List<Book> books;
public List<Book> getBooks() {
return books;
}
public void setBooks(List<Book> parkTypes) {
this.books = parkTypes;
}
}
Class Book:
public class Book extends MainEntitie<Book> implements Serializable, SelectableDataModel<Book> {
#Inject
BookHolder bookHolder;
private final String longName;
private final String shortName;
public Book(BookBase sd) {
super(sd.getId(), false, false, sd.getNote());
this.longName = sd.getLongName();
this.shortName = sd.getShortName();
}
public String getLongName() {
return longName;
}
public String getShortName() {
return shortName;
}
#Override
public int getId() {
return super.getId();
}
#Override
public Object getRowKey(Book t) {
return t.getId();
}
#Override
public Book getRowData(String string) {
for (Book app : bookHolder.getBooks()) {
if (app.getId() == Integer.parseInt(string)) {
return app;
}
}
return null;
}
}
Since you use ui:define, I assume there is a ui:include in your template file (pagesTemplate.xhtml).
If so, that is great, but your included page has some unnecessary stuff, e.g. html and body tag (by the way: use h:body). No need for that.
See second part of this posting to learn how to include an xhtml file into another one.
You will notice that the content of ui:define is kind of "cut&pasted" into the your template file.
So, what about your form tag? It's being ignored (at least, I guess it won't be a parent of your datatable).
Make the h:form (again, use JSF's h:form instead of HTML form) a child of ui:define,
like:
<ui:composition template="/WEB-INF/template.xhtml"
xmlns=.....>
<ui:define name="content">
<h:form>
<p:dataTable ...>
...
</p:dataTable>
</h:form>
</ui:define>
</ui:composition>

change <h:outputText> into <h:inputText> ajax in PrimeFaces

I'm trying to make something that change <h:outputText> into <h:inputText> after clicking on button or link. Somtehing similar to this: How to build "edit" button in JSF and switch between h:outputText and h:inputText but I would like to use PrimeFaces.
I think this would be usefull: http://www.primefaces.org/showcase/ui/inplace.jsf
but I would like to make that edit mode fires after clicking on edit button or hyperlink, not after clicking on the text I want to change.
Of course after clicking edit button I would like that change to "accept" button that will allow me to save changes and change inputText into outputText
Take a look at this SSCCE, it does what you want.
TestBean.java
package com.mycompany;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
#ManagedBean
#ViewScoped
public class TestBean {
/**
* Controls if the input field is available or not
*/
private boolean editable = false;
/**
* The String value you want to edit
*/
private String value = "Default value";
/**
* Changes between the inputText and the outputText
*/
public void changeEditable() {
editable = !editable;
}
public String getValue() {
return value;
}
public boolean isEditable() {
return editable;
}
/**
* Definitely saves the value
*/
public void saveValue() {
FacesMessage message = new FacesMessage("Value " + value + " saved!");
FacesContext.getCurrentInstance().addMessage(null, message);
}
public void setEditable(boolean editable) {
this.editable = editable;
}
public void setValue(String value) {
this.value = value;
}
}
index.xhtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>JSF Demo</title>
</h:head>
<h:body>
<p:messages />
<h:form>
<h:panelGroup rendered="#{!testBean.editable}">
<h:outputText value="#{testBean.value}" />
</h:panelGroup>
<h:panelGroup rendered="#{testBean.editable}">
<p:inputText value="#{testBean.value}" />
</h:panelGroup>
<p:commandButton
value="#{testBean.editable ? 'Confirm value' : 'Change value'}"
update="#form" actionListener="#{testBean.changeEditable}" />
<p:commandButton value="Save value" ajax="false"
action="#{testBean.saveValue}" />
</h:form>
</h:body>
</html>

How to map an object in jsf from backing bean?

I am getting error while running this snippet as /facelet/crew/objectMapGossip.xhtml #14,94 value="#{objcetMapBean.searchCrewParam.staffNum}": Property 'staffNum' not readable on type java.lang.String
please help me out from this small error .. I am new to jsf so stucking at things basic ...
Thanks in advance :-)
This is my backing bean...
import javax.faces.bean.ManagedBean;
#ManagedBean(name = "objcetMapBean")
public class ObjectMapGossip {
private SearchCrew1 searchCrewParam = new SearchCrew1("212","kart","asd");
public SearchCrew1 getSearchCrewParam() {
return searchCrewParam;
}
public void setSearchCrewParam(SearchCrew1 searchCrewParam) {
this.searchCrewParam = searchCrewParam;
}
public String search() {
return "success";
}
}
class SearchCrew1 {
public SearchCrew1() {
super();
}
/**
* #param staffNum
* #param surName
* #param rank
*/
public SearchCrew1(String staffNum, String surName, String rank) {
super();
this.staffNum = staffNum;
this.surName = surName;
this.rank = rank;
}
private String staffNum;
private String surName;
private String rank;
public String getStaffNum() {
return staffNum;
}
public void setStaffNum(String staffNum) {
this.staffNum = staffNum;
}
public String getSurName() {
return surName;
}
public void setSurName(String surName) {
this.surName = surName;
}
public String getRank() {
return rank;
}
public void setRank(String rank) {
this.rank = rank;
}
}
This is my jsf page
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html 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">
<h:body>
<ui:composition template="/facelet/layout/mainlayout.xhtml">
<ui:define name="content">
<h:form>
<div align="left">
<h:outputText value="Staff Number: " />
<h:inputText id="staffnum" size="6" value="# {objcetMapBean.searchCrewParam.staffNum}" />
<h:outputText value="Surname: " />
<h:inputText id="surname" size="10" maxlength="25" value="# {objcetMapBean.searchCrewParam.surName}" />
<h:outputText value="Rank: " />
<h:inputText id="rank" size="3" value="#{objcetMapBean.searchCrewParam.rank}" />
<h:commandButton value="Search" action="#{objcetMapBean.search}" />
</div>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
We can use h:dataTable from jsf tag and map easily.
http://www.mkyong.com/jsf2/jsf-2-datatable-example/

Resources