2 Replies Latest reply on Nov 5, 2006 2:51 AM by Olaf Gerwig

    Problem with DataModelSelection

    Olaf Gerwig Newbie

      hi,
      i try to implement a jsf datatable with seam @datamodel and @datamodelselection.

      to generate the datamodel is no problem. but when a row is selected on the website, i cannot access to the values in @datamodelselection.

      thanks for help

      olaf

      the javacode:

      @Stateful
      @Name("articleSelection")
      public class ArticleSelectionBean implements ArticleSelection {

      @PersistenceContext
      private EntityManager em;

      @DataModel(value="searchArticle")
      private List searchArticle;

      @DataModel(value="detailArticle")
      private Article detailArticle;


      private Article detailArticleInternal;

      private String searchString;

      @DataModel
      private List selectetArticleParameter;

      @DataModelSelection(value="searchArticle")
      private Article selectedSearchArticle;



      @Factory("searchArticle")
      public String findOverview(){
      System.out.println("!!! - Suchstring:" + searchString);
      String searchPattern = searchString==null ? "%" : '%' + searchString.toLowerCase().replace('*', '%') + '%';
      searchArticle = em.createQuery("FROM Article art WHERE lower(art.artName) like :search").setParameter("search", searchPattern).getResultList();
      return "article_search_result";

      }

      public String findDetail(){
      System.out.println("Artikelnummer:" + getSelectedSearchArticle().getArtName());
      //detailArticle = em.merge(getSelectedSearchArticle());
      return "article_detail";

      }

      public String getSearchString() {
      return searchString;
      }

      public void setSearchString(String searchString) {
      this.searchString = searchString;
      }

      @Remove @Destroy
      public void destroy(){}

      }

      the Website:

      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:s="http://jboss.com/products/seam/taglib"
      template="template.xhtml">

      <!-- content -->
      <ui:define name="content">
      <h1>Suchresultat</h1>
      <h:dataTable columnClasses="firstColumn,secondColumn,thirdColumn"
      headerClass="headerAlignment"
      value="#{searchArticle}"
      var="art"
      rendered="#{searchArticle.rowCount>0}">
      <h:column>
      <f:facet name="header">Artikelbild</f:facet><h:graphicImage value="/img/article/thumbnails/#{art.artPicture}"/>
      </h:column>
      <h:column>
      <f:facet name="header">Artikeltitel</f:facet>#{art.artName}
      </h:column>
      <h:column>
      <f:facet name="header">ArtikelPreis</f:facet>#{art.artSalesPrice}
      </h:column>
      <h:column>
      <f:facet name="header">Artikeldetail</f:facet><s:link value="Artikel Bestellen" action="#{articleSelection.findDetail}"/>
      </h:column>
      </h:dataTable>
      </ui:define>
      </ui:composition>

      the exception:

      exception

      javax.servlet.ServletException: Exception while invoking expression #{articleSelection.findDetail}
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:121)
      org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:30)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


      root cause

      javax.faces.el.EvaluationException: Exception while invoking expression #{articleSelection.findDetail}
      org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:153)
      org.jboss.seam.core.Pages.callAction(Pages.java:212)
      org.jboss.seam.jsf.AbstractSeamPhaseListener.callPageActions(AbstractSeamPhaseListener.java:127)
      org.jboss.seam.jsf.AbstractSeamPhaseListener.beforeRender(AbstractSeamPhaseListener.java:98)
      org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:50)
      org.apache.myfaces.lifecycle.LifecycleImpl.informPhaseListenersBefore(LifecycleImpl.java:520)
      org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:342)
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
      org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:30)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)