lundi 11 février 2008

Seam + ExtJS, Java glue code

In order to use my ExtJS extensions, we need some Java glue code like the generic method parameters and return values.

So, let's begin with the generic method parameters :

- for a simple query method :

package xxx.yyy.zzz;
import org.jboss.seam.annotations.Name;

@Name("queryParam")
public class QueryParam
{
private String queryString;

public QueryParam()
{
super();
}

public String getQueryString()
{
return queryString;
}

public void setQueryString(String queryString)
{
this.queryString = queryString;
}

}

- for a simple paging query method :


package xxx.yyy.zzz;

import org.jboss.seam.annotations.Name;

@Name("pagingQueryParam")
public class PagingQueryParam extends QueryParam
{
private int start;
private int limit;


public int getStart()
{
return start;
}

public void setStart(int start)
{
this.start = start;
}

public int getLimit()
{
return limit;
}

public void setLimit(int limit)
{
this.limit = limit;
}
}




Now for the return values :
- for a simple query method :
package xxx.yyy.zzz;

import java.util.List;

import org.jboss.seam.annotations.Name;

/**
*
* @author cvigouroux
*
* @param <T>
*/

@Name("resultList")
public class ResultList<T>
{
private List<T> list;
private int totalRecords;

public ResultList(List<T> list)
{
this.list = list;
this.totalRecords = list.size();
}

public int getTotalRecords()
{
return totalRecords;
}

public void setTotalRecords(int totalRecords)
{
this.totalRecords = totalRecords;
}

public List<T> getList()
{
return list;
}

public void setList(List<T> list)
{
this.list = list;
}
}

- for a simple paging query method :

package xxx.yyy.zzz;

import java.util.List;

import org.jboss.seam.annotations.Name;

/**
* @author cvigouroux
*
* @param <T>
*/

@Name("pagingResultList")
public class PagingResultList<T> extends ResultList<T>
{
// private int totalRecords;
// private List<T> list;

public PagingResultList(int totalRecords, List<T> list)
{
super(list);
this.setTotalRecords(totalRecords);
}
}

1 commentaire:

Unknown a dit…

Hi,

Thanks for the great code !

I've found something that appears to be a seam bug.

I'm using seam 1.1.5-GA. The bug is that when using the QueryParam and PagingQueryParam as seam bean (with the @Name annotation), their property values would never be setted.

If someone has the same problem, I've bypassed it using them as standard java beans that is :
- explicitely import the classes in the webpage :
<script type="text/javascript" src="seam/remoting/interface.js?<fully qualified package>.QueryParam" ></script>
- use the Seam.Remoting.createType( '<fully qualified package>.QueryParam' ) in SeamRemotingProxy instead of Seam.Component.newInstance( 'beanName' )

Regards
Nel