I built a page with some pieces that I want to extract to a component. The 
pieces are parts of a form.  I'm not sure I'm taking the proper approach. My 
current idea is to use delegates and blocks.  My component template is:

<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd";
             xmlns:p="tapestry:parameter">


    <t:block t:id="clientBlock">
        <t:hidden t:id="clientId" value="client" />
        <t:textfield t:id="clientName" value="clientName" />
        <t:checkbox type="checkbox" t:id="includeInactiveClients" 
value="includeInactiveClients" />
    </t:block>

    <t:block t:id="divisionBlock">
        <t:hidden t:id="divisionId" value="division" />
        <t:textfield t:id="divisionName" value="divisionName" />
        <t:checkbox type="checkbox" t:id="includeInactiveDivisions" 
value="includeInactiveDivisions" />
    </t:block>

</t:container>


Then in the actual page, I want to use it like this:

            <div class="control-group">
                <label class="control-label">
                    Client:
                </label>
                <div class="controls">
                    <t:delegate to="block:clientBlock" />
                </div>
            </div>


And a similar block to divisionBlock.

Right now I'm getting a null pointer exception from Hidden.java when I try to 
get it's client id.  Specifically:

    @Import(library = { "ClientDivisionAutoComplete.js" })
    public void afterRender() {

        JSONObject specs = new JSONObject(
                "clientId", "#" + clientIdField.getClientId(),
                "clientName", "#" + clientNameField.getClientId(),
                "includeInactiveClients", "#" + 
includeInactiveClientsField.getClientId(),
                "clientNameAutoCompleteUrl", 
componentResources.createEventLink("clientNameAutoComplete").toURI(),
                "divisionId", "#" + divisionId.getClientId(),
                "divisionName", "#" + divisionNameField.getClientId(),
                "includeInactiveDivisions", "#" + 
includeInactiveDivisionsField.getClientId(),
                "divisionNameAutoCompleteUrl", 
componentResources.createEventLink("divisionNameAutoComplete").toURI()
        );

        javaScriptSupport.addInitializerCall("clientDivisionAutoComplete", 
specs);
    }


The exception I'm getting is:

Caused by: java.lang.NullPointerException
        at 
org.apache.tapestry5.corelib.components.Hidden.getClientId(Hidden.java:152)
        at 
com.starpoint.instihire.web.components.ClientDivisionAutoComplete.advised$afterRender_12ecdf1ecc23b3d1(ClientDivisionAutoComplete.java:128)
        at 
com.starpoint.instihire.web.components.ClientDivisionAutoComplete$Invocation_afterRender_12ecdf1ecc23b3d0.proceedToAdvisedMethod(Unknown
 Source)


Is my approach wrong?  This all works when I put it together in a single page, 
but I'm not having much luck extracting it to a component.

Thanks for your help in advance
Tony Nelson
Starpoint Solutions




Since 1982, Starpoint Solutions has been a trusted source of human capital and 
solutions. We are committed to our clients, employees, environment, community 
and social concerns.  We foster an inclusive culture based on trust, respect, 
honesty and solid performance. Learn more about Starpoint and our social 
responsibility at http://www.starpoint.com/social_responsibility

This email message from Starpoint Solutions LLC is for the sole use of  the 
intended recipient(s) and may contain confidential and privileged  information. 
 Any unauthorized review, use, disclosure or distribution is prohibited.  If 
you are not the intended recipient, please contact the sender by reply email 
and destroy all copies of the original message.  Opinions, conclusions and 
other information in this message that do not relate to the official business 
of Starpoint Solutions shall be understood as neither given nor endorsed by it.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to