[jboss-user] [JBoss Seam] - @DataModel problem
lsabin
do-not-reply at jboss.com
Tue Nov 27 05:13:52 EST 2007
Hi.
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.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4107984#4107984
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4107984
More information about the jboss-user
mailing list