You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by wholalotta <ar...@gmail.com> on 2011/11/11 14:33:27 UTC

DropDownChoice model is not updated when wantOnSelectionChangedNotifications is overriden

Hi,

I want to make a filter to update a table according to selected user.
I am filling a hashmap to retrieve some data from database. To accomplish
that
I overrided "wantOnSelectionChangedNotifications" method. But the problem
is;
when I choose the user1, the model value is updated as it is exptected and
hashmap
is updated. But after that I am choosing user2 but neither the model value
nor hashMap is not updated
and the selectbox is still showing user1..

I put a a breakpoint into propertyModel constructer but it didnt stop there
in debug mode.
Any idea?

Thanks
	
	private HashMap<String, String> criteriaMap= new HashMap<String, String>();
	Criteria criteria = new Criteria();
	
	List userFilter=new ArrayList();
    userFilter.add("user1");
    userFilter.add("user2");

	add(new DropDownChoice("selectByUser", new PropertyModel(criteria,
"userCriteria"),userFilter) {
	@Override
		protected boolean wantOnSelectionChangedNotifications() {
			criteriaMap.put("user",criteria.getUserCriteria());
			return true;
		}
	});
	
	
	public class Criteria implements Serializable{
	
	private String userCriteria;
	
	public String getUserCriteria() {
		return userCriteria;
	}
	public void setUserCriteria(String userCriteria) {
		this.userCriteria = userCriteria;
	}

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-model-is-not-updated-when-wantOnSelectionChangedNotifications-is-overriden-tp4031368p4031368.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: AW: AW: DropDownChoice model is not updated when wantOnSelectionChangedNotifications is overriden

Posted by Sven Meier <sv...@meiers.net>.
Hi,

 >>setResponsePage(FormInput.class);
 > all the model values are reset to default including my
 > selectbox model value...is this normal?

yes, a new instance of the page will be created.

>  I checked the FormInput example..The only difference ...


You should provide a quickstart, so we are able to check what you're 
doing differently.

Best regards
Sven

On 11/12/2011 05:17 PM, wholalotta wrote:
> Yes I checked the FormInput example..The only difference is that example has
> custem dropwdown component which stated in the same class..Also it uses the
> following in onSelectionChanged method..
>
> // force re-render by setting the page to render to the bookmarkable
> // instance, so that the page will be rendered from scratch,
> // re-evaluating the input patterns etc
> setResponsePage(FormInput.class);
>
> When I put this line into my code, it renders the all page and all the model
> values are reset to default including my selectbox model value...is this
> normal?
>
>
> The point is, I used dropdown component hundred times in the forms and didnt
> face any problem like this.
> Because I did not need to override any methods to do some job after
> selecting something..This is the first time I didnt attach this component to
> a form...If I remove these two overriden methods, selectbox model value is
> updated in all selections accordingly..
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-model-is-not-updated-when-wantOnSelectionChangedNotifications-is-overriden-tp4031368p4034763.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
>


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


Re: AW: AW: DropDownChoice model is not updated when wantOnSelectionChangedNotifications is overriden

Posted by wholalotta <ar...@gmail.com>.
Yes I checked the FormInput example..The only difference is that example has
custem dropwdown component which stated in the same class..Also it uses the
following in onSelectionChanged method..

// force re-render by setting the page to render to the bookmarkable
// instance, so that the page will be rendered from scratch,
// re-evaluating the input patterns etc
setResponsePage(FormInput.class);

When I put this line into my code, it renders the all page and all the model
values are reset to default including my selectbox model value...is this
normal?


The point is, I used dropdown component hundred times in the forms and didnt
face any problem like this.
Because I did not need to override any methods to do some job after
selecting something..This is the first time I didnt attach this component to
a form...If I remove these two overriden methods, selectbox model value is
updated in all selections accordingly..



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-model-is-not-updated-when-wantOnSelectionChangedNotifications-is-overriden-tp4031368p4034763.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: AW: AW: DropDownChoice model is not updated when wantOnSelectionChangedNotifications is overriden

Posted by Sven Meier <sv...@meiers.net>.
Have you taken a look at org.apache.wicket.examples.forminput.FormInput ?

On 11/12/2011 10:23 AM, wholalotta wrote:
> Any suggestion?
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-model-is-not-updated-when-wantOnSelectionChangedNotifications-is-overriden-tp4031368p4033965.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
>


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


Re: AW: AW: DropDownChoice model is not updated when wantOnSelectionChangedNotifications is overriden

Posted by wholalotta <ar...@gmail.com>.
Any suggestion?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-model-is-not-updated-when-wantOnSelectionChangedNotifications-is-overriden-tp4031368p4033965.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: AW: AW: DropDownChoice model is not updated when wantOnSelectionChangedNotifications is overriden

Posted by wholalotta <ar...@gmail.com>.
I think I am doing something wrong or there is a bug..newSelection is not
contain the new selected user..like model value..
If I dont override any methods, selectbox model value is updated as it is
expected..

But the the both of them always show the first selection...

new PropertyModel(criteria, "userCriteria") and 
protected void onSelectionChanged(Object newSelection) 




--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-model-is-not-updated-when-wantOnSelectionChangedNotifications-is-overriden-tp4031368p4031578.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: AW: AW: DropDownChoice model is not updated when wantOnSelectionChangedNotifications is overriden

Posted by Martin Grigorov <mg...@apache.org>.
On Fri, Nov 11, 2011 at 4:41 PM, wholalotta <ar...@gmail.com> wrote:
> Ok I am overriding the both methods but still cannot update the
> userCriteria..It always contains the
> the value that I selected first..
>
> new PropertyModel(criteria, "userCriteria")
>
>
> The whole code is as following;
>
> public class ListQuestionsPage extends AdminBasePage {
>
>    @SpringBean
>    UserDao dataDao;
>
>        private HashMap<String, String> criteriaMap= new HashMap<String, String>();
>        Criteria criteria = new Criteria();
>
>        public ListUsersPage() {
>
>                final LoadableDetachableModel data= new LoadableDetachableModel() {
>            @Override
>            protected Object load() {
>                List<Data> dataArrayList =  dataDao.findAll();
>                return dataArrayList;
>            }
>        };
>
>        final WebMarkupContainer listContainer = new
> WebMarkupContainer("listContainer");
>        add(listContainer);
>
>        List userFilter=new ArrayList();
>        userFilter.add("user1");
>        userFilter.add("user2");
>
>        add(new DropDownChoice("selectByUser", new PropertyModel(criteria,
> "userCriteria"),userFilter) {
>                @Override
>                protected boolean wantOnSelectionChangedNotifications() {
>                        return true;
>                }
>
>                @Override
>                protected void onSelectionChanged(Object newSelection) {
>                        criteriaMap.put("user",criteria.getUserCriteria());

You should use the new value here ^^


>                }
>
>        });
>
>        PageableListView userList = new PageableListView("userList",data
> ,10) {
>
>                        @Override
>                        protected void populateItem(final ListItem item) {
>                                final User user = (User) item.getModelObject();
>                                item.add(new Label("id", Long.toString(user.getId())));
>                                item.add(new Label("user", user.getUser().getUsername()));
>                                item.add(new Label("details", user.getDetails()));
>                        }
>                };
>        listContainer.add(userList);
>        add(new PagingNavigator("navigator",questionList));
>        }
> }
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-model-is-not-updated-when-wantOnSelectionChangedNotifications-is-overriden-tp4031368p4031523.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
>
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

Re: AW: AW: DropDownChoice model is not updated when wantOnSelectionChangedNotifications is overriden

Posted by wholalotta <ar...@gmail.com>.
Ok I am overriding the both methods but still cannot update the
userCriteria..It always contains the
the value that I selected first..

new PropertyModel(criteria, "userCriteria")


The whole code is as following;

public class ListQuestionsPage extends AdminBasePage {

    @SpringBean
    UserDao dataDao;
    
	private HashMap<String, String> criteriaMap= new HashMap<String, String>();
	Criteria criteria = new Criteria();

	public ListUsersPage() {
		
		final LoadableDetachableModel data= new LoadableDetachableModel() { 
            @Override 
            protected Object load() { 
                List<Data> dataArrayList =  dataDao.findAll(); 
                return dataArrayList; 
            } 
        };
        
        final WebMarkupContainer listContainer = new
WebMarkupContainer("listContainer");
        add(listContainer);
        
        List userFilter=new ArrayList();
        userFilter.add("user1");
        userFilter.add("user2");
        
        add(new DropDownChoice("selectByUser", new PropertyModel(criteria,
"userCriteria"),userFilter) {
        	@Override
        	protected boolean wantOnSelectionChangedNotifications() {
        		return true;
        	}
        	
		@Override
		protected void onSelectionChanged(Object newSelection) {
			criteriaMap.put("user",criteria.getUserCriteria());
		}

        });
                   
        PageableListView userList = new PageableListView("userList",data
,10) {

			@Override
			protected void populateItem(final ListItem item) {
				final User user = (User) item.getModelObject();
				item.add(new Label("id", Long.toString(user.getId())));
				item.add(new Label("user", user.getUser().getUsername()));
				item.add(new Label("details", user.getDetails()));				
			}
		};
        listContainer.add(userList);
        add(new PagingNavigator("navigator",questionList));
	}
}


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-model-is-not-updated-when-wantOnSelectionChangedNotifications-is-overriden-tp4031368p4031523.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


AW: AW: DropDownChoice model is not updated when wantOnSelectionChangedNotifications is overriden

Posted by Sven Meier <sv...@meiers.net>.
See org.apache.wicket.examples.forminput.FormInput, you need to override
both methods.

Sven

-----Ursprüngliche Nachricht-----
Von: wholalotta [mailto:ardaaskin@gmail.com] 
Gesendet: Freitag, 11. November 2011 14:55
An: users@wicket.apache.org
Betreff: Re: AW: DropDownChoice model is not updated when
wantOnSelectionChangedNotifications is overriden

Thanks for the quick response Sven...But eclipse gives error for the code
you
suggested
I changed it as below;

       @Override
	protected void onSelectionChanged(Object criteria) {
		criteriaMap.put("user",((Criteria)
criteria).getUserCriteria());
	}

But using onSelectionChanged does not render the page..I need to reload
table data from database
according to the choice is made in selectBox..Because of that I used
"wantOnSelectionChangedNotifications"


        final LoadableDetachableModel data= new LoadableDetachableModel() {
            @Override
            protected Object load() {
                List<Data> dataArrayList =  dataDao.findAll();
                return dataArrayList;
            }
        };

--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-model-is-not-updat
ed-when-wantOnSelectionChangedNotifications-is-overriden-tp4031368p4031416.h
tml
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



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


Re: AW: DropDownChoice model is not updated when wantOnSelectionChangedNotifications is overriden

Posted by wholalotta <ar...@gmail.com>.
Thanks for the quick response Sven...But eclipse gives error for the code you
suggested
I changed it as below;

       @Override
	protected void onSelectionChanged(Object criteria) {
		criteriaMap.put("user",((Criteria) criteria).getUserCriteria());
	}

But using onSelectionChanged does not render the page..I need to reload
table data from database
according to the choice is made in selectBox..Because of that I used
"wantOnSelectionChangedNotifications"


        final LoadableDetachableModel data= new LoadableDetachableModel() {
            @Override
            protected Object load() {
                List<Data> dataArrayList =  dataDao.findAll();
                return dataArrayList;
            }
        };

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-model-is-not-updated-when-wantOnSelectionChangedNotifications-is-overriden-tp4031368p4031416.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


AW: DropDownChoice model is not updated when wantOnSelectionChangedNotifications is overriden

Posted by Sven Meier <sv...@meiers.net>.
protected void onSelectionChanged(final Criteria criteria)
{
	criteriaMap.put("user",criteria.getUserCriteria());
}


-----Ursprüngliche Nachricht-----
Von: wholalotta [mailto:ardaaskin@gmail.com] 
Gesendet: Freitag, 11. November 2011 14:33
An: users@wicket.apache.org
Betreff: DropDownChoice model is not updated when
wantOnSelectionChangedNotifications is overriden

Hi,

I want to make a filter to update a table according to selected user.
I am filling a hashmap to retrieve some data from database. To accomplish
that
I overrided "wantOnSelectionChangedNotifications" method. But the problem
is;
when I choose the user1, the model value is updated as it is exptected and
hashmap
is updated. But after that I am choosing user2 but neither the model value
nor hashMap is not updated
and the selectbox is still showing user1..

I put a a breakpoint into propertyModel constructer but it didnt stop there
in debug mode.
Any idea?

Thanks
	
	private HashMap<String, String> criteriaMap= new HashMap<String,
String>();
	Criteria criteria = new Criteria();
	
	List userFilter=new ArrayList();
    userFilter.add("user1");
    userFilter.add("user2");

	add(new DropDownChoice("selectByUser", new PropertyModel(criteria,
"userCriteria"),userFilter) {
	@Override
		protected boolean wantOnSelectionChangedNotifications() {
			criteriaMap.put("user",criteria.getUserCriteria());
			return true;
		}
	});
	
	
	public class Criteria implements Serializable{
	
	private String userCriteria;
	
	public String getUserCriteria() {
		return userCriteria;
	}
	public void setUserCriteria(String userCriteria) {
		this.userCriteria = userCriteria;
	}

--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-model-is-not-updat
ed-when-wantOnSelectionChangedNotifications-is-overriden-tp4031368p4031368.h
tml
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



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