3 Replies Latest reply on Jun 4, 2007 4:41 AM by Mikael Andersson

    @DataModelSelection problem,outjects the first element in th

    Mikael Andersson Master

      Hi,
      I'm learning seam at the moment and wonder what I'm doing wrong.

      Note:
      Read a previous post with the same problem where the problem was solved by switching form tomahawk datatable to standard datatable.
      I have tried with both standard datatable and richfaces one, but the problem persists.

      I'm trying to implement a simple search/select/edit/save use case with seam in order to learn how to use some of the features (annotations, scopes and pageflow).

      But in the search part of the flow, the first row is always outjected..

      And I just started with Seam yesterday, so please point out any tips you have for me :-)

      Backing bean:

      @Name("riskAddonBacking")
      @Scope( ScopeType.CONVERSATION)
      public class CountryRiskAddonBacking implements Serializable{
      
       /**
       *
       */
       private static final long serialVersionUID = 1L;
      
       @DataModel
       private List<CountryRiskAddonBean> searchResults;
      
       @DataModelSelection
       @Out(required=false)
       private CountryRiskAddonBean selectedItem;
      
       private String searchPattern;
      
       @Begin(pageflow="countryaddon")
       public void startPageFlow(){
      
       }
      
       public String performSearch(){
      
       int nbrHits = RandomUtils.nextInt()%10;
       List<CountryRiskAddonBean> tmpList = new ArrayList<CountryRiskAddonBean>(nbrHits);
       for(int i=0; i<nbrHits; i++ ){
       CountryRiskAddonBean cab = new CountryRiskAddonBean();
       cab.setTicketNumber("RSK-" + (RandomUtils.nextInt()%10000) );
       cab.setCptyName("CptyXYZ");
       cab.setCountryOfRisk("SWE");
       tmpList.add( cab );
       }
       searchResults = tmpList;
      
       return null;
       }
      
       public String save(){
       System.out.println("SAAAAAAVVVVVVIIIIIIIIINNNNNNNNGGGGGGGG to db");
      
       return "";
       }
      
       public String getSearchPattern() {
       return searchPattern;
       }
      
       public void setSearchPattern(String searchPattern) {
       this.searchPattern = searchPattern;
       }
      }
      


      search.xhtml:

      <html 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:t="http://myfaces.apache.org/tomahawk"
       xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
       xmlns:rich="http://richfaces.ajax4jsf.org/rich"
       xmlns:s="http://jboss.com/products/seam/taglib">
      <body>
      
      
      <ui:composition template="/WEB-INF/layout/template.xhtml">
       <ui:param name="title" value="Pageflow Start"/>
      
       <ui:define name="body">
       <h:form>
       <s:decorate>
       <h:inputText id="srchPatt" value="#{riskAddonBacking.searchPattern}" required="true"/>
       </s:decorate>
      
       <s:button action="#{riskAddonBacking.performSearch}" value="Search"/>
      
       <h:outputText value="Found #{searchResults.rowCount} hits"
       rendered="#{searchResults.rowCount > 0}"/>
       </h:form>
      
      
       <h:form rendered="#{not empty searchResults}">
       <h:dataTable value="#{searchResults}"
       var="_item">
       <h:column>
       <f:facet name="header">
       Ticket Number
       </f:facet>
       #{_item.ticketNumber}
       </h:column>
       <h:column>
       <f:facet name="header">
       Counterparty
       </f:facet>
       #{_item.cptyName}
       </h:column>
       <h:column>
       <f:facet name="header">
       Country of Risk
       </f:facet>
       #{_item.countryOfRisk}
       </h:column>
       <h:column>
       <f:facet name="header">
       Risk Addon
       </f:facet>
       #{_item.riskAddon}
       </h:column>
       <h:column>
       <f:facet name="header">
       Add/Edit
       </f:facet>
      
       <s:link action="edit" value="Edit" rendered="#{_item.riskAddon > 0}" />
       <s:link action="edit" value="Add" rendered="#{_item.riskAddon == 0}"/>
       </h:column>
       </h:dataTable>
       <!--
       <rich:dataTable value="#{searchResults}"
       var="_item">
       <rich:column>
       <f:facet name="header">
       Ticket Number
       </f:facet>
       #{_item.ticketNumber}
       </rich:column>
       <rich:column>
       <f:facet name="header">
       Counterparty
       </f:facet>
       #{_item.cptyName}
       </rich:column>
       <rich:column>
       <f:facet name="header">
       Country of Risk
       </f:facet>
       #{_item.countryOfRisk}
       </rich:column>
       <rich:column>
       <f:facet name="header">
       Risk Addon
       </f:facet>
       #{_item.riskAddon}
       </rich:column>
       <rich:column>
       <f:facet name="header">
       Add/Edit
       </f:facet>
      
       <s:link action="edit" value="Edit" rendered="#{_item.riskAddon > 0}" />
       <s:link action="edit" value="Add" rendered="#{_item.riskAddon == 0}"/>
       </rich:column>
       </rich:dataTable>
       -->
       </h:form>
      
       </ui:define>
      </ui:composition>
      
      </body>
      </html>
      


      countryaddon.jpdl.xml :

      <pageflow-definition
       xmlns="http://jboss.com/products/seam/pageflow"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation=
       "http://jboss.com/products/seam/pageflow http://jboss.com/products/seam/pageflow-1.2.xsd"
       name="countryaddon">
      
       <start-state name="start">
       <transition to="searchPage"/>
       </start-state>
      
       <page view-id="/countryaddon/search.xhtml" name="searchPage">
       <redirect/>
       <transition name="edit" to="editPage"/>
       </page>
      
       <page view-id="/countryaddon/edit.xhtml" name="editPage">
       <redirect/>
       <transition name="approve" to="approvePage"/>
       </page>
      
       <page view-id="/countryaddon/approve.xhtml" name="approvePage">
       <redirect/>
       <transition name="save" to="endPage">
       <action expression="#{riskAddonBacking.save}"/>
       </transition>
       <transition name="prev" to="editPage"/>
       </page>
      
       <page view-id="/countryaddon/end.xhtml" name="endPage">
       <redirect/>
       <end-conversation/>
       </page>
      
      </pageflow-definition>
      


      And OT, I get annoying error messages related to there not being a transaction, from the ExceptionFilter. Is there a cure for this, read a post about this problem but it didn't have a solution of how to get rid of it.

      Cheers,
      Mike