1 Reply Latest reply on Aug 3, 2010 12:22 AM by shane lee

    Newbie Seam DataModel cannot be cast to ArrayList

    Doug Molina Newbie

      I am new to SEAM trying out from a generated app some changes like implement a data selecitonemenu where i can show data from a table in a form,
      i am getting the following exception

      java.util.ArrayList cannot be cast to javax.faces.model.DataModel

      It may be something very basic but i havent found a good example for this, maybe someone can point me out to one. I am reading Seam in Action and Seam Framework from YUAN havent found one example like the one i am trying.

      This is my bean

          public class FuncionesAcciones {
           private Log log;
           StatusMessages statusMessages;
           protected EntityManager entityManager = null;
           @Out(required = false)
           protected Usuarios selectedUser;
           @Out(required = false)
           protected List<Usuarios> listaUsers = null;
           public String view() {
            return "/AccionesEdit.xhtml";
           public void listarUsuarios() {
            List resultList = entityManager.createQuery(
                    "select idUsuarios from Usuarios")
            listaUsers = (List<Usuarios>) resultList;
          //  "select idUsuarios,NombreUsuario from Usuarios")
           public void funcionesAcciones() {
            // implement your business logic here
            log.info("FuncionesAcciones.funcionesAcciones() action called");
           // add additional action methods

      This is the part where i use it in the Facelet

             <s:decorate id="usuariosIdUsuariosField" value="#{FuncionesAcciones.selectedUser}"          template="layout/edit.xhtml">
                   <ui:define name="label">Usuario que Identifica Accion</ui:define>
                   <h:selectOneMenu  name="usuario" id="usuariosIdUsuarios" required="true"   value="Usuarios.nombreUsuario">
                      <f:selectItems var="_usuario" value ="#{listaUsers}" label="#{_usuario.NombreUsuario}"/>

      Someone can point me out in the right direction , i am new to SEAM somewhat middle experience in JAVA/Hibernate i come from PHP so the learning curve is apparently very hard right now as a beginner.

        • 1. Re: Newbie Seam DataModel cannot be cast to ArrayList
          shane lee Newbie

          Hi Doug,
          You seemed to be confused from displaying your output either as a drop down combo box(h:selectOneMenu) or as a table(h:dataTable).

          To see an example of drop down combobox go to:

          See below for data table example:

          Action class:

          @DataModel private List<Attachment> attachments;
              @Out(required = false)
              private Attachment attachment;
               * Get list of attachments and outject to conversation scope    
              public void getInquiryAttachments(){
                  attachments = entityManager.createNamedQuery("Attachment.findAllbyInquiryId").setParameter("inquiry", newInquiry.getId() ).getResultList();

          View xhtml page:

                  <f:facet name="header">General Inquiry form - List of attachments</f:facet>
                  <div class="section">
                      <h:outputText value="No Attachments Found"
                         <rich:dataTable id="attachments" value="#{attachments}" var="attachment"
                              rendered="#{attachments.rowCount>0}" rowClasses="rvgRowOne,rvgRowTwo">
                              <h:column id="column1">
                                   <f:facet  id="NameFacet" name="header">File name</f:facet>
                                   <h:outputText value="#{attachment.fileName}" />
                              <h:column id="column2">
                                   <f:facet id="DescriptionFacet" name="header">Document</f:facet>
                              <h:column id="column3">
                                   <f:facet id="SizeFacet" name="header">Size</f:facet>
                              <h:column id="column4">
                                   <f:facet id="FileTypeFacet" name="header">FileType</f:facet>
                              <h:column id="column5">
                                   <f:facet id="Action1Facet" name="header"></f:facet>
                                   <h:commandLink id="remove" value="Remove"
                                        action="#{inquiry.remove}" />
                              <h:column id="column6">
                                   <f:facet id="Action2Facet" name="header"></f:facet>
                                   <h:commandLink id="view" value="View" action="#{inquiry.sendFile}" />

          There is a good example of this in Dan Allens Seam in Action book.