JSF+datatable+Hibernate

M

mbunirigo

Hi all,
I'm tryint to display the rows of a table usign JSF framework, but I
receive the following error

javax.faces.el.EvaluationException: javax.faces.FacesException:
javax.faces.FacesException: Can't instantiate class:
'ar.com.redlink.MarWebSucursales.AdministradorUsuariosBean'.. class
ar.com.redlink.MarWebSucursales.AdministradorUsuariosBean :
java.lang.IllegalAccessException: Class java.beans.Beans can not
access a member of class
ar.com.redlink.MarWebSucursales.AdministradorUsuariosBean with
modifiers ""

I'm new working on this platform, so I need your help!!!

Here is the back bean class

public class AdministradorUsuariosBean {
private List listaUsuarios = new ArrayList();

public List getListaUsuarios() {
return cargarListaUsuarios();
}

public void setListaUsuarios( List listaUsuarios ) {
this.listaUsuarios = listaUsuarios;
}

private List cargarListaUsuarios() {
Session session=HibernateSessionFactory.getSession();
if( session != null ) {
String SQL_QUERY = "FROM TUsuarios u " +
"ORDER BY u.NombreUsuario";

Query query = session.createQuery(SQL_QUERY);
listaUsuarios = query.list();
}

The jsp code is this
<f:view>
<h:dataTable value="#{admUsuarios.listaUsuarios}" var="usuario">
<f:facet name="header">
<h:eek:utputText value="Lista de usuarios"/>
</f:facet>
<h:column>
<f:facet name="NombreUsuario">
<h:eek:utputText value="Nombre de Usuario"/>
</f:facet>
<h:eek:utputText value="#{usuario.nombreUsuario}"/>
</h:column>

and the faces-config.xml is this
<managed-bean>
<description>Administrador de usuarios</description>
<managed-bean-name>admUsuarios</managed-bean-name> <managed-bean-
class>ar.com.redlink.MarWebSucursales.AdministradorUsuariosBean</
managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>

What I'm doing wrong?
Thanks in advance!!!
 
M

Michael Plate

Hello,

Tag <h:dataTable of JSF can't work with List. You must converting this to
DataModel.

Can you inserted the following row in your bean:DataModel dataTableModel = new ListDataModel();
<<

and changed this
public List getListaUsuarios() {
return cargarListaUsuarios();
}

public void setListaUsuarios( List listaUsuarios ) {
this.listaUsuarios = listaUsuarios;
}
<<

topublic DataModel getListaUsuarios() {
return dataTableModel.setWrappedData( cargarListaUsuarios() );
}

public void setListaUsuarios( DataModel listaUsuarios ) {
this.listaUsuarios = listaUsuarios;
}
<<

best regards
Michael
 
M

mbunirigo

Thank you, Michael for your response.
I've changed my back bean in this way:

public class AdministradorUsuariosBean {

DataModel listaUsuarios = new ListDataModel();

AdministradorUsuariosBean() {
}

public DataModel getListaUsuarios() {
listaUsuarios.setWrappedData(cargarListaUsuarios());
return listaUsuarios;
}

public void setListaUsuarios( DataModel listaUsuarios ) {
this.listaUsuarios = listaUsuarios;
}

But the problem persists. I'm really new in java and jsf framework, so
any basic suggestion may be important.
Thanks agais, Mariano
 
M

mbunirigo

Hello again, I found the problem in the class constructor
I forgot the public claus in the definition

I change
AdministradorUsuariosBean() { }
<<
public AdministradorUsuariosBean() { }

and everything works fine.

Thank you, Michael again.
Best regards, Mariano
 
M

Michael Plate

excellent :)

best regards
Michael

Hello again, I found the problem in the class constructor
I forgot the public claus in the definition

I change
AdministradorUsuariosBean() { }
<<
public AdministradorUsuariosBean() { }

and everything works fine.

Thank you, Michael again.
Best regards, Mariano
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,701
Latest member
XavierQ83

Latest Threads

Top