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

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

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

kshitiz
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...
Reply | Threaded
Open this post in threaded view
|

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

Martin Makundi
Did you look at wicket ajax debugin browser? It usually gives quite
good clues about what's missing ...

2012/6/9 kshitiz <[hidden email]>:

> 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

kshitiz
I have never tried out that before....I have enabled debug mode but I to debug the ajax part? Can you please tell me ??
Reply | Threaded
Open this post in threaded view
|

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

Martin Makundi
Ajax debug is a small hover window visible in browser when you have
application configuration in development mode.

**
Martin


2012/6/9 kshitiz <[hidden email]>:

> 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

kshitiz
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?
Reply | Threaded
Open this post in threaded view
|

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

Martin Makundi
Listview has this parameter reuseitems, if you set it to false it will
rebuild when its container is refreshed.

2012/6/9 kshitiz <[hidden email]>:

> 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

kshitiz
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...
Reply | Threaded
Open this post in threaded view
|

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

Martin Makundi
clearinput can be used with forms when submit is not done but model is changed

**
Martin

2012/6/9 kshitiz <[hidden email]>:

> 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

kshitiz
This post was updated on .
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) {

                                listItem.add(userName);
                        }

                };

                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) {

                        }

                };

                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);
                        }
                });
        }

}