struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicolás Pace" <nicop...@gmail.com>
Subject Re: Elements in collection = null in Struts 2 view
Date Fri, 08 Jun 2007 18:57:34 GMT
I will answer myself!!!
The problem was that I was using a wrong ognl expression to access the
iterator element.
The correct expression would be "#tel", not "tel".

Nicolás Pace

On 6/7/07, Nicolás Pace <nicopace@gmail.com> wrote:
> Hi everyone!
>
> Description: The problem is that when i debug this webapp, inside the
> servlet i can see the elements inside de modelo.Telefonos collection, but
> the jsp can't.
> In the jsp, the collection only have null's, but the correct number of them.
> (if the collection has 3 elements, there are 3 nulls inside it) :S
>  The database also contains those elements.
>  Thanks in advance
>
>  Nicolás Pace
>
>
>  Struts version: 2.0.6
> Hibernate version: 3.1.3 or 3.2
>  Mapping documents:
>  ---------Modelo.hbm.xml---------------
>  <?xml version="1.0"?>
>  <!DOCTYPE hibernate-mapping PUBLIC
>  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
>  <hibernate-mapping package="modelos">
>  <class name="Modelo">
>  <id name="id">
>  <generator class="native"></generator>
>  </id>
>
>  <property name="apellido"></property>
>  <property name="nombre"></property>
>  <property name="fechaNacimiento"></property>
>  <property name="foto"></property>
>  <property name="turno"></property>
>
>  <many-to-one name="escuela" cascade="all" ></many-to-one>
>
>  <set name="domicilios" cascade="all" table="modelo_domicilio">
>  <key column="model_id"/>
>  <many-to-many column="dom_id" class="modelos.Domicilio" />
>  </set>
>
>  <set name="telefonos" cascade="all" table="modelo_telefono" fetch="join"
> lazy="false">
>  <key column="model_id"/>
>  <many-to-many column="telefono_id" class="Telefono"/>
>  </set>
>
>  <set name="caracteristicas" cascade="all" table="modelo_caracteristica">
>  <key column="model_id"/>
>  <many-to-many column="carac_id" class="modelos.CaracteristicaFisica"/>
>  </set>
>
>  <set name="habilidades" cascade="all" table="modelo_habilidad">
>  <key column="model_id"/>
>  <many-to-many column="habilidad_id" class="modelos.Habilidad"/>
>  </set>
>
>  <set name="observaciones" cascade="all" table="modelo_observacion">
>  <key column="model_id"/>
>  <many-to-many column="observacion_id" class="modelos.Observacion"/>
>  </set>
>
>  <set name="restricciones" cascade="all" table="modelo_restriccion">
>  <key column="model_id"/>
>  <many-to-many column="restricciones_id" class="modelos.Restriccion"/>
>  </set>
>
>  <set name="horariosDisponibles" cascade="all"
> table="modelo_horarioDisponible">
>  <key column="model_id"/>
>  <many-to-many column="franja_id" class="modelos.FranjaHoraria"/>
>  </set>
>
>  <set name="grupoFamiliar" cascade="all" table="modelo_grupoFamiliar">
>  <key column="grupoFamiliar_id"/>
>  <many-to-many column="model_id" class="modelos.Modelo"/>
>  </set>
>
>  </class>
>  </hibernate-mapping>
>  -------------------
>  -----------Telefono.hbm.xml----------------
>  <?xml version="1.0"?>
>  <!DOCTYPE hibernate-mapping PUBLIC
>  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
>  <hibernate-mapping package="modelos">
>  <class name="Telefono">
>  <id name="id"><generator class="native"></generator></id>
>  <property name="numero"></property>
>  </class>
>  </hibernate-mapping>
>  ------------------------------------
>
>  Code between sessionFactory.openSession() and session.close(): Using
> OpenSessionInView pattern with ServletFilter suggested here
>
>  ModeloAction.java
>
>  public class ModeloAction extends ActionSupport {
>
>  private Modelo modelo;
>
>  ...
>  execute() {
>  modelo = (Modelo) s.get(Modelo.class, id);
>
>  modelo.getTelefonos().size();
>  modelo.getDomicilios().size();
>  modelo.getCaracteristicas().size();
>  modelo.getGrupoFamiliar().size();
>  modelo.getHabilidades().size();
>  modelo.getHorariosDisponibles().size();
>  modelo.getObservaciones().size();
>  modelo.getRestricciones().size();
>  }
>
>  ....
>  }
>
>  Modelo.jsp:
>  ...
>  <s:iterator value="modelo.telefonos" id="tel">
>  <s:property value="tel==null"/>
>  </s:iterator>
>  ...
>
>
>  Full stack trace of any exception that occurs:
>
>  Name and version of the database you are using:mysql
>
>  The generated SQL (show_sql=true):
> Hibernate: select modelo0_.id as id16_1_, modelo0_.apellido as
> apellido16_1_, modelo0_.nombre as nombre16_1_, modelo0_.fechaNacimiento as
> fechaNac4_16_1_, modelo0_.foto as foto16_1_, modelo0_.turno as turno16_1_,
> modelo0_.escuela as escuela16_1_, telefonos1_.model_id as model1_3_,
> telefono2_.id as telefono2_3_, telefono2_.id as id9_0_, telefono2_.numero as
> numero9_0_ from Modelo modelo0_ left outer join modelo_telefono telefonos1_
> on modelo0_.id=telefonos1_.model_id left outer join
> Telefono telefono2_ on
> telefonos1_.telefono_id=telefono2_.id where modelo0_.id=?
> Hibernate: select domicilios0_.model_id as model1_1_, domicilios0_.dom_id as
> dom2_1_, domicilio1_.dom_id as dom1_3_0_, domicilio1_.calle as calle3_0_,
> domicilio1_.numero as numero3_0_, domicilio1_.departamento as
> departam4_3_0_, domicilio1_.ciudad as ciudad3_0_ from modelo_domicilio
> domicilios0_ left outer join Domicilio domicilio1_ on
> domicilios0_.dom_id=domicilio1_.dom_id where
> domicilios0_.model_id=?
> Hibernate: select caracteris0_.model_id as model1_1_, caracteris0_.carac_id
> as carac2_1_, caracteris1_.carac_id as carac1_4_0_, caracteris1_.nombre as
> nombre4_0_ from modelo_caracteristica caracteris0_ left outer join
> CaracteristicaFisica caracteris1_ on
> caracteris0_.carac_id=caracteris1_.carac_id where
> caracteris0_.model_id=?
> Hibernate: select grupofamil0_.grupoFamiliar_id as grupoFam1_1_,
> grupofamil0_.model_id as model2_1_, modelo1_.id as id16_0_,
> modelo1_.apellido as apellido16_0_, modelo1_.nombre as nombre16_0_,
> modelo1_.fechaNacimiento as fechaNac4_16_0_, modelo1_.foto as foto16_0_,
> modelo1_.turno as turno16_0_, modelo1_.escuela as escuela16_0_ from
> modelo_grupoFamiliar grupofamil0_ left outer join Modelo modelo1_ on
> grupofamil0_.model_id=modelo1_.id where
> grupofamil0_.grupoFamiliar_id=?
> Hibernate: select habilidade0_.model_id as model1_1_,
> habilidade0_.habilidad_id as habilidad2_1_, habilidad1_.id as id7_0_,
> habilidad1_.nombre as nombre7_0_ from modelo_habilidad habilidade0_ left
> outer join Habilidad habilidad1_ on
> habilidade0_.habilidad_id=habilidad1_.id where
> habilidade0_.model_id=?
> Hibernate: select horariosdi0_.model_id as model1_1_, horariosdi0_.franja_id
> as franja2_1_, franjahora1_.id as id6_0_, franjahora1_.dia as dia6_0_,
> franjahora1_.horaInicio as horaInicio6_0_, franjahora1_.horaFin as
> horaFin6_0_ from modelo_horarioDisponible horariosdi0_ left outer join
> FranjaHoraria franjahora1_ on
> horariosdi0_.franja_id=franjahora1_.id where
> horariosdi0_.model_id=?
> Hibernate: select observacio0_.model_id as model1_1_,
> observacio0_.observacion_id as observac2_1_, observacio1_.id as id8_0_,
> observacio1_.nombre as nombre8_0_ from modelo_observacion observacio0_ left
> outer join Observacion observacio1_ on
> observacio0_.observacion_id=observacio1_.id where
> observacio0_.model_id=?
> Hibernate: select restriccio0_.model_id as model1_1_,
> restriccio0_.restricciones_id as restricc2_1_, restriccio1_.id as id5_0_,
> restriccio1_.nombre as nombre5_0_ from modelo_restriccion restriccio0_ left
> outer join Restriccion restriccio1_ on
> restriccio0_.restricciones_id=restriccio1_.id where
> restriccio0_.model_id=?
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message