I believe that doing this causes the list to contain one empty, but still selectable, element. That is what I am trying to avoid--I just want a plain empty list. I'm starting to wonder whether empty lists are considered to not be the "Wicket way," as it seems like it should be easier than this. Does ListChoice *intentionally* not allow for an empty list? I expected to find something like "allowEmpty(boolean)"...but no dice.

I could see this being a technical issue since the whole "Choose One"/empty item thing will cause a request parameter to be submitted with a form, whereas an empty list would submit no parameter at all...possibly making it difficult/impossible to determine when a null must be applied to the model during form processing. Does that have anything to do with it?

That aside...thanks very much for your response, Kent.
--Matt

Kent Tong wrote:
Matt Jensen-2 wrote:
Is there any way to get a ListChoice to render as empty (no options) when its choice model is empty? By default, "Choose One" appears. If I set nullValid to true, an empty item appears which is still selectable. I would like to have the list come up completely empty if the choice model is empty, and I'd like to do it without creating a new component (though obviously I will do that if it is what is needed.)


Try:

ListChoice lc = new ListChoice("lc", ...) {
        protected CharSequence getDefaultChoice(Object selected) {
                return "";
        }
};

-----
--
Kent Tong
Wicket tutorials freely available at http://www.agileskills2.org/EWDW

Reply via email to