struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexandru <>
Subject Fw: RE: struts tags: How to use a list inside another list
Date Tue, 14 Jun 2011 13:16:36 GMT

--- On Tue, 6/14/11, Alexandru <> wrote:

From: Alexandru <>
Subject: RE: struts tags: How to use a list inside another list
To: "Martin Gainty" <>
Date: Tuesday, June 14, 2011, 9:15 AM

So it is possible to send a list with another list ( 2d list) to a servlet? My sources follows:

    <s:form action="do-translate-document" cssClass="formtable"
        <s:iterator value="contentList">
            <p class="expression">
                <s:property value="expression" />
            <s:hidden name=""/>
 name="contentList.content.translations.translation"> </textarea>
            <s:iterator value="translations">
                <p class="translation"><s:property value="translation"
        <s:submit />
public class Content {
    private Long id;
    private String expression;
    private List<Translation> translations;
    public void setExpression(String expression)
        this.expression = expression;

    public String getExpression() {
        return expression;
    public void setTranslations(List<Translation> translation) {
        this.translations = translation;
    public List<Translation> getTranslations() {
        if(translations == null)
            translations = new ArrayList<Translation>();
        return this.translations;
    public void addTranslation(Translation translation){
    public void setId(Long id) { = id;

    public Long getId() {
        return id;

public class Translation {
    private Long id;
    private Content expression;
    private String translation;
    public Translation(){}
    public Translation(String s){
        translation = s;
    public void setId(Long id) { = id;

 Long getId() {
        return id;

    public void setExpression(Content expression) {
        this.expression = expression;

    public Content getExpression() {
        return expression;

    public void setTranslation(String translation) {
        this.translation = translation;

    public String getTranslation() {
        return translation;
public class TranslateDocumentAction extends ActionSupport {

    private static final long serialVersionUID = -1752813781713631809L;
 private List<Document> documentList;
    private List<Content> contentList;
    private String project_id; //Project's id
    private String document_id;//Document's id
    public String selectDocument(){
        Session s = HibernateUtil.getSessionFactory().openSession();
        if(document_id == null){
            documentList= (List<Document>)s.createQuery("from Document d where
            documentList= (List<Document>)s.createQuery("from Document d where
            contentList = (List<Content>)
 s.createQuery("from Content c where c.document="+document_id).list();
        return SUCCESS;
    public void validate(){}
    public void setDocumentList(List<Document> documentList) {
        this.documentList = documentList;

    public List<Document> getDocumentList() {
        if(documentList ==null)
            documentList = new ArrayList<Document>();
        return documentList;

    public void setProject_id(String project_id) {
     this.project_id = project_id;

    public String getProject_id() {
        return project_id;

    public void setDocument_id(String document_id) {
        this.document_id = document_id;

    public String getDocument_id() {
        return document_id;

    public void setContentList(List<Content> contentList) {
        this.contentList = contentList;

    public List<Content> getContentList() {
        return contentList;

--- On Tue, 6/14/11, Martin Gainty
 <> wrote:

From: Martin Gainty <>
Subject: RE: struts tags: How to use a list inside another list
Date: Tuesday, June 14, 2011, 8:52 AM

without looking at the Action class and the struts-config.xml it is difficult to determine
the failure to submit problem ..i did notice
1)contentList.content.translations.translation whwre name is not camelcase but lowercase and
does not include package identitifer e.g.
2)you endtag textarea to exclude <s:iterator value="translations">..thus textarea is
one giant block of text without any relationship
to any of the other declared properties
3)the declared iterator <s:iterator value="translations"> has no knowledge or association
with previous iterator <s:iterator value="translations"> and does not reflect the current
state of the iterator e.g.:
<!-- this example pulls from collection leftSideCartoonCharacters and the property will
output the count (and the top property) -->
            <s:iterator value="leftSideCartoonCharacters"
                <s:property value="%{#stat.count}" />.<s:property
value="top" />&nbsp;

difficult to say whats going on without seeing your action class and struts-config.xml
Martin Gainty 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten
wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist
unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet
keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen
wir keine Haftung fuer den Inhalt
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire
prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe
quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information
seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les
email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune
responsabilité pour le contenu fourni.

> Date: Tue, 14 Jun 2011 05:33:54 -0700
> From:
> Subject: Re: struts tags: How to use a list inside another list
> To:
> Is there a way to submit the contentList back to the server? in other words, can i send
a list from jsp to struts? I tried the following but it doesn't work:
>     <s:form
 action="do-translate-document" cssClass="formtable"
>         method="POST">
>         <s:iterator value="contentList">
>             <tr><td>
>             <p >
>                 <s:property value="expression" />
>             </p>
>             <s:hidden name="id"/>
>             <textarea name="contentList.content.translations.translation">
>             <s:iterator value="translations">
         <p class="translation"><s:property value="translation" /></p>
>             </s:iterator>
>             </td></tr>
>         </s:iterator>
>         <s:submit />
>     </s:form>

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message