still the same problem then i am affraid.
I have to control the visibilty if toat selectoption depending on what the model object is of the Select itself. (null or something)


On 12/3/05, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
but a SelectOption is not in your collection - its a component. The whole point of the Select component is to have full control over the markup. All our core choice elements limit your access to markup by producing the entire <select> output for you including all the options. The point of Select/SelectOption is to have total control.

So for the previous example you cao do something like this:
Collection smallCars=getSmallCars();
Collection bigCars=getBigCars();
IOptionRenderer carRenderer=new IOptionRenderer() {...}

Select carSelect=new Select("carSelect").add( RequiredValidator.getInstance());
carSelect.add(new SelectOption("none", new Model(/*NULL*/));
carSelect.add(new SelectOptions("small", smallCars, carRenderer));
carSelect.add(new SelectOptions("big", bigCars, carRenderer));

and then in markup
<select wicket:id="carSelect">
<option wicket:id="none">Please Select One</option>
<optgroup label="small cars">
   <span wicket:id="small"></span>
</optgroup>
<optgroup label="big cars">
   <span wicket:id="big"></span>
</optgroup>
</select>

personally i dont see what the point of "select one" is if a choice is required. easier to just not add one and let the box default to the first choice. sure it requires more attention on the part of the user - but thats what confirmation pages are for :)


-Igor



On 12/2/05, Johan Compagner <[EMAIL PROTECTED] > wrote:
yes then  it is exactly what i say.
for "Choose one.." you shouldn't have to need a SelectChoice == option element in youre collection
Because "Choose one" should only be there if nothing is selected and null value isn't allowed...


johan


On 12/2/05, Igor Vaynberg < [EMAIL PROTECTED]> wrote:
no, SelectChoice is a component that represents a single <option> element. you add that to the Select component. SelectChoices is a convinience component that draws out a bunch of <option> tags much like our current components.

-Igor



On 12/2/05, Johan Compagner < [EMAIL PROTECTED]> wrote:
That selectchoice is a thing you have to add to the collection of choices?
then that is not that nice. Because choose one should only be there if no one is selected and null is required (or something like that)
Because of that you can't add it easily to the collection because you have to know that you want to add it or not...

I like the getDefaultValue() or what is that method  called of DropDown..

johan



On 12/2/05, Igor Vaynberg < [EMAIL PROTECTED]> wrote:
just checked in a fix. also the Select element does not add a "choose one" choice for you, you have to do it yourself by adding a SelectChoice that represents that element.

-Igor



On 12/2/05, Davide Savazzi <[EMAIL PROTECTED]> wrote:
On 11/30/05, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
> any feedback on this yet? if not, i guess i will polish it with its current
> feature set and that will be that.

I have a Map that contains List of choices, my code is:

Map choicesMap = getChoicesMap();
Select select = new Select("mySelect", new PropertyModel(myModel,
"propertyName"));
IOptionRenderer renderer = new IOptionRenderer() {
  public String getDisplayValue(Object selection) {
        return ((Selection) selection).getName();
  }
  public IModel getModel(Object selection) {
        return new Model(new Integer(((Selection) selection).getId()));
  }
};
select.add(new SelectOptions("group1", new Model((Serializable)
choicesMap.get("group1")), renderer));
select.add(new SelectOptions("group2", new Model((Serializable)
choicesMap.get("group2")), renderer));

When myModel.getPropertyName() is null I get a WicketException:

09:50:07,679 ERROR [RequestCycle] Select
[3:step1Form:section4Border:mySelect] contains a null model object,
must be an object of type java.lang.Ob
ject or java.util.Collection (in case of multi-valued select element)

In other dropdown menu when model is null there is a entry like
'Choose one', they don't throw an exception!
Am I using your extension correctly?

Cheers,
--
Davide Savazzi


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&opclick
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user






Reply via email to