0 Replies Latest reply on Aug 12, 2008 5:43 PM by Syed Muhammad Ali Naqvi

    Illegal Argument Exception

    Syed Muhammad Ali Naqvi Newbie

      Hello:-
         
            I am having IllegalArgumentException. The binding which I am doing of datascroller with UI fails.


      SFSB is


      package com.pcounts.server.action.session;
      
      import java.util.Iterator;
      import java.util.List;
      import java.util.Set;
      import java.util.Vector;
      
      import javax.ejb.Remove;
      import javax.ejb.Stateful;
      
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.Begin;
      import org.jboss.seam.annotations.Destroy;
      import org.jboss.seam.annotations.Factory;
      import org.jboss.seam.annotations.FlushModeType;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.annotations.datamodel.DataModel;
      import org.jboss.seam.annotations.datamodel.DataModelSelection;
      import org.richfaces.component.UIDatascroller;
      
      import com.pcounts.server.action.auth.PCUserInfo;
      
      import com.pcounts.server.hibernate.mapping.Contacts;
      import com.pcounts.server.hibernate.mapping.Groups;
      import com.pcounts.server.hibernate.service.ContactService;
      import com.pcounts.server.hibernate.service.GroupService;
      import com.pcounts.server.hibernate.service.UserService;
      
      @SuppressWarnings("unused")
      @Stateful
      @Name("dashboardContact")
      @Scope(ScopeType.SESSION)
      public class DashboardContactBean implements DashboardContact {
           
           @In(create = true)      ContactService contactService;
           @In(create = true)      GroupService groupService;
           @In(create = true)      PCUserInfo pcuserInfo;
           @In(create = true)      UserService userService;
           
           private UIDatascroller contactsDatascroller;
           
           
           private boolean ascendingOrder;
           private String orderField;
           private boolean editable;
           private Long selectedContactNumber;
           
           @DataModel
           private List<Contacts> lstContacts;
           
           @DataModelSelection("lstContacts")
           Contacts contacts;
           
           @SuppressWarnings("unchecked")
           @Factory(value = "lstContacts")
           public void listContacts(){
                
                List<Contacts> listSubSetRecords;
                List<Groups> lstGroups;
                Set setSPsOfGroups;
                int pageFirstIndex;
                Long count;
                
                lstGroups = groupService.getGroupsForSP(pcuserInfo.getUserNumber());
                
      //          lstGroups = groupService.getGroupsForSP(new Long(12));
      
                setSPsOfGroups = userService.getSPsFromSalesGroups(lstGroups);
      
                count = contactService.getContactsRowCount(userService.getCSVUserNumber(setSPsOfGroups));
      
                Vector<Contacts> vector = new Vector();
      
                vector.setSize(count.intValue());
                
                System.out.println("this.getContactsDatascroller: ----------------- " + this.getContactsDatascroller());
                System.out.println("this.getContactsDatascroller().getPage(): ----------------- " + this.getContactsDatascroller().getPage());
                
                pageFirstIndex = (this.getContactsDatascroller().getPage() * this.getContactsDatascroller().
                          getDataTable().getRows()) - this.getContactsDatascroller().getDataTable().getRows();
      
      
                listSubSetRecords = contactService.getContacts(userService
                          .getCSVUserNumber(setSPsOfGroups), this.getOrderField(),this.isAscendingOrder(),pageFirstIndex);
      
                for (int index = 0; index < listSubSetRecords.size(); index++) {
                     vector.set(pageFirstIndex + index, listSubSetRecords.get(index));
                }
      
      //          for (int i = 0; i < vector.size(); i++) {
      //          
      //               System.out.println(vector.get(i).getFirstName());
      //          }
      
                lstContacts = vector;
           }
      
           public void sortAction(String field) {
                List<Contacts> nullList;
                this.ascendingOrder = !this.ascendingOrder;
                this.orderField = field;
                nullList = this.getLstContacts();
                this.getLstContacts().clear();
                nullList = null;
                this.setLstContacts(nullList);
           }
           
           public String editAction(){
      
                System.out.println("Selected contact contact Number : " +  contacts.getContactNumber());
                
                return null;
           }
           
           public void nullList(){
                this.lstContacts = null;
           }
           
           @Remove
           @Destroy
           public void destroy(){
                
           }
      
           public UIDatascroller getContactsDatascroller() {
                return contactsDatascroller;
           }
      
           public void setContactsDatascroller(UIDatascroller contactsDatascroller) {
                this.contactsDatascroller = contactsDatascroller;
           }
      
           public boolean isAscendingOrder() {
                return ascendingOrder;
           }
      
           public void setAscendingOrder(boolean ascendingOrder) {
                this.ascendingOrder = ascendingOrder;
           }
      
           public String getOrderField() {
                return orderField;
           }
      
           public void setOrderField(String orderField) {
                this.orderField = orderField;
           }
      
           public List<Contacts> getLstContacts() {
                return lstContacts;
           }
      
           public void setLstContacts(List<Contacts> lstContacts) {
                this.lstContacts = lstContacts;
           }
      
           public Long getSelectedContactNumber() {
                return selectedContactNumber;
           }
      
           public void setSelectedContactNumber(Long selectedContactNumber) {
                this.selectedContactNumber = selectedContactNumber;
           }
      
      }
      



      and UI Code is


      <!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:s="http://jboss.com/products/seam/taglib"
           xmlns:ui="http://java.sun.com/jsf/facelets"
           xmlns:f="http://java.sun.com/jsf/core"
           xmlns:h="http://java.sun.com/jsf/html"
           xmlns:rich="http://richfaces.org/rich"
           xmlns:a="http://richfaces.org/a4j">
      
           <h:form>
      
                <table width="100%" border="0">
                     <tr>
                          <td colspan="3" align="center"><a:commandLink value="Accounts"
                               action="#{salesPersonAccount.gotoAccounts}"></a:commandLink></td>
                     </tr>
                     <tr>
                          <td>
                          <table width="100%">
                               <tr>
                                    <td align="justify"><rich:dataTable id="sp-dash-contacts"
                                         value="#{lstContacts}" var="contacts" rows="15">
      
                                         <rich:column>
                                              <f:facet name="header">
                                                   <h:outputText value="Edit" />
                                              </f:facet>
                                              <s:link action="#{dashboardContact.editAction}">
                                         Edit
                                    </s:link>
                                         </rich:column>
                                         <rich:column>
      
                                              <f:facet name="header">
                                                   <a:commandLink
                                                        action="#{dashboardContact.sortAction('customers.legalName')}" 
                                                       reRender="sp-dash-contacts,con-dashscroller"
                                                        value="Legal Name">
                                                   </a:commandLink>
                                              </f:facet>
                                              
                                                   <h:outputText value="#{contacts.customers.legalName}">
                                                   </h:outputText>
                                                   
                                              
                                         </rich:column>
      
                                         <rich:column>
                                              <f:facet name="header">
                                                   <a:commandLink
                                                        action="#{dashboardContact.sortAction('users.firstName')}"
                                                        reRender="sp-dash-contacts,con-dashscroller"
                                                        value="Main Contact">
                                                   </a:commandLink>
                                              </f:facet>
      
                                              <h:outputText
                                                   value="#{contacts.users.firstName} #{contacts.users.lastName}" />
                                         </rich:column>
      
                                         <rich:column>
                                              <f:facet name="header">
                                                   <a:commandLink
                                                        action="#{dashboardContact.sortAction('phone1')}"
                                                        reRender="sp-dash-contacts,con-dashscroller"
                                                        value="Phone Number">
                                                   </a:commandLink>
                                              </f:facet>
      
                                              <h:outputText value="#{contacts.phone1}" />
                                         </rich:column>
      
                                         <rich:column>
                                              <f:facet name="header">
                                                   <a:commandLink action="#{dashboardContact.sortAction('city')}"
                                                        reRender="sp-dash-contacts,con-dashscroller" value="City">
                                                   </a:commandLink>
                                              </f:facet>
      
                                              <h:outputText value="#{contacts.city}" />
                                         </rich:column>
      
                                    </rich:dataTable></td>
                               </tr>
                               <tr>
                                    <td align="justify"><rich:datascroller id="con-dashscroller"
                                         for="sp-dash-contacts" maxPages="15" binding="#{dashboardContact.contactsDatascroller}" /></td>
                               </tr>
      
                          </table>
      
      
      
      
      
                          </td>
                          <td width="5%"> </td>
                          
                     </tr>
                </table>
      
           </h:form>
      </ui:composition>


      There is no problem with the tags. if i remove the binding then I get null when I try to print out datascroller object on my console.


      So please solve my poblem ASAP.


      Bye
      Muhammad Ali