2009-07-29 14 views
0

J'ai une forme qui ressemble un peu à ceci:html: tag texte ne fonctionne pas

public class MaintainForecastInputForm extends ActionForm { 
    private MainMenuForm mainMenuForm = new MainMenuForm(); 
    public SelectProdLineAssociationForm selectProdLineAssociationForm = new SelectProdLineAssociationForm(); 
    private EconometricDataForm econometricDataForm = new EconometricDataForm(); 
    private EconometricImportDownloadForm econometricImportDownloadForm = new EconometricImportDownloadForm(); 
    private String userAction; 
    private List<MaintainForecastInputForm.DemandForecast> demands = new ArrayList<MaintainForecastInputForm.DemandForecast>(); 
    private List<MaintainForecastInputForm.DemandForecast> forecasts = new ArrayList<MaintainForecastInputForm.DemandForecast>(); 
    private DemandForecast iimsForecast = new DemandForecast(); 
    private DemandForecast econometricForecast = new DemandForecast(); 

    public static class DemandForecast { 
     private String subType; 
     private String shortTermWtAvg="0.0"; 
     private String midTermWtAvg="0.0"; 
     private String longTermWtAvg="0.0"; 
     private String shortTermPct="0.0"; 
     private String midTermPct="0.0"; 
     private String longTermPct="0.0"; 
     private List yearDemands = new ArrayList(); 

    public static class Year { 
      private String fyTotalValue="0.0"; 
      private String fyPctChange="0.0"; 
     private List monthDemands = new ArrayList(); 

     public String getFyPctChange() { 
       return fyPctChange; 
      } 

      public void setFyPctChange(String fyPctChange) { 
       this.fyPctChange = fyPctChange; 
      } 

      public String getFyTotalValue() { 
       return fyTotalValue; 
      } 

      public void setFyTotalValue(String fyTotalValue) { 
       this.fyTotalValue = fyTotalValue; 
      } 
    } // Year 

     public static class Month { 
      private String demandValue="0.0"; 
      private String demandQuantity="0.0"; 

     public String getDemandQuantity() { 
       return demandQuantity; 
      } 

      public void setDemandQuantity(String demandQuantity) { 
       this.demandQuantity = demandQuantity; 
      } 

      public String getDemandValue() { 
       return demandValue; 
      } 

      public void setDemandValue(String demandValue) { 
       this.demandValue = demandValue; 
      } 
    } // Month 

    public String getLongTermPct() { 
      return longTermPct; 
     } 

     public void setLongTermPct(String longTermPct) { 
      this.longTermPct = longTermPct; 
     } 

     public String getLongTermWtAvg() { 
      return longTermWtAvg; 
     } 

     public void setLongTermWtAvg(String longTermWtAvg) { 
      this.longTermWtAvg = longTermWtAvg; 
     } 

     public String getMidTermPct() { 
      return midTermPct; 
     } 

     public void setMidTermPct(String midTermPct) { 
      this.midTermPct = midTermPct; 
     } 

     public String getMidTermWtAvg() { 
      return midTermWtAvg; 
     } 

     public void setMidTermWtAvg(String midTermWtAvg) { 
      this.midTermWtAvg = midTermWtAvg; 
     } 

     public String getShortTermPct() { 
      return shortTermPct; 
     } 

     public void setShortTermPct(String shortTermPct) { 
      this.shortTermPct = shortTermPct; 
     } 

     public String getShortTermWtAvg() { 
      return shortTermWtAvg; 
     } 

     public void setShortTermWtAvg(String shortTermWtAvg) { 
      this.shortTermWtAvg = shortTermWtAvg; 
     } 

     public String getSubType() { 
      return subType; 
     } 

     public void setSubType(String subType) { 
      this.subType = subType; 
     } 

     public List getYearDemands() { 
      return yearDemands; 
     } 

     public void setYearDemands(List yearDemands) { 
      this.yearDemands = yearDemands; 
     } 
    } // DemandForecast 
} 

et dans mon JSP je donne les résultats suivants:

<c:forEach items="${form.iimsForecast.yearDemands}" var="yearDemand"    varStatus="year"> 
    <tr> 
    <td>${yearDemand.fiscalYear}</td> 
    <c:forEach items="${yearDemand.monthDemands}" var="yearMonth"     varStatus="month"> 
     <c:choose> 
     <c:when test="${year.count == 1 && month.count < yearDemand.currentMonth}"> 
      <td class="lightShaded dmnd"> 
      <html-el:text property="form.iimsForecast.yearDemands.monthDemands.demandValue"> 
      </td> 
... 

Je reçois une exception JSP - La propriété getter n'a pas été trouvée dans le formulaire bien qu'elle soit là. Quelqu'un peut-il m'aider avec ce problème s'il vous plaît?

+2

Ajoutez l'exception, ajoutez tout le code, formatez-le correctement. Ce n'est pas assez d'informations. – stevedbrown

Répondre

0

Cela peut sembler évident, mais avez-vous ajouté la bibliothèque de balises à la page?

<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html-el" %> 
2

Votre code ne montre pas si vous avez une méthode getIimsForecast() sur votre formulaire (il ne montre que iimsForecast propriété) - si vous ne le faites pas, vous devez l'ajouter. Cependant, ce n'est pas le seul problème.

Le chemin de votre propriété inclut yearDemands et monthDemands et les méthodes getter pour les deux renvoyer List s. Cela est illégal: le chemin de propriété imbriqué doit avoir des beans simples ou avoir un accès indexé pour les éléments de liste (par exemple, iimsForecast.yearDemands[0].monthDemands[0].demandValue).

Enfin, vous n'avez probablement pas besoin de préfixer votre chemin de propriété avec form, bien que cela dépende de votre configuration et si vous avez une balise <html:form> englobante.