You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by saty <sa...@gmail.com> on 2013/02/01 19:32:20 UTC

What is wrong/missing in this code, model object deos not get set

IAutoCompleteRenderer<Broker> renderer = new
AbstractAutoCompleteTextRenderer<Broker>() 
		{
			private static final long serialVersionUID = 1L;
			@Override
			protected String getTextValue(Broker object) 
			{
				return object.getBrokerCode() +"-" + object.getDescription();		
			}
	
			
		};

final IModel<Broker> brokerModel = new Model<Broker>();
final AutoCompleteTextField<Broker> broker = new
AutoCompleteTextField<Broker>("broker", brokerModel,renderer)
		{
			private static final long serialVersionUID = 1L;
			@Override
			protected Iterator<Broker> getChoices(String input) 
			{
		List<Broker> choices = new ArrayList<Broker>(10);
                List<Broker> brokers =  getService().getBrokerList();//gets
brokers
                for (final Broker brk : brokers)
                {
                    final String code = brk.getBrokerCode();
                    if (code.toUpperCase().startsWith(input.toUpperCase()))
                    {
                        choices.add(brk);
                        if (choices.size() == 10)
                        {
                            break;
                        }
                    }
                }
                return choices.iterator();
			}};
			
			form.add(broker);
			
			broker.add(new AjaxEventBehavior("onchange")
			{
				@Override
				protected void onEvent(AjaxRequestTarget target) {
					logger.info("AjaxEventBehavior::onchange: "+brokerModel.getObject());
				//always prints null here???	
					
				}				
				
			});

Thanks



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/What-is-wrong-missing-in-this-code-model-object-deos-not-get-set-tp4656005.html
Sent from the Users forum 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: What is wrong/missing in this code, model object deos not get set

Posted by saty <sa...@gmail.com>.
Yes, this is it, thanks



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/What-is-wrong-missing-in-this-code-model-object-does-not-get-set-tp4656005p4656009.html
Sent from the Users forum 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: What is wrong/missing in this code, model object deos not get set

Posted by vineet semwal <vi...@gmail.com>.
use AjaxFormComponentUpdatingBehavior

On Sat, Feb 2, 2013 at 12:18 AM, saty <sa...@gmail.com> wrote:
> I will give it a try just to see if model gets set, but i really cant do that
> in this case as there are other fields in the form that need to be filled
> before submitting the form, is there any other way that just sets the model
> for auto complete field?
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/What-is-wrong-missing-in-this-code-model-object-does-not-get-set-tp4656005p4656007.html
> Sent from the Users forum 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
>



-- 
regards,

Vineet Semwal

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


Re: What is wrong/missing in this code, model object deos not get set

Posted by saty <sa...@gmail.com>.
I will give it a try just to see if model gets set, but i really cant do that
in this case as there are other fields in the form that need to be filled
before submitting the form, is there any other way that just sets the model
for auto complete field?



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/What-is-wrong-missing-in-this-code-model-object-does-not-get-set-tp4656005p4656007.html
Sent from the Users forum 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: What is wrong/missing in this code, model object deos not get set

Posted by Michael Mosmann <mi...@mosmann.de>.
Use AjaxFormSubmitBehavior,not AjaxEventBehavior..

Michael



saty <sa...@gmail.com> schrieb:

>IAutoCompleteRenderer<Broker> renderer = new
>AbstractAutoCompleteTextRenderer<Broker>() 
>		{
>			private static final long serialVersionUID = 1L;
>			@Override
>			protected String getTextValue(Broker object) 
>			{
>				return object.getBrokerCode() +"-" + object.getDescription();		
>			}
>	
>			
>		};
>
>final IModel<Broker> brokerModel = new Model<Broker>();
>final AutoCompleteTextField<Broker> broker = new
>AutoCompleteTextField<Broker>("broker", brokerModel,renderer)
>		{
>			private static final long serialVersionUID = 1L;
>			@Override
>			protected Iterator<Broker> getChoices(String input) 
>			{
>		List<Broker> choices = new ArrayList<Broker>(10);
>            List<Broker> brokers =  getService().getBrokerList();//gets
>brokers
>                for (final Broker brk : brokers)
>                {
>                    final String code = brk.getBrokerCode();
>                if (code.toUpperCase().startsWith(input.toUpperCase()))
>                    {
>                        choices.add(brk);
>                        if (choices.size() == 10)
>                        {
>                            break;
>                        }
>                    }
>                }
>                return choices.iterator();
>			}};
>			
>			form.add(broker);
>			
>			broker.add(new AjaxEventBehavior("onchange")
>			{
>				@Override
>				protected void onEvent(AjaxRequestTarget target) {
>					logger.info("AjaxEventBehavior::onchange:
>"+brokerModel.getObject());
>				//always prints null here???	
>					
>				}				
>				
>			});
>
>Thanks
>
>
>
>--
>View this message in context:
>http://apache-wicket.1842946.n4.nabble.com/What-is-wrong-missing-in-this-code-model-object-deos-not-get-set-tp4656005.html
>Sent from the Users forum 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

-- 
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.