You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Rich M <ri...@moremagic.com> on 2011/02/23 19:52:00 UTC

[5.1] NPE when re-rendering Zone with Blocks containing Forms

Hi,

I'm getting the following error

Caused by: java.lang.NullPointerException
     at 
org.apache.tapestry5.corelib.components.Form._$environment_read_renderSupport(Form.java)
     at 
org.apache.tapestry5.corelib.components.Form.beginRender(Form.java:245)
     at org.apache.tapestry5.corelib.components.Form.beginRender(Form.java)

when I re-render the main zone in my page from an ActionLink or 
FormSuccess event method.

More about my page:

The page is divided into 8 blocks, and 6 of the blocks encapsulate a 
form, as such:

<zone>
<delegate />
<block>
<form>
</form>
<block>
  ...
<block>
<form>
</form>
</block>
</zone>

When first loading the page, it delegates to the first block. You can 
fill out the form and then submit the form. Upon submitting the form, it 
triggers the onSuccessFromForm method, which updates the Block for the 
Delegate and returns the zone component.

At this point, I get the NullPointerError which points directly to the 
line in the TML file declaring the <t:form> in the Block that should now 
be delegated to. I declare the t:id of the form and in the page class 
each Form is declared as a private Form with the @Component annotation.

Any help or advice would be appreciated. I have used the 
Zone/Block/Event-Method strategy in another Component of mine 
successfully, but the Blocks in that Component never contained Form 
components, which seems to be the added complication.

Also, I had the Events working when I just returned the page class 
itself by String reference, but I'd prefer to update the Zone over 
reload the Page each time.

Thanks,
Rich


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


Re: [5.1] NPE when re-rendering Zone with Blocks containing Forms

Posted by Rich M <ri...@moremagic.com>.
Ah, thanks for the example! It was obvious right away what I was doing 
wrong. Turned out to be I simply forgot the t:zone parameter for the 
Form and ActionLink components encapsulated by the Zone, which would 
explain why Tapestry had been complaining when I was doing 
zone.getBody() as returns from the Event methods before.

Thanks,
Rich

On 02/23/2011 02:49 PM, Josh Canfield wrote:
>> Hi,
>>
>> I'm getting the following error
> I can't reproduce the error. Can you create a cut down version that
> causes the problem?
>
> Here is my attempt to recreate.
>
>
>      @Property
>      private String blockId = "one";
>
>      @Component
>      private Zone blockZone;
>
>      @Component
>      private Form oneForm;
>
>      @Property
>      private String oneText;
>
>      @Component
>      private Form twoForm;
>
>      @Property
>      private String twoText;
>
>      @Inject
>      private ComponentResources resources;
>
>      public Block onSuccessFromOneForm() {
>          blockId = "two";
>          return blockZone.getBody();
>      }
>
>      public Block onSuccessFromTwoForm() {
>          blockId = "one";
>          return blockZone.getBody();
>      }
>
>      public Block getTheBlock() {
>          return resources.getBlock(blockId);
>      }
>
>
> <t:zone t:id="blockZone">
>      <t:delegate to="theBlock"/>
>      <t:block t:id="one">
>          <t:form t:id="oneForm" t:zone="blockZone">
>              <t:label for="oneText">One</t:label>
>              <t:textfield t:id="oneText"/>
>              <t:submit/>
>          </t:form>
>      </t:block>
>      <t:block t:id="two">
>          <t:form t:id="twoForm" t:zone="blockZone">
>              <t:label for="twoText">Two</t:label>
>              <t:textfield t:id="twoText"/>
>              <t:submit/>
>          </t:form>
>      </t:block>
> </t:zone>
>
> Josh
>
> On Wed, Feb 23, 2011 at 10:52 AM, Rich M<ri...@moremagic.com>  wrote:
>> Hi,
>>
>> I'm getting the following error
>>
>> Caused by: java.lang.NullPointerException
>>     at
>> org.apache.tapestry5.corelib.components.Form._$environment_read_renderSupport(Form.java)
>>     at
>> org.apache.tapestry5.corelib.components.Form.beginRender(Form.java:245)
>>     at org.apache.tapestry5.corelib.components.Form.beginRender(Form.java)
>>
>> when I re-render the main zone in my page from an ActionLink or FormSuccess
>> event method.
>>
>> More about my page:
>>
>> The page is divided into 8 blocks, and 6 of the blocks encapsulate a form,
>> as such:
>>
>> <zone>
>> <delegate />
>> <block>
>> <form>
>> </form>
>> <block>
>>   ...
>> <block>
>> <form>
>> </form>
>> </block>
>> </zone>
>>
>> When first loading the page, it delegates to the first block. You can fill
>> out the form and then submit the form. Upon submitting the form, it triggers
>> the onSuccessFromForm method, which updates the Block for the Delegate and
>> returns the zone component.
>>
>> At this point, I get the NullPointerError which points directly to the line
>> in the TML file declaring the<t:form>  in the Block that should now be
>> delegated to. I declare the t:id of the form and in the page class each Form
>> is declared as a private Form with the @Component annotation.
>>
>> Any help or advice would be appreciated. I have used the
>> Zone/Block/Event-Method strategy in another Component of mine successfully,
>> but the Blocks in that Component never contained Form components, which
>> seems to be the added complication.
>>
>> Also, I had the Events working when I just returned the page class itself by
>> String reference, but I'd prefer to update the Zone over reload the Page
>> each time.
>>
>> Thanks,
>> Rich
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


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


