0
I am trying to use the DWR framework to populate a select from the output of another select in my JSP.
Only you have no action after selecting the first select.
JSP 1º SELECT:
<select
onchange="verificaHierarquia(this)" class="form-control"
id="hierarquia" name="hierarquia.id">
<option value="" data-valor=0 selected>SELECIONE...</option>
<c:forEach var="hierarquia" items="${hierarquias }">
<option value="${hierarquia.id }"
data-valor2="${hierarquia.nivel }">${hierarquia.descricao }</option>
</c:forEach>
</select>
JSP 2º SELECT:
It’s a simple select
SERVICE:
public List<Funcionario> obterFuncionarios(Hierarquia hierarquia){
List<Funcionario> listaFuncionarios = new ArrayList<Funcionario>();
listaFuncionarios = dao.obterFuncionarios(hierarquia);
return listaFuncionarios;
}
DAO:
@SuppressWarnings("unchecked")
public List<Funcionario> obterFuncionarios(Hierarquia hierarquia) {
Query query = manager.createQuery("select f FROM Funcionario f WHERE f.hierarquia = :hierarquia");
query.setParameter("hierarquia", hierarquia);
return query.getResultList();
}
WEB.XML:
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
DWR.XML (Located in LIB folder):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC
"-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN"
"http://www.getahead.ltd.uk/dwr/dwr20.dtd">
<dwr>
<allow>
<create creator="new" javascript="FuncionarioService">
<param name="class" value="br.cq.service.FuncionarioService"/>
</create>
<convert converter="bean" match="br.cq.entity.Funcionario"/>
<convert converter="bean" match="br.cq.dao.FuncionarioDAO"/>
<convert converter="bean" match="br.cq.entity.Hierarquia"/>
</allow>
</dwr>