You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Elisabeth Adler <el...@gmail.com> on 2009/11/13 00:26:46 UTC

NullPointerEx on adding @Persist to property for parameter "selected" for palette

Hi,

I am trying to get a palette working with simple pojos to be displayed 
in the "available" list. I am working with Tapestry 5.0.11.

I defined my palette in the tml:
<t:palette encoder="cropsEncoder" model="cropsModel" 
selected="selectedCrops"/>

I implemented the encoder and model:
public Object getCropsEncoder() {
        return new GenericValueEncoder<Crop>(manager.getAllCrops(),
                "name", propertyAccess);
}

public Object getCropsModel()  {
        return new GenericSelectModel<Crop>(manager.getAllCrops(), 
Crop.class,
                "name", "id", propertyAccess);
}

I added the property for the selected values:
@Property
private List<Crop> selectedCrops;

This is working fine. As soon as I now try to actually keep the selected 
values in the "selected" list by adding @Persist to the property:
@Property
@Persist
private List<Crop> selectedCrops;

I get the following NullPointerException:
Caused by: java.lang.NullPointerException
    at 
org.apache.tapestry.internal.util.SelectModelRenderer.option(SelectModelRenderer.java:49)
    at 
org.apache.tapestry.corelib.components.Palette$SelectedRenderer.render(Palette.java:145)

The "available" list is displayed correctly, and the error occurs only 
when I select some items and move them over to the "selected" list.
Any ideas what I am missing?
thanks in advance,
Elisabeth

Re: NullPointerEx on adding @Persist to property for parameter "selected" for palette

Posted by Elisabeth Adler <el...@gmail.com>.
Hi,
The equals() method in Crop was missing alltogether. Implementing it was 
doing the trick.
Thanks a mil!
Elisabeth

Thiago H. de Paula Figueiredo wrote:
> Em Thu, 12 Nov 2009 21:26:46 -0200, Elisabeth Adler 
> <el...@gmail.com> escreveu:
>
>> Hi,
>
> Hi!
>
>> I am trying to get a palette working with simple pojos to be displayed
>> in the "available" list. I am working with Tapestry 5.0.11.
>
> That's a very old version . . .
>
>> I get the following NullPointerException:
>> Caused by: java.lang.NullPointerException
>>     at 
>> org.apache.tapestry.internal.util.SelectModelRenderer.option(SelectModelRenderer.java:49) 
>>
>
> I've seen this error before when there's some value in the selected 
> list that isn't available in the model. Also make sure the Crop class 
> has a good equals() method.
>

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


Re: NullPointerEx on adding @Persist to property for parameter "selected" for palette

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Thu, 12 Nov 2009 21:26:46 -0200, Elisabeth Adler  
<el...@gmail.com> escreveu:

> Hi,

Hi!

> I am trying to get a palette working with simple pojos to be displayed
> in the "available" list. I am working with Tapestry 5.0.11.

That's a very old version . . .

> I get the following NullPointerException:
> Caused by: java.lang.NullPointerException
>     at  
> org.apache.tapestry.internal.util.SelectModelRenderer.option(SelectModelRenderer.java:49)

I've seen this error before when there's some value in the selected list  
that isn't available in the model. Also make sure the Crop class has a  
good equals() method.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, 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