You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Paulo Ricardo Ribeiro <pa...@gmail.com> on 2012/01/17 11:47:11 UTC

Select throws NullPointerException

Hello,

I'm using tapestry 5.3.1.

Using a select with the zone parameter, if the session timeout has been
reached and the user changed the selected value, I was getting a
NullPointerException, so, I've downloaded the source, and looked at the
Select.java (tapestry-core) and noticed that the "this.encoder" on the
following method, was null:
  protected Object toValue(String submittedValue)
    {
        return InternalUtils.isBlank(submittedValue) ? null :
this.encoder.toValue(submittedValue);
    }


so, I've changed the source code to:

 protected Object toValue(String submittedValue)
    {
        return (this.encoder == null ||
InternalUtils.isBlank(submittedValue)) ? null :
this.encoder.toValue(submittedValue);
    }

and it worked.


I'm relatively new to Tapestry, so I'd like to ask if this is a feature
(and I'm doing something wrong), or is it a bug?

If this is a bug, should I create an issue here (
https://issues.apache.org/jira/browse/TAP5) and also upload the patch?


Cheers
Paulo Ricardo Ribeiro

Re: Select throws NullPointerException

Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
There is a general issue with Tapestry and AJAX & Expired sessions.
The issue and a solution is described here:
http://code.google.com/p/flowlogix/wiki/TapestryLibrary

On Jan 17, 2012, at 7:02 AM, Paulo Ricardo Ribeiro wrote:

> Hi Thiago
> 
> I wasn't sure where I should post, sorry :)
> 
> 
> So, now, in the correct mailing list, with the code :)
> 
> 
> on my tml I have:
> 
> <select class="input" t:id="keySets" t:type="ck/BeanSelect"
> t:list="listaKeySets" t:zone="result" t:value="keyset"
> t:labelField="literal:contextmark" t:valueField="literal:keysetid"
> t:blankLabel="Seleccione" t:required="true"
> t:blankOption="literal:AUTO">
> </select>
> 
> <div t:type="zone" t:id="result" id="result" class="section result"
> t:inPlace="true">
> 
> ...
> 
> </div>
> 
> on the java side, I have:
> 
> public Object onValueChangedFromKeySets(Object sel2) {
> 
> this.setSelectedTypes(new HashSet<String>());
> if (sel2 == null) {
> this.eid = null;
> this.keyset = null;
> } else {
> Keyset ks = (Keyset) sel2;
> this.eid = ks.getElement().getEid();
> this.keyset = ks;
> }
> return result.getBody();
> }
> 
> 
> This code uses the BeanSelect from chenillekit.
> When the session is OK, the encoder is not null. It only becomes null when
> the session has expired (eg timeout) and the user tries to change the
> selected value.
> 
> 
> 
> Abraço :)
> Paulo Ricardo
> 
> 
> 
> ---------- Forwarded message ----------
> From: Thiago H. de Paula Figueiredo <th...@gmail.com>
> Date: Tue, Jan 17, 2012 at 11:35 AM
> Subject: Re: Select throws NullPointerException
> To: Tapestry development <de...@tapestry.apache.org>, Paulo Ricardo Ribeiro <
> paulo.ricardo@gmail.com>
> 
> 
> On Tue, 17 Jan 2012 08:47:11 -0200, Paulo Ricardo Ribeiro <
> paulo.ricardo@gmail.com> wrote:
> 
> Hello,
>> 
> 
> Bão? :)
> 
> 
> I'm using tapestry 5.3.1.
>> 
>> Using a select with the zone parameter, if the session timeout has been
>> reached and the user changed the selected value, I was getting a
>> NullPointerException, so, I've downloaded the source, and looked at the
>> Select.java (tapestry-core) and noticed that the "this.encoder" on the
>> following method, was null:
>> protected Object toValue(String submittedValue)
>>   {
>>       return InternalUtils.isBlank(**submittedValue) ? null :
>> this.encoder.toValue(**submittedValue);
>>   }
>> 
> 
> You seem to be providing a null value to the encode parameter, which would
> be an error. As always, please post the code, otherwise we can't know
> what's really going on.
> 
> By the way, please post in the users mailing list first before posting in
> dev, as you didn't know yet if it was an user or Tapestry error. ;)
> 
> -- 
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br


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


Re: Select throws NullPointerException

Posted by Paulo Ricardo Ribeiro <pa...@gmail.com>.
Hi Lenny

Thank you for your reply.
Unfortunately I'm in a very tight schedule and wont be able to test
your solution, but on future developments of this project I'll have it in
consideration.


Cheers
Paulo Ricardo


On Tue, Jan 17, 2012 at 2:36 PM, Lenny Primak <lp...@hope.nyc.ny.us>wrote:

