首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Tapestry onEvent问题

Tapestry onEvent问题
EN

Stack Overflow用户
提问于 2013-06-10 22:45:32
回答 1查看 670关注 0票数 0

我在更新链接的select组件时遇到了一个问题--我键入的似乎是有效的,但它给了我一个很大的丑陋的错误消息。

Component.tml (相关章节)

代码语言:javascript
复制
<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 (相关章节)

代码语言:javascript
复制
     @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组件都包含预期的信息-但是我得到了一条红色的丑陋的大错误消息,占据了半个屏幕。

代码语言:javascript
复制
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。该组件是由许多子组件组成的表单的一部分-其他子组件都没有这个问题(可能是因为这是唯一使用链式select的组件)。有没有人能解释一下我做错了什么/为什么我会得到这个错误?

EN

回答 1

Stack Overflow用户

发布于 2013-06-11 17:01:42

看起来我找到了答案(尽管我必须承认我不理解这种行为)。就在select之前,我在我的tml文件中包含了一个自定义组件。自定义组件包含一个元素,这似乎导致表单在标记之前关闭(更有可能是在tml结构上搞乱了,而不是提前关闭表单,因为没有其他错误)。从我的自定义组件中删除已解决此问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17026612

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档