Foros del Web » Programación para mayores de 30 ;) » Java »

Target model Type is no a Collection or Array

Estas en el tema de Target model Type is no a Collection or Array en el foro de Java en Foros del Web. Hola Buenas, estoy haciendo mi aplicación en JSF y tengo dos páginas xhtml. Cuando en una de ellas presiono el submit, quiero que me lleve ...
  #1 (permalink)  
Antiguo 22/07/2013, 05:12
 
Fecha de Ingreso: julio-2013
Mensajes: 36
Antigüedad: 10 años, 9 meses
Puntos: 2
Target model Type is no a Collection or Array

Hola Buenas, estoy haciendo mi aplicación en JSF y tengo dos páginas xhtml.

Cuando en una de ellas presiono el submit, quiero que me lleve a la otra, pero me sale este error;

"Target model Type is no a Collection or Array"

Me podrías ayudar por favor? Muchas Gracias. Un saludo
  #2 (permalink)  
Antiguo 22/07/2013, 05:34
 
Fecha de Ingreso: marzo-2012
Ubicación: Argentina
Mensajes: 111
Antigüedad: 12 años, 1 mes
Puntos: 12
Respuesta: Target model Type is no a Collection or Array

podes postear el backing bean y la vista asociada ?

supuestamente es que no estas usando una collection o array donde deberias.

Saludos.
  #3 (permalink)  
Antiguo 22/07/2013, 05:41
 
Fecha de Ingreso: julio-2013
Mensajes: 36
Antigüedad: 10 años, 9 meses
Puntos: 2
Respuesta: Target model Type is no a Collection or Array

Hola de nuevo, pues aqui posteo, las dos páginas xhtml, los bean asociados y el faces config. Muchas Gracias, un saludo

----PRIMERA PAGINA XHTML----------

<h:body>
<f:verbatim>
<h2>Tabla de Skills</h2>
</f:verbatim>
<h:form id="formu_listas" style="height: 119px; " >
<h:panelGrid id="panel_listas" columns="1" style="height: 156px; ">
<h:selectManyMenu id="lista_skills"
value="#{skill_bean.skill_seleccionado}" style="width: 182px; height: 208px">
<f:selectItems id="contenido_skills" value="#{skill_bean.lista_skills}" />
</h:selectManyMenu>
<h:commandButton value="Comprobar Skills" action="tablacv"/>
</h:panelGrid>
</h:form>
</h:body>



-------BEAN DE ESTA PRIMERA PAGINA------

