First, the thing to understand here is that the IModel parameter is used to get the current value (to be used to see whether the option rendered is the currently selected one) and, when a selection changes/ the form is submitted, the model is updated with the new selection.

So in your case, as you use a StringResourceModel, Wicket tries to update that model. However that model is read-only as it can't write to the properties files.

What you should do is either pre-fill you localized options and provide it as a collection (e.g. a List) or implement your custom IChoiceList (start by overriding wicket.markup.html.form.model.ChoiceList or DetachableChoiceList) in order to 'pull' the available options. If you override ChoiceList.newChoice, you can provide your own IChoice implementation, with the localized display string you want.

Also, you should use an updatable model to store what the current selected option is.

Now, about navigating to result pages etc... Like I wrote earlier today (but I think just before you joined this list), you have these options to navigate:

setResponsePage(new MyPage())

setResponsePage(... (e.g. use IPageFactory) )

and a special case is when you want to redirect directly to a non-wicket
address (e.g. the serverside):

setResponsePage(new RedirectPage("http://www.theserverside.com";));


If you look at the first option, it is clear that you can do anything you want, 
e.g. doing:

FooModel fooModel ...

setResponsePage(new MyPage(fooModel));

or setResponsePage(new MyPage(myList, myOtherObject))

etc.



Hope this helps.

Eelco

P.s. we *really* need to write more about Choices, as questions about them keep comming up. There also isn't any example of how to use custom IChoices. I'll try to find some time today, allthough we also have to release the next RC, and I have to create a new release of JettyLauncher.


[EMAIL PROTECTED] wrote:

Hello!

I am trying to understand Wicket since a few weeks...( and quite unexperienced 
in Java ;-(  )
The last struggle I came up to is how to localize a drop down selection.
The first point of course is that all 'values' normally associated with selections get out of sight in Wicket.. How can I localize display strings in a Dropdown list? After lots of looking through the wicket docs and code, I tried the following:

public InputForm(String name, IFeedback feedback)
{
        super(name,new CompoundPropertyModel(new  SrchFormModel()), feedback);
                         add(new DropDownChoice("testType", new 
StringResourceModel("testType", this, null),                
                                                TESTCONTAINER ) ) ;
}

This to my amazement worked to produce the desired result in the selection.. ( I made a srchform.properties file of course with some testType values )

But I was very disappointed that I got an exception that setObject in the used model (StringResourceModel) is not supported....
What should I do?

I too came upon the problem how to forward Form-submission results to the page 
that will handle the form input.
Do I need to pack all returned parameters in a Page parameters object, and construct the new page (target) with this parameters object?, or can I somehow create a model (object) of a form that I can access in the result page..and if sow, how do I do that? (That is, how to forward this object to the target page ; as somehow happens in the library example with a bookdetails - page )
Help will be much appreciated!

Dick








-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user



-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to