File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Can Watch "Can New topic
Author

Can't get data from single selected datatable.

sam White
Ranch Hand

Joined: Feb 18, 2011
Posts: 208
Hello,

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 :


@ManagedBean(name="roleController")
//@SessionScoped
//@ViewScoped
public class RoleController //implements Serializable
{


@EJB
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());
roleManager.createRoleFromName(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"
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.prime.com.tr/ui">

<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}" />

</h:panelGrid>
</p:panel>

</html>





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:
au.com.houseware.wsdl.ix.generated.Role@cf2e58

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


Thanks
Sam
 
wood burning stoves
 
subject: Can't get data from single selected datatable.