You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by 滕训华 <te...@magic-sw.com.cn> on 2008/04/24 11:56:11 UTC

Strange return for grid component

I have a grid component in the page of T5 and its sources is got from
db.There is also another search field to filter the records.

 

I defined 2 method in my service class:

 

         List<CustomerInfo> getAllCustomers()

         List<CustomerInfo> search(String key)

 

when init this page will return all customers it run normally,but when I
input some to press the search button,it give me a error page:

 

An unexpected application exception has occurred.

Index: 4, Size: 4

 

I do not know why and how to slove this.please help .thanks.


Re: 答复: Strange return for grid component

Posted by Marcelo Lotif <ml...@gmail.com>.
This looks like an ArrayOutOfBoundsException, but without the stack trace we
cannot see where is the error...

try to set the production mode to "false" adding the line below to the
"contributeApplicationDefaults()" method in your AppModule, and then paste
the error page here.

configuration.add("tapestry.production-mode", "false");

2008/4/24 滕训华 <te...@magic-sw.com.cn>:

> Yes,I think you are right,follow is the relate source files
>
> =================== CustomerList.tml========================
>
> <t:pagelayout t:pageTitle="${message:label_pageTitle}"
> xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
> <head>
> </head>
> <body>
> <t:form t:id="customerListForm" >
>        <table>
>                <tr>
>                        <td align="left">
>                                ${message:label_searchTitle}:<input
> type="text" t:type="TextField" t:value="searchKey" />
>                                <input type="submit" t:type="Submit"
> t:id="button_search"  value="${message:button_Search}" />
>                        </td>
>                </tr>
>                <tr>
>                        <td>
>                                <t:grid t:source="allCustomers"
> rowsPerPage="5" pagerPosition="bottom"
>
> exclude="CustomerCode,customerDestCode,controlSaleDept,controlSale"
>
> reorder="customerName,customerTel,customerLocation,customerPost"/>
>
>                        </td>
>                </tr>
>        </table>
> </t:form>
> </body>
> </t:pagelayout>
>
>
>
> ================== CustomerList.java=======================
>
> package com.sacf.viewlayer.web.pages.securePage;
>
> import com.sacf.servicelayer.iface.*;
> import org.apache.tapestry.ioc.annotations.Inject;
> import org.apache.tapestry.annotations.Service;
> import com.sacf.domain.model.CustomerInfo;
>
> import java.util.List;
>
> public class CustomerList {
>
>
>        private String searchKey;
>
>        public void setSearchKey(String searchKey){
>                this.searchKey=searchKey;
>        }
>        public String getSearchKey(){
>                return searchKey;
>        }
>
>
>        @Inject
>        @Service("customerManager")
>        private CustomerManager customerManager;
>
>        public List<CustomerInfo> getAllCustomers(){
>                System.out.println("you input the key is:"+searchKey);
>                if(searchKey==null||searchKey.equals("") ){
>                        return customerManager.getCustomers();
>                }
>                else{
>                        return customerManager.search(searchKey);
>                }
>        }
>
>
> }
>
>
> ===============CustomerManagerImpl.java==========
>
>
> package com.sacf.servicelayer.impl;
>
> import java.util.List;
>
> import com.sacf.domain.model.CustomerInfo;
> import com.sacf.servicelayer.iface.CustomerManager;
>
> import com.sacf.domain.dao.CustomerDao;
>
> public class CustomerManagerImpl implements CustomerManager {
>
>        private CustomerDao customerDao;
>
>        public void setCustomerDao(CustomerDao customerDao){
>                this.customerDao=customerDao;
>        }
>
>        public void deleteCustomer(CustomerInfo custObj) {
>                customerDao.deleteCustomer(custObj);
>
>        }
>
>        public List<CustomerInfo> getCustomers() {
>                return customerDao.getCustomerList();
>        }
>
>        public void saveCustomer(CustomerInfo custObj) {
>                customerDao.saveorupdateCustomer(custObj);
>        }
>
>        public List<CustomerInfo> search(String searchKey) {
>                return customerDao.search(searchKey);
>        }
>
> }
>
>
>
> =================CustomerDaoImpl.java=====================
>
>
> package com.sacf.domain.dao.hibernate;
>
> import java.util.List;
>
> import com.sacf.domain.dao.CustomerDao;
> import com.sacf.domain.model.CustomerInfo;
> import org.hibernate.Session;
> import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
> import org.hibernate.Query;
> import org.springframework.dao.DataAccessException;
>
> public class CustomerDaoImpl extends HibernateDaoSupport implements
> CustomerDao {
>
>        public void deleteCustomer(CustomerInfo customerObj) {
>                try{
>                        Session
> session=getHibernateTemplate().getSessionFactory().openSession();
>                        session.delete(customerObj);
>                }
>                catch(DataAccessException e){
>                        e.printStackTrace();
>                }
>
>        }
>
>        public List<CustomerInfo> getCustomerList() {
>                try{
>                        Session
> session=getHibernateTemplate().getSessionFactory().openSession();
>                        Query query=session.createQuery("from
> CustomerInfo");
>                        return query.list();
>
>
>
>                }
>                catch(DataAccessException e){
>                        return null;
>                }
>        }
>
>        public void saveorupdateCustomer(CustomerInfo cust) {
>                getHibernateTemplate().save(cust);
>
>        }
>
>        public List<CustomerInfo> search(String searchKey) {
>                try{
>                        Session
> session=getHibernateTemplate().getSessionFactory().openSession();
>                        Query query=session.createQuery("from CustomerInfo
> where customerName like :p_customerName");
>                        query.setParameter("p_customerName",
> "%"+searchKey+"%");
>                        return query.list();
>
>
>
>                }
>                catch(DataAccessException e){
>                        return null;
>                }
>        }
>
>
>
> }
>
>
>
>
> When I press the search button,the search have no any error information,and
> the return page only have the follow information:
>
> An unexpected application exception has occurred.
>  Index: 4, Size: 4
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Atenciosamente,
Marcelo Lotif

答复: Strange return for grid component

Posted by 滕训华 <te...@magic-sw.com.cn>.
Yes,I think you are right,follow is the relate source files

=================== CustomerList.tml========================

<t:pagelayout t:pageTitle="${message:label_pageTitle}"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
<head>
</head>
<body>
<t:form t:id="customerListForm" > 
	<table>
		<tr>
			<td align="left">
				${message:label_searchTitle}:<input
type="text" t:type="TextField" t:value="searchKey" />
				<input type="submit" t:type="Submit"
t:id="button_search"  value="${message:button_Search}" />
			</td>
		</tr>
		<tr>
			<td>
				<t:grid t:source="allCustomers"
rowsPerPage="5" pagerPosition="bottom"	
	
exclude="CustomerCode,customerDestCode,controlSaleDept,controlSale"
	
reorder="customerName,customerTel,customerLocation,customerPost"/>
	
			</td>
		</tr>
	</table>
</t:form>
</body>
</t:pagelayout>



================== CustomerList.java=======================

package com.sacf.viewlayer.web.pages.securePage;

import com.sacf.servicelayer.iface.*;
import org.apache.tapestry.ioc.annotations.Inject;
import org.apache.tapestry.annotations.Service;
import com.sacf.domain.model.CustomerInfo;

import java.util.List;

public class CustomerList {
	
	
	private String searchKey;
	
	public void setSearchKey(String searchKey){
		this.searchKey=searchKey;
	}
	public String getSearchKey(){
		return searchKey;
	}
	
	
	@Inject
	@Service("customerManager")
	private CustomerManager customerManager;
	
	public List<CustomerInfo> getAllCustomers(){
		System.out.println("you input the key is:"+searchKey);
		if(searchKey==null||searchKey.equals("") ){
			return customerManager.getCustomers();
		}
		else{
			return customerManager.search(searchKey);
		}
	}
	

}


===============CustomerManagerImpl.java==========


package com.sacf.servicelayer.impl;

import java.util.List;

import com.sacf.domain.model.CustomerInfo;
import com.sacf.servicelayer.iface.CustomerManager;

import com.sacf.domain.dao.CustomerDao;

public class CustomerManagerImpl implements CustomerManager {
	
	private CustomerDao customerDao;
	
	public void setCustomerDao(CustomerDao customerDao){
		this.customerDao=customerDao;
	}

	public void deleteCustomer(CustomerInfo custObj) {
		customerDao.deleteCustomer(custObj);

	}

	public List<CustomerInfo> getCustomers() {		
		return customerDao.getCustomerList();
	}

	public void saveCustomer(CustomerInfo custObj) {
		customerDao.saveorupdateCustomer(custObj);
	}

	public List<CustomerInfo> search(String searchKey) {		
		return customerDao.search(searchKey);
	}

}



=================CustomerDaoImpl.java=====================


package com.sacf.domain.dao.hibernate;

import java.util.List;

import com.sacf.domain.dao.CustomerDao;
import com.sacf.domain.model.CustomerInfo;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.hibernate.Query;
import org.springframework.dao.DataAccessException;

public class CustomerDaoImpl extends HibernateDaoSupport implements
CustomerDao {

	public void deleteCustomer(CustomerInfo customerObj) {
		try{
			Session
session=getHibernateTemplate().getSessionFactory().openSession();
			session.delete(customerObj);
		}
		catch(DataAccessException e){
			e.printStackTrace();
		}

	}

	public List<CustomerInfo> getCustomerList() {
		try{
			Session
session=getHibernateTemplate().getSessionFactory().openSession();
			Query query=session.createQuery("from
CustomerInfo");
			return query.list();
			
		
			
		}
		catch(DataAccessException e){
			return null;
		}
	}

	public void saveorupdateCustomer(CustomerInfo cust) {
		getHibernateTemplate().save(cust);

	}

	public List<CustomerInfo> search(String searchKey) {
		try{
			Session
session=getHibernateTemplate().getSessionFactory().openSession();
			Query query=session.createQuery("from CustomerInfo
where customerName like :p_customerName");
			query.setParameter("p_customerName",
"%"+searchKey+"%");
			return query.list();
			
		
			
		}
		catch(DataAccessException e){
			return null;
		}
	}



}




When I press the search button,the search have no any error information,and
the return page only have the follow information: 

An unexpected application exception has occurred.
 Index: 4, Size: 4




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Strange return for grid component

Posted by Dmitry Shyshkin <sh...@devoler.com>.
Stacktrace and some source and *.tml code will be helpful. Methods
definition is not enough to see the problem

滕训华 write:
> I have a grid component in the page of T5 and its sources is got from
> db.There is also another search field to filter the records.
>
>  
>
> I defined 2 method in my service class:
>
>  
>
>          List<CustomerInfo> getAllCustomers()
>
>          List<CustomerInfo> search(String key)
>
>  
>
> when init this page will return all customers it run normally,but when I
> input some to press the search button,it give me a error page:
>
>  
>
> An unexpected application exception has occurred.
>
> Index: 4, Size: 4
>
>  
>
> I do not know why and how to slove this.please help .thanks.
>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org