@DataModel problem
lsabin Nov 27, 2007 5:13 AMHi.
I have the following component which retrieves a list of courses done by a employee. This works fine but when I included some code to get a list of courses that match a certain input the list of courses is not retrieved (actually the method listCoursesEmployee() is not invoked at all).
@Name("courseservice")
@Scope(ScopeType.CONVERSATION)
@Restrict("#{identity.loggedIn}")
public class CourseAction {
@In
private EntityManager entityManager;
@In(value="empleadoSel")
private Tecnico selectedEmployee;
@DataModel
private List<CursoCurriculum> listCoursesEmployee = new ArrayList<CursoCurriculum>();
public CourseAction(){}
@Factory(value="listCoursesEmployee",autoCreate=true)
public void listCoursesEmployee(){
if (selectedEmployee != null)
{
Curriculum cvEmpleado = null;
cvEmpleado = selectedEmployee.getCurriculum();
if (cvEmpleado != null)
listCoursesEmployee = cvEmpleado.getCursos();
}
}
But if I move the code that gets the list of courses to another component everything works. This is the code in the new component:
@Name("cursoservice")
@Scope(ScopeType.CONVERSATION)
@Restrict("#{identity.loggedIn}")
public class CursosAction {
@In
private EntityManager entityManager;
private String nombreCurso;
@Out(scope=ScopeType.EVENT)
List<Curso> listaCursosParcial = new ArrayList<Curso>();
public CursosAction(){}
public List<Curso> getListaCursosParcial(){
return listaCursosParcial;
}
public void setNombreCurso(String nombreCurso) {
this.nombreCurso = nombreCurso;
}
public void obtieneCursosParcial(){
String patron = "";
patron = (nombreCurso == null) ? "%" : ('%' + nombreCurso.toLowerCase().replace('*', '%') + '%');
listaCursosParcial = entityManager.createQuery(
"from Curso where LOWER(nombre) like :patron order by nombre")
.setParameter("patron",patron)
.getResultList();
}
I want to have all the code in the first component. If this is posible what am I doing wrong?
Thanks.