> There is a general issue with Tapestry and AJAX & Expired sessions.
> The issue and a solution is described (2nd try!) here:
> http://code.google.com/p/flowlogix/wiki/TLAJAXAnnotation
> On Jan 17, 2012, at 7:02 AM, Paulo Ricardo Ribeiro wrote:
>
> > Hi Thiago
> >
> > I wasn't sure where I should post, sorry :)
> >
> >
> > So, now, in the correct mailing list, with the code :)
> >
> >
> > on my tml I have:
> >
> > <select class="input" t:id="keySets" t:type="ck/BeanSelect"
> > t:list="listaKeySets" t:zone="result" t:value="keyset"
> > t:labelField="literal:contextmark" t:valueField="literal:keysetid"
> > t:blankLabel="Seleccione" t:required="true"
> > t:blankOption="literal:AUTO">
> > </select>
> >
> > <div t:type="zone" t:id="result" id="result" class="section result"
> > t:inPlace="true">
> >
> > ...
> >
> > </div>
> >
> > on the java side, I have:
> >
> > public Object onValueChangedFromKeySets(Object sel2) {
> >
> > this.setSelectedTypes(new HashSet<String>());
> > if (sel2 == null) {
> > this.eid = null;
> > this.keyset = null;
> > } else {
> > Keyset ks = (Keyset) sel2;
> > this.eid = ks.getElement().getEid();
> > this.keyset = ks;
> > }
> > return result.getBody();
> > }
> >
> >
> > This code uses the BeanSelect from chenillekit.
> > When the session is OK, the encoder is not null. It only becomes null
> when
> > the session has expired (eg timeout) and the user tries to change the
> > selected value.
> >
> >
> >
> > Abraço :)
> > Paulo Ricardo
> >
> >
> >
> > ---------- Forwarded message ----------
> > From: Thiago H. de Paula Figueiredo <th...@gmail.com>
> > Date: Tue, Jan 17, 2012 at 11:35 AM
> > Subject: Re: Select throws NullPointerException
> > To: Tapestry development <de...@tapestry.apache.org>, Paulo Ricardo
> Ribeiro <
> > paulo.ricardo@gmail.com>
> >
> >
> > On Tue, 17 Jan 2012 08:47:11 -0200, Paulo Ricardo Ribeiro <
> > paulo.ricardo@gmail.com> wrote:
> >
> > Hello,
> >>
> >
> > Bão? :)
> >
> >
> > I'm using tapestry 5.3.1.
> >>
> >> Using a select with the zone parameter, if the session timeout has been
> >> reached and the user changed the selected value, I was getting a
> >> NullPointerException, so, I've downloaded the source, and looked at the
> >> Select.java (tapestry-core) and noticed that the "this.encoder" on the
> >> following method, was null:
> >> protected Object toValue(String submittedValue)
> >>   {
> >>       return InternalUtils.isBlank(**submittedValue) ? null :
> >> this.encoder.toValue(**submittedValue);
> >>   }
> >>
> >
> > You seem to be providing a null value to the encode parameter, which
> would
> > be an error. As always, please post the code, otherwise we can't know
> > what's really going on.
> >
> > By the way, please post in the users mailing list first before posting in
> > dev, as you didn't know yet if it was an user or Tapestry error. ;)
> >
> > --
> > Thiago H. de Paula Figueiredo
> > Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> > and instructor
> > Owner, Ars Machina Tecnologia da Informação Ltda.
> > http://www.arsmachina.com.br
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Select throws NullPointerException

Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
There is a general issue with Tapestry and AJAX & Expired sessions.
The issue and a solution is described (2nd try!) here:
http://code.google.com/p/flowlogix/wiki/TLAJAXAnnotation
On Jan 17, 2012, at 7:02 AM, Paulo Ricardo Ribeiro wrote:

