Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Can't get data from single selected datatable.  RSS feed

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() {"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?

It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!