0

I'm having an issue with updating chained select components - what I have keyed seems to be working but its giving me a big ugly error message.

Component.tml (relevant section)

<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 (relevant section)

     @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();
    }

However I keep hitting the following error and have been unable to resolve. The service method call completes, returns the expected list and both the Select components contain the information expected - however I get a big red ugly error message takign up half the screen saying...

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

I'm using tapestry 5.3.7. The component is part of a form made up of many sub components - none of the other sub components have this issue (likely because this is the only one using a chained select). Can anyone shed some light as to what I'm doing wrong/ why I'm getting this error?

4

1 回答 1

0

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

于 2013-06-11T09:01:42.120 回答