> Hi Thiago
> 
> I wasn't sure where I should post, sorry :)
> 
> 
> So, now, in the correct mailing list, with the code :)
> 
> 
> on my tml I have:
> 
> <select class="input" t:id="keySets" t:type="ck/BeanSelect"
> t:list="listaKeySets" t:zone="result" t:value="keyset"
> t:labelField="literal:contextmark" t:valueField="literal:keysetid"
> t:blankLabel="Seleccione" t:required="true"
> t:blankOption="literal:AUTO">
> </select>
> 
> <div t:type="zone" t:id="result" id="result" class="section result"
> t:inPlace="true">
> 
> ...
> 
> </div>
> 
> on the java side, I have:
> 
> public Object onValueChangedFromKeySets(Object sel2) {
> 
> this.setSelectedTypes(new HashSet<String>());
> if (sel2 == null) {
> this.eid = null;
> this.keyset = null;
> } else {
> Keyset ks = (Keyset) sel2;
> this.eid = ks.getElement().getEid();
> this.keyset = ks;
> }
> return result.getBody();
> }
> 
> 
> This code uses the BeanSelect from chenillekit.
> When the session is OK, the encoder is not null. It only becomes null when
> the session has expired (eg timeout) and the user tries to change the
> selected value.
> 
> 
> 
> Abraço :)
> Paulo Ricardo
> 
> 
> 
> ---------- Forwarded message ----------
> From: Thiago H. de Paula Figueiredo <th...@gmail.com>
> Date: Tue, Jan 17, 2012 at 11:35 AM
> Subject: Re: Select throws NullPointerException
> To: Tapestry development <de...@tapestry.apache.org>, Paulo Ricardo Ribeiro <
> paulo.ricardo@gmail.com>
> 
> 
> On Tue, 17 Jan 2012 08:47:11 -0200, Paulo Ricardo Ribeiro <
> paulo.ricardo@gmail.com> wrote:
> 
> Hello,
>> 
> 
> Bão? :)
> 
> 
> I'm using tapestry 5.3.1.
>> 
>> Using a select with the zone parameter, if the session timeout has been
>> reached and the user changed the selected value, I was getting a
>> NullPointerException, so, I've downloaded the source, and looked at the
>> Select.java (tapestry-core) and noticed that the "this.encoder" on the
>> following method, was null:
>> protected Object toValue(String submittedValue)
>>   {
>>       return InternalUtils.isBlank(**submittedValue) ? null :
>> this.encoder.toValue(**submittedValue);
>>   }
>> 
> 
> You seem to be providing a null value to the encode parameter, which would
> be an error. As always, please post the code, otherwise we can't know
> what's really going on.
> 
> By the way, please post in the users mailing list first before posting in
> dev, as you didn't know yet if it was an user or Tapestry error. ;)
> 
> -- 
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br


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


Select throws NullPointerException

Posted by Paulo Ricardo Ribeiro <pa...@gmail.com>.
Hi Thiago

I wasn't sure where I should post, sorry :)


So, now, in the correct mailing list, with the code :)


on my tml I have:

<select class="input" t:id="keySets" t:type="ck/BeanSelect"
t:list="listaKeySets" t:zone="result" t:value="keyset"
 t:labelField="literal:contextmark" t:valueField="literal:keysetid"
t:blankLabel="Seleccione" t:required="true"
 t:blankOption="literal:AUTO">
</select>

<div t:type="zone" t:id="result" id="result" class="section result"
t:inPlace="true">

...

</div>

on the java side, I have:

public Object onValueChangedFromKeySets(Object sel2) {

this.setSelectedTypes(new HashSet<String>());
 if (sel2 == null) {
this.eid = null;
this.keyset = null;
 } else {
Keyset ks = (Keyset) sel2;
this.eid = ks.getElement().getEid();
 this.keyset = ks;
}
return result.getBody();
 }


This code uses the BeanSelect from chenillekit.
When the session is OK, the encoder is not null. It only becomes null when
the session has expired (eg timeout) and the user tries to change the
selected value.



Abraço :)
Paulo Ricardo



---------- Forwarded message ----------
From: Thiago H. de Paula Figueiredo <th...@gmail.com>
Date: Tue, Jan 17, 2012 at 11:35 AM
Subject: Re: Select throws NullPointerException
To: Tapestry development <de...@tapestry.apache.org>, Paulo Ricardo Ribeiro <
paulo.ricardo@gmail.com>


On Tue, 17 Jan 2012 08:47:11 -0200, Paulo Ricardo Ribeiro <
paulo.ricardo@gmail.com> wrote:

 Hello,
>

Bão? :)


 I'm using tapestry 5.3.1.
>
> Using a select with the zone parameter, if the session timeout has been
> reached and the user changed the selected value, I was getting a
> NullPointerException, so, I've downloaded the source, and looked at the
> Select.java (tapestry-core) and noticed that the "this.encoder" on the
> following method, was null:
>  protected Object toValue(String submittedValue)
>    {
>        return InternalUtils.isBlank(**submittedValue) ? null :
> this.encoder.toValue(**submittedValue);
>    }
>

You seem to be providing a null value to the encode parameter, which would
be an error. As always, please post the code, otherwise we can't know
what's really going on.

By the way, please post in the users mailing list first before posting in
dev, as you didn't know yet if it was an user or Tapestry error. ;)

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

Re: Select throws NullPointerException

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 17 Jan 2012 08:47:11 -0200, Paulo Ricardo Ribeiro  
<pa...@gmail.com> wrote:

> Hello,

Bão? :)

> I'm using tapestry 5.3.1.
>
> Using a select with the zone parameter, if the session timeout has been
> reached and the user changed the selected value, I was getting a
> NullPointerException, so, I've downloaded the source, and looked at the
> Select.java (tapestry-core) and noticed that the "this.encoder" on the
> following method, was null:
>   protected Object toValue(String submittedValue)
>     {
>         return InternalUtils.isBlank(submittedValue) ? null :
> this.encoder.toValue(submittedValue);
>     }

You seem to be providing a null value to the encode parameter, which would  
be an error. As always, please post the code, otherwise we can't know  
what's really going on.

By the way, please post in the users mailing list first before posting in  
dev, as you didn't know yet if it was an user or Tapestry error. ;)

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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