选中时无法获取对象

时间:2014-05-26 12:53:41

标签: jsf java-ee

文件:ServiceAnnonce.java

  public List<Annonce> loadAnnonce( UserEntity idUser ) {
    Query query = getEntityManger().createQuery( "select u from "
            + getPersistentClass().getSimpleName()
            + " u where u.annonceUser= :idUser" ).setParameter( "idUser", idUser );
    List<Annonce> annonce = (List) query.getResultList();
    return annonce;
}

文件:DaoUser.java

public UserEntity loadUserByEmail( String email ) {
    Assert.notNull( email );
    UserEntity user = null;
    Query query = getEntityManger().createQuery( "select u from "
            + getPersistentClass().getSimpleName()
            + " u where u.email= :email" ).setParameter( "email", email );
    try {
        user = (UserEntity) query.getSingleResult();
    } catch ( NoResultException e ) {

    }
    return user;
}

文件:ServiceUser.java

public Annonce annonceEnFonctionId( Annonce annonce, String email ) {

    UserEntity user = userDao.loadUserByEmail( email );
    List<Annonce> a = annonceDao.loadAnnonce( user );

    Annonce an = annonce;

    for ( int i = 0; i < a.size(); i++ ) {
        if ( a.get( i ).getId() == (Long) an.getId() ) {

              an = annonce;
        }

    }

    return an;
}

文件:flow.xml

<transition on="annonceID" to="annonceEnFonctionId">
        <evaluate expression="userService.annonceEnFonctionId(annonce,user.getEmail())" result="flowScope.annonce" />
    </transition>

文件:OurAnnonce.java

    <p:dataTable var="item" value="#{annonce}">

        <p:column style="width:2%">
        <h:commandButton value="show" action="annonceID" />
        </p:column>
        <p:column>
    <h:outputText value="#{item.titre}" />                          
        </p:column>

文件:shwo.java

<p:dataTable var="valeur" value="#{annonce}">
        <p:column headerText="Model">
            <h:outputText value="#{valeur.titre}" />
        </p:column>
 </p:dataTable>

当我点击按钮显示时我应该获得更多关于annonce的详细信息,但我仍然总是得到DataBase中的第一个annonce任何想法?

0 个答案:

没有答案