开发者

Problem displaying property on Struts2

开发者 https://www.devze.com 2023-02-16 08:43 出处:网络
i have the following action class: package com.pendulum.web; import java.util.ArrayList; import java.util.List;

i have the following action class:

package com.pendulum.web;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.pendulum.dao.DocumentoDAO;
import com.pendulum.domain.Documento;
import com.pendulum.domain.DocumentoPK;

public class DocumentoAction extends ActionSupport implements ModelDriven<Documento>{

    private static final long serialVersionUID = 8757127171831894323L;
    private Documento documento = new Documento();
    private List<Documento> documentList = new ArrayList<Documento>();
    private DocumentoDAO documentoDAO = new DocumentoDAO();
    private Documento currDocument = new Documento(); 
    private DocumentoPK documentoPK = new DocumentoPK();

    @Override
    public Documento getModel() {
        return documento;
    }

    public Documento getDocumento() {
        return documento;
    }

    public void setDocumento(Documento documento) {
        this.documento = documento;
    }

    public List<Documento> getDocumentList() {
        return documentList;
    }

    public void setDocument开发者_StackOverflow社区List(List<Documento> documentList) {
        this.documentList = documentList;
    }

    public String listDocument()
    {
        HttpServletRequest request = (HttpServletRequest) ActionContext.getContext().get(ServletActionContext.HTTP_REQUEST);
        documentList = documentoDAO.listDocumentsByCreditId(request.getParameter("creditId"));
        if (documentList.size()>0) {
            currDocument = documentList.get(0);
            documentoPK = currDocument.getDocumentoPK();
        }

        System.err.println(documentList.size());
        System.err.println(currDocument.getDocumentoPK().getCreditoId());
        System.err.println(currDocument.getOrigenId());
        return SUCCESS;
    }

    public DocumentoDAO getDocumentoDAO() {
        return documentoDAO;
    }

    public void setDocumentoDAO(DocumentoDAO documentoDAO) {
        this.documentoDAO = documentoDAO;
    }

    public Documento getCurrDocument() {
        return currDocument;
    }

    public void setCurrDocument(Documento currDocument) {
        this.currDocument = currDocument;
    }

    public DocumentoPK getDocumentoPK() {
        return documentoPK;
    }

    public void setDocumentoPK(DocumentoPK documentoPK) {
        this.documentoPK = documentoPK;
    }


}

My problem is that in my view (.jsp) i can get the properties from currDocument, but i am unable to get the properties inside DocumentoPK.

DocumentoPK is a hibernate composite key declared on its own class, and instantiated on each Documento bean, however... in my jsp i have:

<table class="userTable" cellpadding="5px">
        <tr class="even">
            <td><s:property value="currDocument.origenId"/></td>
            <td><s:property value="documentoPK.creditId"/></td>
            <td><s:property value="currDocument.documentoPK.creditId"/></td>
            <td><s:property value="creditId"/></td>
        </tr>
</table>

but only the value on the first is rendered... and don't know if im missing something obvious. Any help greatly appreciated! Jhurtado


Since the getter on DocumentoPK is getCreditoId(), shouldn't the OGNL property be named creditoId in:

<td><s:property value="documentoPK.creditId"/></td>
<td><s:property value="currDocument.documentoPK.creditId"/></td>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号