Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

There is a simple form to create autocomplete using Seam using EntityQuery.

Let's use the tag rich:suggestionbox. If you don't know this, visit RichFaces demo page . There is a good example about this tag.

<s:decorate id="userDecoration" 		template="layout/edit.xhtml">			<ui:define name="label">Name</ui:define>		<h:inputText id="user" value="#userList.instance.userName}">				</h:inputText>
<rich:suggestionbox id="suggestionBox" for="userName"		fetchValue="#{userList.instance.userName}"
	var="user" minChars="2">
	<h:column>						<h:outputText value="#user.userName}" />					</h:column>					</rich:suggestionbox>

Now, is necessary create the method autocomplete...

public class UserList extends EntityQuery {


public List<User> autoComplete(Object o) {
		String sql =  this.getEjbql() + " where lower(user.userName) like concat('%',lower('"+o.toString()+"'),'%')";
		return this.getEntityManager().createQuery(sql).getResultList();