0

I need that adminimnmuebles.jsp shows a list of "Pisos" and his respective values. All it show well except and the values from object "Propietario", that it are inside from Pisos. I try to show but it doesn't work.

Action MostrarInmuebles.java:

private ArrayList<Piso> pisos = new ArrayList<Piso>();

private PisoDAO pisodao = new PisoImpl();


public String Mostrar() {

    System.out.println("Entro en mostrar pisos");
    pisos = pisodao.MostrarPisos(); 
 if (pisos.isEmpty()) {
     return NONE;
 }
 else {
 return SUCCESS;
 }
}

public ArrayList<Piso> getPisos() {
    return pisos;

}

AdminInmuebles.jsp

<s:iterator value="pisos">

                    <fieldset>
                    <legend><s:property value="titulo"/></legend>
                    <img style="float: left;" alt="<s:property value='titulo' />" src="<s:property value='imagen'/>" width="200" height="200">

                    Dormitorios: <s:property value="dormitorios"/> 
                    <p>

                    Baños: <s:property value="banyos"/> 
                    <p>
                    Precio: <s:property value="precio"/>&#8364;
                    <p>
                    Provincia:  <s:property value="provincia"/>
                    <p>
                    Localidad:  <s:property value="localidad"/>
                    <p>
                    Descripción: <s:property value="descripcion"/>
                    <p>
                    Propietario: <s:property value="propietario.nombre"/>

2
  • 2
    Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example. Commented Jun 16, 2016 at 12:41
  • You are either 1) missing the getter for propietario or nombre, or 2) propietario is a List, or 3) you have typos Commented Jun 16, 2016 at 12:46

1 Answer 1

1

In order to show attributes from your List<Pisos> array, you would need to do this:

<s:iterator value="pisos">
  <s:property value="someAttributeOnPisos"/>
</s:iterator>

In other words, collections must be iterated in the JSP and Struts2 will push them to the top of the stack inside the iterator, allowing you to access the top of the value stack value directly, as shown above.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.