Taking a peek:

    public String getClientId()
    {
        if (clientId == null)
        {
            clientId = jsSupport.allocateClientId(resources);
            hiddenInputElement.forceAttributes("id", clientId);  //
Hidden.java, line 152
        }

        return clientId;
    }

An NPE there makes it look like the Hidden element has not yet rendered.

It would be interesting to capture the MarkupWriter and see what markup has
been written at the point your afterRender() method is invoked.  Possibly,
you are returned the wrong Block from clientBlock, so the Hidden component
is never rendered.


On Tue, Mar 19, 2013 at 9:40 AM, Tony Nelson <[email protected]> wrote:

> 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: [email protected]
> For additional commands, e-mail: [email protected]
>
>


-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

Reply via email to