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

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)

Related

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

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");
}

#javax.faces.view.ViewScoped call #PostConstruct on p:commandButton action from p:datatable column facet

I have a primefaces datatable where the commandButton's action addItem within the columns header facet always fires the CDI #ViewScoped beans #PostConstruct method, while the commandButton's action editItem from the column does not?!
Curiously enough this happens only, if the action methods return a non-null string?! Means, if both methods return null, the #PostConstruct method is not called, but I use a non-null string, because clicking the buttons should show a new #ViewScoped page.
The main problem in my real application is, that I do some initialization stuff within #PostConstruct, which should really happen only once during page construction!
datatable.xhtml
<?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:p="http://primefaces.org/ui"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<f:view>
<p:messages autoUpdate="true" showDetail="true"/>
<h:outputLabel value="Datatable Test"/>
<h:form>
<p:dataTable var="item" value="#{datatableBean.items}">
<p:column>
<f:facet name="header">
<p:commandButton value="Add Item" action="#{datatableBean.editItem(null)}"/>
</f:facet>
<p:commandButton value="Edit Item" action="#{datatableBean.editItem(item)}"/>
</p:column>
<p:column headerText="Id">
<p:outputLabel value="#{item.id}"/>
</p:column>
<p:column headerText="Name">
<p:outputLabel value="#{item.name}"/>
</p:column>
</p:dataTable>
</h:form>
</f:view>
</html>
addItem.xhtml
<?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:p="http://primefaces.org/ui"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<f:view>
<h:outputLabel value="Add Item"/>
</f:view>
</html>
editItem.xhtml
<?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:p="http://primefaces.org/ui"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<f:view>
<h:outputLabel value="Edit Item"/>
</f:view>
</html>
DatatableBean.java
package my.web.datatable;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.view.ViewScoped;
import javax.inject.Named;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
#ViewScoped
#Named
public class DatatableBean implements Serializable {
private List<Item> items = new ArrayList<>();
#PostConstruct
private void init() {
System.out.println(DatatableBean.class.getName() + " -> init()");
for (int i = 1; i <= 5; i++) {
items.add(new Item(i, "Item " + i));
}
System.out.println(DatatableBean.class.getName() + " <- init()");
}
public List<Item> getItems() {
return items;
}
public String editItem(Item item) {
System.out.println(DatatableBean.class.getName() + " -> editItem(): " + item);
if (item == null) {
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_INFO, "add item", null));
System.out.println(DatatableBean.class.getName() + " <- editItem()");
return "addItem.xhtml";
} else {
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_INFO, "edit item", item.toString()));
System.out.println(DatatableBean.class.getName() + " <- editItem()");
return "editItem.xhtml";
}
}
}
Item.java
package my.web.datatable;
public class Item {
private final int id;
private final String name;
public Item(int id, String name) {
this.id = id;
this.name = name;
}
public int getId() {
return id;
}
public String getName() {
return name;
}
#Override
public String toString() {
return String.format("[id=%d,name=%s]", id, name);
}
}
Is this a bug regarding command button within datatable column header facet? Or is there a better way, to do what I want?
I am using primefaces 6.0 on wildfly-10.0.0.Final with Mojarra 2.2.12!
Update: removed logger; call same method for addItem / editItem; added redirect / forward pages

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