0 Replies Latest reply on Nov 3, 2008 8:05 PM by valatharv

    Repeat sample exception in seam

    valatharv
      I am trying to run Repeat sample in seam
      http://livedemo.exadel.com/richfaces-demo/richfaces/repeat.jsf?c=repeat&tab=usage

      I just copied the code from above link, is anything I am doing wrong ?? or is it issue with version... I am using "jboss-4.2.3", "jboss-seam-2.0.2.SP1"

      but it gives the following error:
      "Caused by: javax.el.ELException: /TestRepeat.xhtml @22,102 binding="#{updateBean.repeater}": java.lang.IllegalArgumentException: argument type mismatch
           at com.sun.facelets.el.TagValueExpression.setValue(TagValueExpression.java:101)
           at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:250)
           ... 61 more
      Caused by: java.lang.IllegalArgumentException: argument type mismatch
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)"

      xhtml code:
      ----------
      <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:a="http://richfaces.org/a4j"   
          xmlns:rich="http://richfaces.org/rich">
         
          <h:form>
         
              <a4j:outputPanel id="table">
         
              <table border="1" class="dr-table rich-table">
                  <thead class="dr-table-thead">
                      <tr class="dr-table-header rich-table-header">
                          <th class="dr-table-headercell rich-table-headercell"><h:outputText value="Product Code" /></th>
                          <th class="dr-table-headercell rich-table-headercell"><h:outputText value="Proposed Price" /></th>
                          <th class="dr-table-headercell rich-table-headercell"><h:outputText value="Sales Cost" /></th>
                          <th class="dr-table-headercell rich-table-headercell" style="width: 150px"><h:outputText value="Reason" /></th>
                          <th class="dr-table-headercell rich-table-headercell"><h:outputText value="Proposed Gross Margin" /></th>
                      </tr>
                  </thead>
                  <tbody>
                      <a4j:repeat value="#{salesReport.items}" var="item" binding="#{updateBean.repeater}">
                          <tr>
                              <td align="center" class="dr-subtable-cell rich-subtable-cell">
                                  <h:outputText value="#{item.productCode}" />
                              </td>
                              <td class="dr-subtable-cell rich-subtable-cell">
                                  <h:inputText binding="#{updateBean.priceRef}"
                                  immediate="false" value="#{item.proposedPrice}" size="7">
                                      <a4j:support immediate="true" action="#{updateBean.change}"
                                          event="onchange" reRender="reason,margin" />
                                  </h:inputText>
                              </td>
                              <td class="dr-subtable-cell rich-subtable-cell">
                                  <h:outputText value="#{item.salesCost}" />
                              </td>
                              <td class="dr-subtable-cell rich-subtable-cell">
                                  <h:selectOneMenu id="reason" required="true"
                                      value="#{item.reason}">
                                      <f:selectItems value="#{item.reasons}" />
                                  </h:selectOneMenu>
                              </td>
                              <td class="dr-subtable-cell rich-subtable-cell">
                                  <h:outputText id="margin"
                                      value="#{item.proposedGrossMargin}">
                                      <f:convertNumber pattern="$###0.000" />
                                  </h:outputText>
                              </td>
                          </tr>
                      </a4j:repeat>
                  </tbody>
              </table>
              </a4j:outputPanel>
              <rich:messages />
          </h:form>

      </ui:composition>


      UpdateBean.java
      ---------------
      package com.test;

      import javax.faces.component.html.HtmlInputText;
      import javax.faces.context.FacesContext;
      import org.ajax4jsf.component.UIRepeat;
      import org.jboss.seam.annotations.Name;

      import java.util.HashSet;
      import java.util.Set;

      @Name("updateBean")
      public class UpdateBean {

          HtmlInputText priceRef;
          private UIRepeat repeater;
          private Set<Integer> keys = null;
         
          /**
           * @return the keys
           */
          public Set getKeys() {
              return keys;
          }

          /**
           * @param keys the keys to set
           */
          public void setKeys(Set keys) {
              this.keys = keys;
          }

          public void setRepeater(UIRepeat repeater) {
              this.repeater = repeater;
          }

          public UIRepeat getRepeater() {
              return repeater;
          }

          public HtmlInputText getPriceRef() {
              return priceRef;
          }

          public void setPriceRef(HtmlInputText priceRef) {
              this.priceRef = priceRef;
          }
         
          public String change(){
             
              HashSet keys = new HashSet<Integer>();
              int rowKey = getRepeater().getRowIndex();
              keys.add(rowKey);
              setKeys(keys);
              priceRef.processValidators(FacesContext.getCurrentInstance());
              priceRef.processUpdates(FacesContext.getCurrentInstance());
              return null;
          }
      }