You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by m_salman <mo...@yahoo.com> on 2009/06/03 00:54:17 UTC

Re: DropDownChoice - required, one item so preselection?

I have set the model. But I still don't see it preselected when the
dropDownChoice object is displayed:

		form.add(new DropDownChoice<IParameterInOutType>(
						"parameterInOutType",
						new
CompoundPropertyModel<IParameterInOutType>(parameterMetaData.getParameterInOutType()),
						listParameterInOutType,
						new ChoiceRenderer<IParameterInOutType>("name")));



Am I missing some thing?  DO I need to do something in the html?

Thanks.





Nino.Martinez wrote:
> 
> just set the model to what you want selected:)
> 
> John wrote:
>> hi, when using a DropDownChoice is there a way to have the value
>> preselected if there is only one available and the field is required?
>>
>> i have looked through the code but cannot see any settings that might
>> control this, and am stumped trying to work out how to extend the
>> control in this way.
>>
>> john
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>   
> 
> -- 
> -Wicket for love
> 
> Nino Martinez Wael
> Java Specialist @ Jayway DK
> http://www.jayway.dk
> +45 2936 7684
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/DropDownChoice---required%2C-one-item-so-preselection--tp19198000p23842503.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: DropDownChoice - required, one item so preselection?

Posted by m_salman <mo...@yahoo.com>.
Thanks so much for yoru response.  I tried a few things from your response
and one solution solved the problem.  I changed the ChoiceRenderer
constructor to include the "id" part. And it worked.

So here is the code:

 		
		form = new Form<IParameterMetaData>(
					"form",
					new CompoundPropertyModel<IParameterMetaData>(parameterMetaData));
		
		form.setOutputMarkupPlaceholderTag(true);
		
		add(form);
	
		
	
		form.add(choiceParameterInOutType = 
					new DropDownChoice<IParameterInOutType>(
						"parameterInOutType",
						listParameterInOutType,
						new ChoiceRenderer<IParameterInOutType>("name", "id")));
		
		choiceParameterInOutType.setOutputMarkupPlaceholderTag(true);
		

Thanks again.



Brill Pappin wrote:
> 
> Set the expected value of the id part in your form model (the model  
> where the dropdown will store the submitted value).
> when the dropdown renders it will use the existing value to preset the  
> choice.
> 
> In your code below, it looks like the model is created new every time.  
> for this to work, the model has to have the preselected choice set on  
> it, or it need to survive renders.
> Your ChoiceRenderer simply tells the component which part is id and  
> which is display.
> 
> - Brill Pappin
> 
> 

-- 
View this message in context: http://www.nabble.com/DropDownChoice---required%2C-one-item-so-preselection--tp19198000p23890566.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: DropDownChoice - required, one item so preselection?

Posted by Brill Pappin <br...@pappin.ca>.
Set the expected value of the id part in your form model (the model  
where the dropdown will store the submitted value).
when the dropdown renders it will use the existing value to preset the  
choice.

In your code below, it looks like the model is created new every time.  
for this to work, the model has to have the preselected choice set on  
it, or it need to survive renders.
Your ChoiceRenderer simply tells the component which part is id and  
which is display.

- Brill Pappin


On 2-Jun-09, at 6:54 PM, m_salman wrote:

>
> I have set the model. But I still don't see it preselected when the
> dropDownChoice object is displayed:
>
> 		form.add(new DropDownChoice<IParameterInOutType>(
> 						"parameterInOutType",
> 						new
> CompoundPropertyModel 
> <IParameterInOutType>(parameterMetaData.getParameterInOutType()),
> 						listParameterInOutType,
> 						new ChoiceRenderer<IParameterInOutType>("name")));
>
>
>
> Am I missing some thing?  DO I need to do something in the html?
>
> Thanks.
>
>
>
>
>
> Nino.Martinez wrote:
>>
>> just set the model to what you want selected:)
>>
>> John wrote:
>>> hi, when using a DropDownChoice is there a way to have the value
>>> preselected if there is only one available and the field is  
>>> required?
>>>
>>> i have looked through the code but cannot see any settings that  
>>> might
>>> control this, and am stumped trying to work out how to extend the
>>> control in this way.
>>>
>>> john
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> -- 
>> -Wicket for love
>>
>> Nino Martinez Wael
>> Java Specialist @ Jayway DK
>> http://www.jayway.dk
>> +45 2936 7684
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/DropDownChoice---required%2C-one-item-so-preselection--tp19198000p23842503.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org