File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Can't get data from single selected datatable. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Can Watch "Can New topic

Can't get data from single selected datatable.

sam White
Ranch Hand

Joined: Feb 18, 2011
Posts: 226

With JBOSS 6.0, JDK 1.6, Primefaces 2.2.1 and FreeBSD,
I have a single selected datatable list. When I click on it, my managed bean gets the entity " role", but the dialog is unable to get the value from the entity bean..

Here is my code for illustration:

Controller :

public class RoleController //implements Serializable

private RoleManager roleManager;
private Role selectedRole;
private String roleName;
private final static Logger logger = Logger.getLogger(RoleController.class.getName());
private ArrayList<Role> roleList;

public RoleController() {"Invoke roleController contructor.");
roleList = null;

public void createRole() {"Creating role "+getRoleName());

public Role getSelectedRole() {
return selectedRole;

public void setSelectedRole(Role selectedRole) {" === selectedRole: " + selectedRole.getRoleId());
this.selectedRole = selectedRole;


In the managed bean(controller) as shown above, whenever I click on a row, the setSelectedRole() method is get called, and the value of getRoleId() is returned correctly.

<html xmlns=""

<p:panel id="panel-edit" header="Edit Role" style="margin-bottom:10px;"

<h:panelGrid columns="5" cellpadding="4">
<hutputText value="Role ID: " />
<hutputText value="#{roleController.selectedRole.roleId}" />



In the above role_add.xhtml file, the roleId is always empty.

If I changed the line of outputText to the one shown as below:
<hutputText value="#{roleController.selectedRole}" />

the role_edit.xhtml prints the address of the Role object:

Can anyone tell me what have the code missing or misconfigured?

I agree. Here's the link:
subject: Can't get data from single selected datatable.
It's not a secret anymore!