Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2007

Tip: Looking for answers? Try searching our database.

JSF+datatable+Hibernate

Thread view: 
mbunirigo@gmail.com - 09 May 2007 21:40 GMT
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:outputText value="Lista de usuarios"/>
            </f:facet>
            <h:column>
                <f:facet name="NombreUsuario">
                    <h:outputText value="Nombre de Usuario"/>
                </f:facet>
                <h:outputText 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!!!
Michael Plate - 10 May 2007 08:44 GMT
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;
}
<<

to

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

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

best regards
Michael

> Hi all,
> I'm tryint to display the rows of a table usign JSF framework, but I
[quoted text clipped - 58 lines]
> What I'm doing wrong?
> Thanks in advance!!!
mbunirigo@gmail.com - 10 May 2007 14:45 GMT
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

> Hello,
>
[quoted text clipped - 97 lines]
> > What I'm doing wrong?
> > Thanks in advance!!!
mbunirigo@gmail.com - 10 May 2007 15:15 GMT
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

On 10 mayo, 10:45, mbunir...@gmail.com wrote:
> Thank you, Michael for your response.
> I've changed my back bean in this way:
[quoted text clipped - 120 lines]
> > > What I'm doing wrong?
> > > Thanks in advance!!!
Michael Plate - 10 May 2007 16:59 GMT
excellent  :-)

best regards
Michael

> Hello again, I found the problem in the class constructor
> I forgot the public claus in the definition
[quoted text clipped - 135 lines]
>> > > What I'm doing wrong?
>> > > Thanks in advance!!!


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.