You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by ANDRE Christophe <ch...@docapost-bpo.com> on 2013/09/12 20:16:41 UTC
NullPointer when refreshing a page with a table inside a zone
Hi,
I have the following zone with table inside :
<t:zone t:id="myZone" t:visible="false">
<table t:type="grid" t:source="myObjects" t:row="currentObject" t:model="model" t:rowIndex="indexRow">
<p:actionCell>
...
</p:actionCell>
<p:empty>
<p>There is nothing</p>
</p:empty>
</table>
</t:zone>
And the following form :
<t:form id="myForm" t:id="myForm" t:zone=" myZone ">
<input t:type="textfield" t:value="myValue" t:id="valueInput" type="text" name="valueInput" style="display:none"/>
<input t:type="submit" t:id="submitValueId" id=" submitValueId " value="Submit" style="display:none"/>
</t:form>
After updating the zone using ajax like this:
@Property
private BeanModel<myObject> model;
@Inject
private BeanModelSource beanModelSource;
@OnEvent(value="success", component = " myForm ")
public void processForm() throws Exception {
model = beanModelSource.createDisplayModel(myObject.class, resources.getMessages());
...
ajaxResponseRenderer.addRender("myZone ", myZone.getBody());
}
My zone get updated and the table become visible.
But I get a Null pointer if I refresh the page or when a redirection is done on this page:
Caused by: java.lang.NullPointerException
at org.apache.tapestry5.corelib.components.GridColumns.setupRender(GridColumns.java:112)
at org.apache.tapestry5.corelib.components.GridColumns.setupRender(GridColumns.java)
at org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase.invokeComponent(ComponentPageElementImpl.java:174)
at org.apache.tapestry5.internal.structure.ComponentPageElementImpl$AbstractPhase.invoke(ComponentPageElementImpl.java:133)
What am I doing wrong?
(Also I have the feeling the page is not fully reloaded when the page is refreshed!?)
Thx
Christophe
Ce message et toutes les pieces jointes (ci apres le message) sont etablis a l intention exclusive de leurs destinataires.
Si vous recevez ce message par erreur, merci de le detruire et d en avertir immediatement l expediteur par e mail.
Toute utilisation de ce message non conforme a sa destination, toute diffusion ou toute publication, totale ou partielle, est interdite, sauf autorisation expresse de l expediteur.
Les communications sur Internet n etant pas securisees, DOCAPOST BPO informe qu elle ne peut accepter aucune responsabilite quant au contenu de ce message.
Re: NullPointer when refreshing a page with a table inside a zone
Posted by Boris Horvat <ho...@gmail.com>.
You seem to have a few extra spaces, not sure if that is your problem but
still
t:zone=" myZone "
ajaxResponseRenderer.addRender("myZone ", myZone.getBody());
@OnEvent(value="success", component = " myForm ")
On Thu, Sep 12, 2013 at 8:16 PM, ANDRE Christophe <
christophe.andre3@docapost-bpo.com> wrote:
> Hi,
>
> I have the following zone with table inside :
>
> <t:zone t:id="myZone" t:visible="false">
> <table t:type="grid" t:source="myObjects" t:row="currentObject"
> t:model="model" t:rowIndex="indexRow">
> <p:actionCell>
> ...
> </p:actionCell>
> <p:empty>
> <p>There is nothing</p>
> </p:empty>
> </table>
> </t:zone>
>
> And the following form :
>
> <t:form id="myForm" t:id="myForm" t:zone=" myZone ">
> <input t:type="textfield"
> t:value="myValue" t:id="valueInput" type="text" name="valueInput"
> style="display:none"/>
> <input t:type="submit"
> t:id="submitValueId" id=" submitValueId " value="Submit"
> style="display:none"/>
> </t:form>
>
> After updating the zone using ajax like this:
>
> @Property
> private BeanModel<myObject> model;
>
> @Inject
> private BeanModelSource beanModelSource;
>
> @OnEvent(value="success", component = " myForm ")
> public void processForm() throws Exception {
> model =
> beanModelSource.createDisplayModel(myObject.class, resources.getMessages());
> ...
> ajaxResponseRenderer.addRender("myZone ", myZone.getBody());
> }
>
>
> My zone get updated and the table become visible.
> But I get a Null pointer if I refresh the page or when a redirection is
> done on this page:
> Caused by: java.lang.NullPointerException
> at
> org.apache.tapestry5.corelib.components.GridColumns.setupRender(GridColumns.java:112)
> at
> org.apache.tapestry5.corelib.components.GridColumns.setupRender(GridColumns.java)
> at
> org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase.invokeComponent(ComponentPageElementImpl.java:174)
> at
> org.apache.tapestry5.internal.structure.ComponentPageElementImpl$AbstractPhase.invoke(ComponentPageElementImpl.java:133)
>
> What am I doing wrong?
> (Also I have the feeling the page is not fully reloaded when the page is
> refreshed!?)
>
> Thx
>
>
> Christophe
>
> Ce message et toutes les pieces jointes (ci apres le message) sont etablis
> a l intention exclusive de leurs destinataires.
> Si vous recevez ce message par erreur, merci de le detruire et d en
> avertir immediatement l expediteur par e mail.
> Toute utilisation de ce message non conforme a sa destination, toute
> diffusion ou toute publication, totale ou partielle, est interdite, sauf
> autorisation expresse de l expediteur.
> Les communications sur Internet n etant pas securisees, DOCAPOST BPO
> informe qu elle ne peut accepter aucune responsabilite quant au contenu de
> ce message.
>
--
Sincerely
*Boris Horvat*
Re: NullPointer when refreshing a page with a table inside a zone
Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 13 Sep 2013 04:57:15 -0300, ANDRE Christophe
<ch...@docapost-bpo.com> wrote:
> Thanks for all your answers.
>
> I tried your solution Thiago like this:
>
> BeanModel<MyObject> getModel() {
> return
> beanModelSource.createDisplayModel(myObject.class,resources.getMessages());
> }
This method should be public.
--
Thiago H. de Paula Figueiredo
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
RE: NullPointer when refreshing a page with a table inside a zone
Posted by ANDRE Christophe <ch...@docapost-bpo.com>.
Thanks for all your answers.
I tried your solution Thiago like this:
BeanModel<MyObject> getModel() {
return
beanModelSource.createDisplayModel(myObject.class,resources.getMessages());
}
And by removing:
@Property
private BeanModel< MyObject > model;
But then I get: ...pages.Index does not contain a property (or public field) named 'model'
The solution I found was to define my model two times:
@BeginRender
public void begin() {
model = beanModelSource.createDisplayModel(myObject.class, resources.getMessages());
}
And in
@OnEvent(value="success", component = " myForm ")
public void processForm() throws Exception {
myObjects = ...
model = beanModelSource.createDisplayModel(myObject.class, resources.getMessages());
...
ajaxResponseRenderer.addRender("myZone ", myZone.getBody());
}
I guess it's not really clean to define it two times...
I m using Tapestry version 5.3.3
Thx
Christophe
-----Message d'origine-----
De : Thiago H de Paula Figueiredo [mailto:thiagohp@gmail.com]
Envoyé : jeudi 12 septembre 2013 20:48
À : Tapestry users
Objet : Re: NullPointer when refreshing a page with a table inside a zone
On Thu, 12 Sep 2013 15:16:41 -0300, ANDRE Christophe <ch...@docapost-bpo.com> wrote:
> Hi,
Hi!
Your code is missing that part that provides the value for myObjects and what Tapestry version you're using. In addition, you seem to be only setting the model field when rendering the whole Grid. Why don't you remove the model field and replace it with this:
BeanModel<MyObject> getModel() {
return
beanModelSource.createDisplayModel(myObject.class,resources.getMessages());
}
This will make sure the model passed to Grid is never null.
--
Thiago H. de Paula Figueiredo
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Ce message et toutes les pieces jointes (ci apres le message) sont etablis a l intention exclusive de leurs destinataires.
Si vous recevez ce message par erreur, merci de le detruire et d en avertir immediatement l expediteur par e mail.
Toute utilisation de ce message non conforme a sa destination, toute diffusion ou toute publication, totale ou partielle, est interdite, sauf autorisation expresse de l expediteur.
Les communications sur Internet n etant pas securisees, DOCAPOST BPO informe qu elle ne peut accepter aucune responsabilite quant au contenu de ce message.
Re: NullPointer when refreshing a page with a table inside a zone
Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Thu, 12 Sep 2013 15:16:41 -0300, ANDRE Christophe
<ch...@docapost-bpo.com> wrote:
> Hi,
Hi!
Your code is missing that part that provides the value for myObjects and
what Tapestry version you're using. In addition, you seem to be only
setting the model field when rendering the whole Grid. Why don't you
remove the model field and replace it with this:
BeanModel<MyObject> getModel() {
return
beanModelSource.createDisplayModel(myObject.class,resources.getMessages());
}
This will make sure the model passed to Grid is never null.
--
Thiago H. de Paula Figueiredo
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org