Tapestry onEvent问题

时间:2013-06-10 14:45:32

标签: tapestry

我遇到了更新链式选择组件的问题 - 我键入的内容似乎正在运行,但它给了我一个很难看的错误信息。

Component.tml(相关部分)

<tr>
    <td>
        <h3>Powers:</h3>
    </td>
    <td>
        <t:select t:id="powersSelect" t:model="powersModel"
            t:value="powersItem" t:encoder="itemEncoder"
             t:validate="required" t:blankOption="ALWAYS" t:blankLabel="Choose..." zone="groundsZone" />
    </td>
</tr>
<tr>
    <td>
        <h3>Grounds:</h3>
    </td>
    <td>
        <t:zone t:id="groundsZone" id="groundsZone" visible="false">
            <t:select  t:model="groundsModel"
                t:value="groundsItem" t:encoder="itemEncoder"
                t:validate="required" t:blankOption="ALWAYS" t:blankLabel="Choose..."/>
        </t:zone>
    </td>
</tr>

Component.java(相关部分)

     @InjectComponent
    private Zone groundsZone;

    @Inject
    private SelectModelFactory selectModelFactory;

    @Property
    private SelectModel powersModel, groundsModel;

    @Property
    StandingDataItem powersStandingDataItem, groundsStandingDataItem;

@SetupRender
void setupRender() {
    powersList = service.getList()
    powersModel = selectModelFactory.create(powersList, "displayText");

   //included as I was getting a null pointer without instantiating 
    groundsList = new ArrayList<StandingDataItem>();
    groundsModel = selectModelFactory.create(new ArrayList<StandingDataItem>(), "displayText");
}

@OnEvent(value = EventConstants.VALUE_CHANGED, component = "powersSelect")
    Object updateGrounds(StandingDataItem sdi) {
        powersStandingDataItem=sdi;
        groundsList = service.getList()
        groundsModel = selectModelFactory.create(groundsList, "displayText");
        return groundsZone.getBody();
    }

但是我一直遇到以下错误并且无法解决。服务方法调用完成,返回预期的列表,并且Select组件都包含预期的信息 - 但是我得到一个大的红色丑陋的错误消息,在屏幕的一半上面说...

TypeError: Cannot call method 'getFormEventManager' of null 
at klass.Tapestry.FieldEventManager.Class.create.initialize (http://localhost:8080/nottsStops/assets/1.0.0-SNAPSHOT/tapestry/tapestry.js:1588:38) 
at new klass (http://localhost:8080/nottsStops/assets/1.0.0-SNAPSHOT/tapestry/scriptaculous_1_9_0/prototype.js:101:23) 
at Element.addMethods.getFieldEventManager (http://localhost:8080/nottsStops/assets/1.0.0-SNAPSHOT/tapestry/tapestry.js:841:23) 
at HTMLSelectElement._methodized [as getFieldEventManager] (http://localhost:8080/nottsStops/assets/1.0.0-SNAPSHOT/tapestry/scriptaculous_1_9_0/prototype.js:438:23) 
at http://localhost:8080/nottsStops/assets/1.0.0-SNAPSHOT/tapestry/tapestry.js:1145:26 
at http://localhost:8080/nottsStops/assets/1.0.0-SNAPSHOT/tapestry/scriptaculous_1_9_0/prototype.js:825:18 
at klass._each (http://localhost:8080/nottsStops/assets/1.0.0-SNAPSHOT/tapestry/scriptaculous_1_9_0/prototype.js:1237:7) 
at klass.each (http://localhost:8080/nottsStops/assets/1.0.0-SNAPSHOT/tapestry/scriptaculous_1_9_0/prototype.js:824:12) 
at T5.extendInitializers.validate (http://localhost:8080/nottsStops/assets/1.0.0-SNAPSHOT/tapestry/tapestry.js:1135:14) 
at http://localhost:8080/nottsStops/assets/1.0.0-SNAPSHOT/tapestry/tapestry.js:268:23
Ajax failure: Status 200 for /nottsStops/stopsentrybuild.powerscomponent.powersselect:change: TypeError: Cannot call method 'getFormEventManager' of null
Communication with the server failed: TypeError: Cannot call method 'getFormEventManager' of null

我正在使用tapestry 5.3.7。该组件是由许多子组件组成的表单的一部分 - 其他子组件都没有此问题(可能因为这是唯一使用链式选择的组件)。谁能解释一下我做错了什么/为什么我会收到这个错误?

1 个答案:

答案 0 :(得分:0)

看起来我找到了答案(虽然我不得不承认我不理解这种行为)。我在select之前在tml文件中包含了一个自定义组件。自定义组件包含一个元素,这似乎导致表单在标记之前关闭(更可能与tml结构混淆,而不是早期关闭表单,因为没有其他错误)。从我的自定义组件中删除已解决该问题。