Hello again,

And again thank you for all your help and interest I really appreciate it!.
This is not working... 
I have a CompoundPropertyModel with all the data from the form, including
the country.
The getCountries() method outputs the list of countries depending on the
language stored in session.
But if I create the DropDownChoice as you said:

 countries = new DropDownChoice("country", 
                new Model() {
                    public List getObject()
                    {
                        return getCountries();}
                    }, new ChoiceRenderer ("countryName", "countryID"));

I have a RunTimeException: java.lang.NullPointerException: List of choices
is null - Was the supplied 'Choices' model empty?

I'm sure that getCountries() always gives something back, so I'm missing
something here... The getObject() of the Model is always called?

Thank you again,
Oskar




Janos Cserep wrote:
> 
> 2007/3/30, Toscano <[EMAIL PROTECTED]>:
>>
>>
>> countries = new DropDownChoice ("country",
>>                 new Model() {
>>                     public List getObject() {
>>                         return getCountries();
>>                     }
>>                 }, getCountries(),
>>                 new CountryChoiceRenderer());
>>
> 
> 
> Skip the second getCountries() call - you don't need that - and also this
> way you lose the selected country (check the javadoc for DDC). Wicket
> Models
> may be hard to grasp at first, I suggest you read the wiki again.
> 
> Remember: component's are just components they don't (or at least
> shouldn't)
> store domain objects. Models do that. If you pass a List to DropDownChoice
> it will be wrapped in a static Model in the constructor and won't be
> affected by later changes. If you pass in a Model which calls
> getCountries()
> on each request - your Model will refresh the list on each request.
> 
> My solution for you would be to write:
> 
> countries = new DDC("country", new PropertyModel(this, "countries), new
> CountryChoiceRenderer());
> 
> This of course needs a CompoundPropertyModel somewhere up the component
> tree
> that stores a bean that has getCountry() and setCountry() methods... If
> you
> want to store your selected country elsewhere, you will need something
> similar to the following code:
> 
> countries = new DDC("country", new PropertyModel(countryBean,
> "selectedCountry"), new PropertyModel(this, "countries), new
> CountryChoiceRenderer());
> 
> -- 
> János Cserép - [EMAIL PROTECTED]
> Mobile: +36 20 4328730
> Web: http://www.szeretgom.hu
> Skype: cserepj
> 
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share
> your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Internationalization-and-DropDownChoice-tf3485705.html#a9866830
Sent from the Wicket - User mailing list archive at Nabble.com.


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to