Re: [5.1] NPE when re-rendering Zone with Blocks containing Forms

Posted by Josh Canfield <jo...@gmail.com>.
> Hi,
>
> I'm getting the following error

I can't reproduce the error. Can you create a cut down version that
causes the problem?

Here is my attempt to recreate.


    @Property
    private String blockId = "one";

    @Component
    private Zone blockZone;

    @Component
    private Form oneForm;

    @Property
    private String oneText;

    @Component
    private Form twoForm;

    @Property
    private String twoText;

    @Inject
    private ComponentResources resources;

    public Block onSuccessFromOneForm() {
        blockId = "two";
        return blockZone.getBody();
    }

    public Block onSuccessFromTwoForm() {
        blockId = "one";
        return blockZone.getBody();
    }

    public Block getTheBlock() {
        return resources.getBlock(blockId);
    }


<t:zone t:id="blockZone">
    <t:delegate to="theBlock"/>
    <t:block t:id="one">
        <t:form t:id="oneForm" t:zone="blockZone">
            <t:label for="oneText">One</t:label>
            <t:textfield t:id="oneText"/>
            <t:submit/>
        </t:form>
    </t:block>
    <t:block t:id="two">
        <t:form t:id="twoForm" t:zone="blockZone">
            <t:label for="twoText">Two</t:label>
            <t:textfield t:id="twoText"/>
            <t:submit/>
        </t:form>
    </t:block>
</t:zone>

Josh

On Wed, Feb 23, 2011 at 10:52 AM, Rich M <ri...@moremagic.com> wrote:
> Hi,
>
> I'm getting the following error
>
> Caused by: java.lang.NullPointerException
>    at
> org.apache.tapestry5.corelib.components.Form._$environment_read_renderSupport(Form.java)
>    at
> org.apache.tapestry5.corelib.components.Form.beginRender(Form.java:245)
>    at org.apache.tapestry5.corelib.components.Form.beginRender(Form.java)
>
> when I re-render the main zone in my page from an ActionLink or FormSuccess
> event method.
>
> More about my page:
>
> The page is divided into 8 blocks, and 6 of the blocks encapsulate a form,
> as such:
>
> <zone>
> <delegate />
> <block>
> <form>
> </form>
> <block>
>  ...
> <block>
> <form>
> </form>
> </block>
> </zone>
>
> When first loading the page, it delegates to the first block. You can fill
> out the form and then submit the form. Upon submitting the form, it triggers
> the onSuccessFromForm method, which updates the Block for the Delegate and
> returns the zone component.
>
> At this point, I get the NullPointerError which points directly to the line
> in the TML file declaring the <t:form> in the Block that should now be
> delegated to. I declare the t:id of the form and in the page class each Form
> is declared as a private Form with the @Component annotation.
>
> Any help or advice would be appreciated. I have used the
> Zone/Block/Event-Method strategy in another Component of mine successfully,
> but the Blocks in that Component never contained Form components, which
> seems to be the added complication.
>
> Also, I had the Events working when I just returned the page class itself by
> String reference, but I'd prefer to update the Zone over reload the Page
> each time.
>
> Thanks,
> Rich
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

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