public class skill_bean {
// PROPIEDADES PARA RECIBIR LOS VALORES SELECCIONADOS
private String skill_seleccionado;
//COLECCIONES PARA MOSTRAR EN EL COMBO
private List<SelectItem> lista_skills;

public skill_bean(){
//INICIAMOS LA COLECCION PARA LA INFORMACION DEL COMBO DE SKILL
lista_skills =new ArrayList<SelectItem>();
//REALIZACION DE LA CONSULTA A LA BASE DE DATOS
IGestion_Skill gestion_Skill=Acceso_ApplicationContext.getBean
(IGestion_Skill.class);
List<Skills> consulta_skills=gestion_Skill.consultar_Todos();
//CARGO LA INFORMACION PARA SER MOSTRADA EN EL COMBO
SelectItem item_comboskills = new SelectItem();
item_comboskills.setLabel("Seleccione un skill");
for (Skills skills :consulta_skills){
item_comboskills=new SelectItem();
item_comboskills.setLabel(skills.getSkill());
item_comboskills.setValue(skills.getIdskill());
System.out.println("--- label ::: "+item_comboskills.getLabel());
lista_skills.add(item_comboskills);
}

}


--------SEGUNDA PAGINA XHTML---------
<h:body>
<h:outputText value="CURRICULUMS"/>
<h:form>
<h:dataTable border="3" value="#{cv_bean.lista_CV}" var="cv">
<h:column>
<f:facet name="header">idCV</f:facet>
<h:outputText value="${cv.value}"/>
</h:column>
<h:column>
<f:facet name="header">Texto</f:facet>
<h:outputText value="${cv.label}" styleClass="enfasis"/>
</h:column>
</h:dataTable>
</h:form>
</h:body>


-------BEAN DE LA SEGUNDA PAGINA------


public class cv_bean {
// PROPIEDADES PARA RECIBIR LOS VALORES SELECCIONADOS
private String cv_seleccionado;
//COLECCIONES PARA MOSTRAR EN LA TABLA
private List<SelectItem> lista_CV;

public cv_bean(){
//INICIAMOS LA COLECCION PARA LA INFORMACION DEL COMBO DE SKILL
lista_CV =new ArrayList<SelectItem>();
//REALIZACION DE LA CONSULTA A LA BASE DE DATOS
IGestion_CV gestion_cv= Acceso_ApplicationContext.getBean(IGestion_CV.clas s);
List<Tempcv> consulta_CV=gestion_cv.recibir_cv();
//CARGO LA INFORMACION PARA SER MOSTRADA EN LA TABLA
SelectItem item_tablacv = new SelectItem();
item_tablacv.setLabel("Mire CV");
for (Tempcv CV :consulta_CV){
item_tablacv=new SelectItem();
item_tablacv.setLabel(CV.getTexto());
item_tablacv.setValue(CV.getIdCv());
System.out.println("--- label ::: "+item_tablacv.getLabel());
lista_CV.add(item_tablacv);
}
}

------FACES CONGFIG---------

<managed-bean>
<managed-bean-name>skill_bean</managed-bean-name>
<managed-bean-class>com.proyecto.managedbean.skill_bean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>

<managed-bean>
<managed-bean-name>cv_bean</managed-bean-name>
<managed-bean-class>com.proyecto.managedbean.cv_bean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>

</managed-bean>

<navigation-rule>
<from-view-id>/xhtml/skill.xhtml</from-view-id>
<navigation-case>
<from-outcome>tablacv</from-outcome>
<to-view-id>/xhtml/tablacv.xhtml</to-view-id>
</navigation-case>



Muchas Gracias por todo.
Responder Citando
  #4 (permalink)  
Antiguo 22/07/2013, 06:04
 
Fecha de Ingreso: marzo-2012
Ubicación: Argentina
Mensajes: 111
Antigüedad: 12 años, 1 mes
Puntos: 12
Respuesta: Target model Type is no a Collection or Array

Tenes unos tags para colocar codigo y que se vea bien tabulado.

por otro lado aca tenes un ejemplo para seguir paso a paso.

Ejemplo list box

Aca otro

Por otro lado creo que en el value va la collection y vos pones el skill seleccionado

Saludos.
  #5 (permalink)  
Antiguo 23/07/2013, 01:03
 
Fecha de Ingreso: julio-2013
Mensajes: 36
Antigüedad: 10 años, 9 meses
Puntos: 2
Respuesta: Target model Type is no a Collection or Array

Hola, ya consegui que me pasase de una página XHTML a otra. Gracias por los consejos.
  #6 (permalink)  
Antiguo 23/07/2013, 01:37
Avatar de Xerelo  
Fecha de Ingreso: mayo-2009
Mensajes: 2.175
Antigüedad: 14 años, 11 meses
Puntos: 306
Respuesta: Target model Type is no a Collection or Array

¿Y cómo lo resolviste?

Piensa que tu solución puede ayudar a otros.
__________________
Cada vez que solucionas los problemas de alguien que no se esfuerza, piensa en que el día de mañana puede llegar a ser tu compañero de trabajo, o peor, tu jefe.
  #7 (permalink)  
Antiguo 23/07/2013, 01:45
 
Fecha de Ingreso: julio-2013
Mensajes: 36
Antigüedad: 10 años, 9 meses
Puntos: 2
Respuesta: Target model Type is no a Collection or Array

----PRIMERA PAGINA XHTML----------

<h:body>
<f:verbatim>
<h2>Tabla de Skills</h2>
</f:verbatim>
<h:form id="formu_listas" style="height: 119px; " >
<h:panelGrid id="panel_listas" columns="1" style="height: 156px; ">
<h:selectManyMenu id="lista_skills"
value="#{skill_bean.skill_seleccionado}" style="width: 182px; height: 208px">
<f:selectItems id="contenido_skills" value="#{skill_bean.lista_skills}" />
</h:selectManyMenu>
<h:commandButton value="Comprobar Skills" action="tablacv"/>
</h:panelGrid>
</h:form>
</h:body>

value="#{skill_bean.skill_seleccionado}"

Pues quite de la primera página XHTML esto y al darle al submit ya me redirecciono a la siguiente página.

Gracias
  #8 (permalink)  
Antiguo 23/07/2013, 07:20
 
Fecha de Ingreso: marzo-2012
Ubicación: Argentina
Mensajes: 111
Antigüedad: 12 años, 1 mes
Puntos: 12
Respuesta: Target model Type is no a Collection or Array

En value va un atributo de tipo lista (Collection) o un array

Por eso la exception que te da jsf es muy clara.

La solucion a un problema no es quitar cosas sino buscar que es lo que pasa por, algo esta el value.

Etiquetas: collection, html, model, target, type
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:48.