Re: [Wicket-user] Internationalization and DropDownChoice

2007-04-09 Thread Timo Rantalaiho
On Thu, 05 Apr 2007, Toscano wrote:
> 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?

As far as I remember, at least in 2.0 DropDownChoice takes
in two models: a list of the choices, and the initial
choice.  (By the way, this is an excellent example of where
generics make the constructor more explicit). 

So double-check that you are supplying the choices
correctly, and not in fact invoking a constructor that only
determines the default choice.

-- 
Timo Rantalaiho
Reaktor Innovations Oyhttp://www.ri.fi/ >

-
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


Re: [Wicket-user] Internationalization and DropDownChoice

2007-04-05 Thread Toscano

 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


Re: [Wicket-user] Internationalization and DropDownChoice

2007-03-30 Thread Janos Cserep

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


Re: [Wicket-user] Internationalization and DropDownChoice

2007-03-29 Thread Toscano

Hello,

Thank you very much for your fast answer.
I'm using what you said, but sure I'm not doing in the way I should because
it doesn't work as expected. Now I can get keep the country selected, but it
is not refreshed when changing the locale.

This is what I have:

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

I think that the getObject method is never called. The getCountries ones is
prepared so that if the user changes the locale, it gets the correct names
for the countries. So I just need getCountries to be called everytime the
languages dropdown is changed.

So,I think I should write something in this method of the languages
DropDownChoice:
 public void onSelectionChanged (Object newSelection)
{
}

Again, thank you very much for your help.
Oskar



Martijn Dashorst wrote:
> 
> 2 things:
> 
> 1. Probably you should use an IChoiceRenderer in addition to your current
> list.
> 2. you *replace* the component, and with it the selected value, better
> to use a lazy model to retrieve the list of countries, instead of
> pushing it to the component
> 
> ad 2:
> 
> new DDC("countries", new Model() { public void getObject(...) { return
> getCountries(); } }, new CountryChoiceRenderer());
> 
> Martijn
> 
> On 3/29/07, Toscano <[EMAIL PROTECTED]> wrote:
>>
>> Hello,
>>
>> I had the following: one extended DropDownChoice with different languages
>> and some fields in a form. When the user changes it, I get success in
>> getting the translation of everything in the page, and also Wicket
>> maintains
>> whatever the user wrote in the fields, so it's nice. But I have a problem
>> with one DropDownChoice which cointains countries.
>> By default, it show the english names of all the countries in the world.
>> In
>> the onSelectionChanged of the languages DropDownChoice I reload the
>> country
>> names from the database, and make the following:
>>
>>  countries  = new DropDownChoice("country", getCountries());
>>  userInformationForm.replace(countries);
>>
>> It works, at the same time I change the language, I get the country list
>> in
>> that language, but if the user selected one country, I can't maintain his
>> selection...
>>
>> Any ideas? It should be easy as long as the ID of the country is the
>> same...
>>
>> Thank you very very much for your help,
>> Oskar
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Internationalization-and-DropDownChoice-tf3485705.html#a9731005
>> 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
>>
> 
> 
> -- 
> Learn Wicket at ApacheCon Europe: http://apachecon.com
> Join the wicket community at irc.freenode.net: ##wicket
> Wicket 1.2.5 will keep your server alive. Download Wicket now!
> http://wicketframework.org
> 
> -
> 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#a9746837
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


Re: [Wicket-user] Internationalization and DropDownChoice

2007-03-29 Thread Martijn Dashorst
2 things:

1. Probably you should use an IChoiceRenderer in addition to your current list.
2. you *replace* the component, and with it the selected value, better
to use a lazy model to retrieve the list of countries, instead of
pushing it to the component

ad 2:

new DDC("countries", new Model() { public void getObject(...) { return
getCountries(); } }, new CountryChoiceRenderer());

Martijn

On 3/29/07, Toscano <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> I had the following: one extended DropDownChoice with different languages
> and some fields in a form. When the user changes it, I get success in
> getting the translation of everything in the page, and also Wicket maintains
> whatever the user wrote in the fields, so it's nice. But I have a problem
> with one DropDownChoice which cointains countries.
> By default, it show the english names of all the countries in the world. In
> the onSelectionChanged of the languages DropDownChoice I reload the country
> names from the database, and make the following:
>
>  countries  = new DropDownChoice("country", getCountries());
>  userInformationForm.replace(countries);
>
> It works, at the same time I change the language, I get the country list in
> that language, but if the user selected one country, I can't maintain his
> selection...
>
> Any ideas? It should be easy as long as the ID of the country is the same...
>
> Thank you very very much for your help,
> Oskar
>
> --
> View this message in context: 
> http://www.nabble.com/Internationalization-and-DropDownChoice-tf3485705.html#a9731005
> 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
>


-- 
Learn Wicket at ApacheCon Europe: http://apachecon.com
Join the wicket community at irc.freenode.net: ##wicket
Wicket 1.2.5 will keep your server alive. Download Wicket now!
http://wicketframework.org

-
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


[Wicket-user] Internationalization and DropDownChoice

2007-03-29 Thread Toscano

Hello,

I had the following: one extended DropDownChoice with different languages
and some fields in a form. When the user changes it, I get success in
getting the translation of everything in the page, and also Wicket maintains
whatever the user wrote in the fields, so it's nice. But I have a problem
with one DropDownChoice which cointains countries.
By default, it show the english names of all the countries in the world. In
the onSelectionChanged of the languages DropDownChoice I reload the country
names from the database, and make the following:
 
 countries  = new DropDownChoice("country", getCountries());
 userInformationForm.replace(countries);
 
It works, at the same time I change the language, I get the country list in
that language, but if the user selected one country, I can't maintain his
selection... 

Any ideas? It should be easy as long as the ID of the country is the same...

Thank you very very much for your help,
Oskar

-- 
View this message in context: 
http://www.nabble.com/Internationalization-and-DropDownChoice-tf3485705.html#a9731005
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