• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can't get data from single selected datatable.

sam White
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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() {
logger.info("Invoke roleController contructor.");
roleList = null;

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

public Role getSelectedRole() {
return selectedRole;

public void setSelectedRole(Role selectedRole) {
logger.info(" === 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="http://www.w3.org/1999/xhtml"

<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?

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic