You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by kshitiz <k....@gmail.com> on 2012/06/09 13:10:45 UTC

Ajax refresh not working in a case .... while working in similar other cases!!!

Hi,

I am trying to refresh ajax container after firing an event. The code is:

*final WebMarkupContainer searchContainer = new WebMarkupContainer(
				"searchContainer");
		searchContainer.setOutputMarkupId(true);*


AjaxFallbackButton ajaxSearchButton = new AjaxFallbackButton(
				"searchButton", searchForm) {

			@Override
			public void onSubmit(AjaxRequestTarget target, final Form<?> form) {
				if (target != null) {

					try {
                                                 // some actions...
					} catch (Exception exception) {
					}
					*target.add(searchContainer);*
				}
			}
}


Label userLabel = new Label("userLabel", "List of Users");
		Label numberOfUserLabel = new Label("numberOfUserLabel", new Integer(
				numberOfUsers).toString());

		final PageableListView<UserDomain> userDomainListView = new
PageableListView<UserDomain>(
				"user", userDomainList, resultsPerPage) {
			private static final long serialVersionUID = 1L;

			@Override
			protected void populateItem(final ListItem<UserDomain> listItem) {
			// populating list
			}

		};

*		userDomainListView.setVisible(!userDomainList.isEmpty());
		userLabel.setVisible(!userDomainList.isEmpty());
		numberOfUserLabel.setVisible(!userDomainList.isEmpty());

		searchContainer.add(userLabel);
		searchContainer.add(userDomainListView);
		searchContainer.add(numberOfUserLabel);
*

But the list view is not getting refreshed? I am using the same technique in
other pages and it is working.. what be the reason..?? Any suggestion can
work for me...

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Ajax-refresh-not-working-in-a-case-while-working-in-similar-other-cases-tp4649794.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: Ajax refresh not working in a case .... while working in similar other cases!!!

Posted by kshitiz <k....@gmail.com>.
I am able to solve this field related problem...just container is not getting
refreshed...

here is the code, I have modified a bit as per requirement:

public Search(String id) {

searchContainer.add(searchForm);
		searchContainer.add(new SearchResultPanel("searchResultPanel",
				searchDomain, error, searchContainer));
		add(searchContainer);
}

	public SearchResultPanel(String id, SearchDomain searchDomain, final
WebMarkupContainer searchContainer) {
		super(id);
		
		List<UserDomain> userDomainList = new ArrayList<UserDomain>();
		List<OrganizationDomain> organizationDomainList = new
ArrayList<OrganizationDomain>();

                userDomainList = searchDomain.getUserDomainList();

		organizationDomainList = searchDomain.getOrganizationDomainList();
		
		int numberOfUsers = searchDomain.getNumberOfUsers();

		Label userLabel = new Label("userLabel", "List of Users");
		Label numberOfUserLabel = new Label("numberOfUserLabel", new Integer(
				numberOfUsers).toString());

		final PageableListView<UserDomain> userDomainListView = new
PageableListView<UserDomain>(
				"user", userDomainList, resultsPerPage) {
			private static final long serialVersionUID = 1L;

			@Override
			protected void populateItem(final ListItem<UserDomain> listItem) {

				String name = ((UserDomain) listItem.getModelObject())
						.getName();
				Label userName = new Label("userName", name);
				listItem.add(userName);
			}

		};

		userDomainListView.setVisible(!userDomainList.isEmpty());
		userLabel.setVisible(!userDomainList.isEmpty());
		numberOfUserLabel.setVisible(!userDomainList.isEmpty());

		add(userLabel);
		add(userDomainListView);
		add(numberOfUserLabel);

		int numberOfOrganization = searchDomain.getNumberOfOrganizations();

		Label organizationLabel = new Label("organizationLabel",
				"List of Organizations");
		Label numberOfOrganizationLabel = new Label(
				"numberOfOrganizationLabel",
				new Integer(numberOfOrganization).toString());

		final ListView<OrganizationDomain> organizationDomainListView = new
ListView<OrganizationDomain>(
				"organization", organizationDomainList) {
			private static final long serialVersionUID = 1L;

			@Override
			protected void populateItem(
					final ListItem<OrganizationDomain> listItem) {

				String organization = ((OrganizationDomain) listItem
						.getModelObject()).getOrganization();
				Label organizationName = new Label("organizationName",
						organization);
				listItem.add(organizationName);
			}

		};

		organizationDomainListView
				.setVisible(!organizationDomainList.isEmpty());
		organizationLabel.setVisible(!organizationDomainList.isEmpty());
		numberOfOrganizationLabel.setVisible(!organizationDomainList.isEmpty());

		add(organizationLabel);
		add(organizationDomainListView);
		add(numberOfOrganizationLabel);

		add(new AjaxPagingNavigator("navigator",
				userDomainListView) {

			/**
				 * 
				 */
			private static final long serialVersionUID = 1L;

			@Override
			protected void onAjaxEvent(AjaxRequestTarget target) {
				target.addComponent(searchContainer);
			}
		});
	}

}



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Ajax-refresh-not-working-in-a-case-while-working-in-similar-other-cases-tp4649794p4649806.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: Ajax refresh not working in a case .... while working in similar other cases!!!

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
clearinput can be used with forms when submit is not done but model is changed

**
Martin

2012/6/9 kshitiz <k....@gmail.com>:
> Okk...actually when I analysed more, what  I found is that when I enter new
> value in text field, the event takes the old value only. Even I am now
> refreshing the form too. Then I found that the field sets its value to old
> one after getting refreshed. My field is of final  type. But that should not
> be the problem as I am using the same technique in other pages too...
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Ajax-refresh-not-working-in-a-case-while-working-in-similar-other-cases-tp4649794p4649802.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: Ajax refresh not working in a case .... while working in similar other cases!!!

Posted by kshitiz <k....@gmail.com>.
Okk...actually when I analysed more, what  I found is that when I enter new
value in text field, the event takes the old value only. Even I am now
refreshing the form too. Then I found that the field sets its value to old
one after getting refreshed. My field is of final  type. But that should not
be the problem as I am using the same technique in other pages too...

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Ajax-refresh-not-working-in-a-case-while-working-in-similar-other-cases-tp4649794p4649802.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: Ajax refresh not working in a case .... while working in similar other cases!!!

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
Listview has this parameter reuseitems, if you set it to false it will
rebuild when its container is refreshed.

2012/6/9 kshitiz <k....@gmail.com>:
> I got the problem atleast...what is happening that it is using the same
> search object (where results are being stored and then displayed in
> container) and not creating the new one for new searches. Actually what I
> want is when user searches anything, the results are refreshed only. I am
> storing the results in an object and displaying them using listview which is
> again a part of container. Can you suggest me anything out here?
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Ajax-refresh-not-working-in-a-case-while-working-in-similar-other-cases-tp4649794p4649799.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: Ajax refresh not working in a case .... while working in similar other cases!!!

Posted by kshitiz <k....@gmail.com>.
I got the problem atleast...what is happening that it is using the same
search object (where results are being stored and then displayed in
container) and not creating the new one for new searches. Actually what I
want is when user searches anything, the results are refreshed only. I am
storing the results in an object and displaying them using listview which is
again a part of container. Can you suggest me anything out here?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Ajax-refresh-not-working-in-a-case-while-working-in-similar-other-cases-tp4649794p4649799.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: Ajax refresh not working in a case .... while working in similar other cases!!!

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
Ajax debug is a small hover window visible in browser when you have
application configuration in development mode.

**
Martin


2012/6/9 kshitiz <k....@gmail.com>:
> I have never tried out that before....I have enabled debug mode but I to
> debug the ajax part? Can you please tell me ??
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Ajax-refresh-not-working-in-a-case-while-working-in-similar-other-cases-tp4649794p4649797.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: Ajax refresh not working in a case .... while working in similar other cases!!!

Posted by kshitiz <k....@gmail.com>.
I have never tried out that before....I have enabled debug mode but I to
debug the ajax part? Can you please tell me ??

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Ajax-refresh-not-working-in-a-case-while-working-in-similar-other-cases-tp4649794p4649797.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: Ajax refresh not working in a case .... while working in similar other cases!!!

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
Did you look at wicket ajax debugin browser? It usually gives quite
good clues about what's missing ...

2012/6/9 kshitiz <k....@gmail.com>:
> Hi,
>
> I am trying to refresh ajax container after firing an event. The code is:
>
> *final WebMarkupContainer searchContainer = new WebMarkupContainer(
>                                "searchContainer");
>                searchContainer.setOutputMarkupId(true);*
>
>
> AjaxFallbackButton ajaxSearchButton = new AjaxFallbackButton(
>                                "searchButton", searchForm) {
>
>                        @Override
>                        public void onSubmit(AjaxRequestTarget target, final Form<?> form) {
>                                if (target != null) {
>
>                                        try {
>                                                 // some actions...
>                                        } catch (Exception exception) {
>                                        }
>                                        *target.add(searchContainer);*
>                                }
>                        }
> }
>
>
> Label userLabel = new Label("userLabel", "List of Users");
>                Label numberOfUserLabel = new Label("numberOfUserLabel", new Integer(
>                                numberOfUsers).toString());
>
>                final PageableListView<UserDomain> userDomainListView = new
> PageableListView<UserDomain>(
>                                "user", userDomainList, resultsPerPage) {
>                        private static final long serialVersionUID = 1L;
>
>                        @Override
>                        protected void populateItem(final ListItem<UserDomain> listItem) {
>                        // populating list
>                        }
>
>                };
>
> *               userDomainListView.setVisible(!userDomainList.isEmpty());
>                userLabel.setVisible(!userDomainList.isEmpty());
>                numberOfUserLabel.setVisible(!userDomainList.isEmpty());
>
>                searchContainer.add(userLabel);
>                searchContainer.add(userDomainListView);
>                searchContainer.add(numberOfUserLabel);
> *
>
> But the list view is not getting refreshed? I am using the same technique in
> other pages and it is working.. what be the reason..?? Any suggestion can
> work for me...
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Ajax-refresh-not-working-in-a-case-while-working-in-similar-other-cases-tp4649794.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