3

我在 DAO 中有以下方法,我在其中检索人员列表:

public List<Personne> getAllUsers() {

Query query = em.createQuery("SELECT p FROM Personne p where TYPE(p) =Utilisateur");
@SuppressWarnings("unchecked")
List <Personne> personnes =  query.getResultList();
return personnes;
    }

我想在数据表中显示人员列表:

  <p:dataTable value="#{desacBean.users}" var="us" paginator="true" selection="#  {desacBean.selectedUser}" selectionMode="single" rowKey="#{desacBean.getId(us)}}"   first="1">           

         <p:ajax event="rowSelect" listener="#{desacBean.onUserSelect}"/> 

            <p:column>
                <f:facet name="n">
                    <h:outputText value="nom" />
                </f:facet>
                <h:outputText value="#{us.nom}"/>
            </p:column>
            <p:column>
                <f:facet name="header">
                    <h:outputText value="prenom" />
                </f:facet>
                <h:outputText value="#{us.prenom}"/>
            </p:column>
         </p:dataTable>

我的豆:

@ManagedBean(name="desacBean")
@SessionScoped
public class DesactiveBean implements Serializable{


private static final long serialVersionUID = 1L;
private List<Personne> users = new ArrayList<Personne>();
private  Personne selectedUser;
private boolean panelRendered;
UserDAO daoUser = new UserDaoImpl();

    public void rowSelect(SelectEvent event){
    selectedUser =  (Personne)event.getObject();
    System.out.println("selectedUser = "+selectedUser.getNom_ut()); 
    this.panelRendered = true;
   }
   public int getId(Personne car)
   {
   return System.identityHashCode(car);
   }

   public void onUserSelect(SelectEvent event){ 
    this.selectedUser =  (Personne)event.getObject();
    System.out.println("selectedUser = "+selectedUser.getNom_ut());

  }

尝试显示此 dataTable 时出现以下错误:

java.lang.NumberFormatException: For input string: "prenom"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:492)
at java.lang.Integer.parseInt(Integer.java:527)
    For input string: "prenom"

我该如何解决?

4

1 回答 1

2

您可能会遇到与此处回答的问题相同的问题:NumberFormatException for input String

于 2013-06-10T15:51:44.757 回答