0

我有一个提交给lookupDispatchAction 的dynaAction 表单设置。问题是页面加载正常,但在提交时应用程序抛出[BeanUtils.populate] 根本原因 java.lang.IllegalArgumentException: No bean specified that 目前我似乎无法捕获堆栈转储并没有指示在哪里这是造成的代码。只有通过撤消修改后的代码,我才能将原因识别为下面打印的 jsp 中的代码部分。目前,我正在尝试查看是否可以从调试器中获取更多信息,但到目前为止,研究已经暗示了可能的原因,但这些都没有帮助。下面是代码的相关部分(跳过堆栈跟踪以保持这篇文章的合理性:struts-config.xml:

 <form-bean name="MonthlyInvoiceForm" type="com.myapp.form.accounting.MonthlyInvoiceForm">
                <form-property name="idMonthInvoice" type="java.lang.Long"/>
                <form-property name="creationDate" type="java.util.Date"/>
                <form-property name="adresse" type="com.myapp.model.component.CustomerAddress"/>
                <form-property name="extras" type="com.myapp.accounting.customer.ExtraInvoiceForm[]"/>
                <form-property name="creationLoc" initial="Home" type="java.lang.String"/>
                <form-property name="totalHT" type="java.math.BigDecimal"/>
                <form-property name="totalTTC" type="java.math.BigDecimal"/>
                <form-property name="prefix" type="java.lang.Integer"/>
                <form-property name="number" type="java.lang.String"/>
                <form-property name="person" type="java.lang.String"/>
                <form-property name="strTotalHT" type="java.lang.String"/>
                <form-property name="strTotalTTC" type="java.lang.String"/>
                <form-property name="customerName" type="java.lang.String"/>
                <form-property name="strIdCustomer" type="java.lang.String"/>
                <form-property name="strCreationDate" type="java.lang.String"/>
        </form-bean> 

表单本身具有以下设置:

public class MonthlyInvoiceForm extends BaseDynaForm implements ModelForm<MonthlyInvoice>{

@Override
public void reset(ActionMapping mapping, HttpServletRequest request) {
    ExtraInvoiceForm[] extraForms = new ExtraInvoiceForm[1];
    this.set("extras", extraForms);

    CustomerAddress caddress = new CustomerAddress();
    this.set("adresse", caddress);

    BigDecimal tmpTRD = new BigDecimal(BigInteger.ZERO);
    this.set("totalHT", tmpTRD);


    BigDecimal tmpTRM = new BigDecimal(BigInteger.ZERO);
    this.set("totalTTC", tmpTRM);
}

@Override
public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest request) {
    ActionErrors errors = new ActionErrors();

    ExtraInvoiceForm[] extraInvoiceForms = (ExtraInvoiceForm[]) this.get("extras");
    LinkedList<String> credits = new LinkedList<String>(); 
    LinkedList<String> reductions = new LinkedList<String>(); 

    for(ExtraInvoiceForm eif: extraInvoiceForms) {
        eif.validate(errors);

        if(!eif.isBlank()) {
            if(eif.getOperation().equals(ExtraCostInvoice.CREDITOPERATION)) {
                if(credits.contains(eif.getDescription()))
                    errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("invoice.duplicate.credit", eif.getDescription()));
                else
                    credits.add(eif.getDescription());
            } else {
                if(reductions.contains(eif.getDescription()))
                    errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("invoice.duplicate.reduction", eif.getDescription()));
                else
                    reductions.add(eif.getDescription());
            }
        }
    }


    if (StringUtils.isEmpty(this.get("strCreationDate").toString()))
        errors.add("strCreationDate",new ActionError("field.required"));

    if (StringUtils.isEmpty(this.get("creationLoc").toString()))
        errors.add("creationLoc",new ActionError("field.required"));



    return errors;
}

@Override
public void populateModel(MonthlyInvoice model) throws Exception {
    DateTimeFormatter fmt = DateTimeFormat.forPattern("dd MMMM yyyy");
    DateTime crDate;


    crDate = new DateTime(fmt.withLocale(Locale.FRENCH).parseDateTime(this.get("strCreationDate").toString()));
    this.set("creationDate",BaseForm.jodaToSqlDate(crDate));

    PropertyUtils.copyProperties(model, this);
}

该jsp:

<html:form action="/toInvoiceCustomerMissions"> 
/*This is the part of code in the jsp which causes the error*/
<c:forEach var="extras" items="${MonthlyInvoiceForm.map.extras}" varStatus="vs">
                    <tr>
                        <td align="center">
                                                    <html:text indexed="true" name="extras" property="description" size="40" maxlength="100" /></td>
                        <td align="center">
                                                    <html-el:radio indexed="true" name="extras" property="operation"
                            value="<%= ExtraCostInvoice.CREDITOPERATION %>"
                            onclick="setPercentSymbol(${vs.index}, false); calcCustomerAmount();" />Déduction
                                                    <html-el:radio indexed="true" name="extras" property="operation"
                            value="<%= ExtraCostInvoice.REDUCTIONOPERATION %>"
                            onclick="setPercentSymbol(${vs.index}, true); calcCustomerAmount();" />Réduction
                                                    <html-el:radio indexed="true" name="extras" property="operation"
                            value="<%= ExtraCostInvoice.SUPPLEMENTOPERATION %>"
                            onclick="setPercentSymbol(${vs.index}, false); calcCustomerAmount();" />Supplément
                        </td>
                        <td align="center">
                                                    <html:text indexed="true" name="extras"
                            property="strAmount" size="7" maxlength="6" onchange="calcCustomerAmount();" />
                                                    <input type="text" id="extraSymbol<c:out value='${vs.index}'/>" value="&euro;"
                            readonly="readonly" size="1" style="border: none">
                                                </td>
                    </tr>
                </c:forEach>
</html:form>

提前致谢

4

1 回答 1

1

解决了。事实证明,您还需要遍历分配数组的每个元素并在 reset 方法中对其进行初始化;在这种情况下,ExtraInvoiceForm[] extraInvoiceForms必须初始化每个元素。

于 2012-06-11T21:44:14.533 回答