You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "N. Metzger" <nm...@odu.edu> on 2013/03/15 19:04:43 UTC

PageableListView item removal

Hi all,

I'm looking at a strange behavior of my PageableListView. 

I have a PageableListView with an AjaxPagingNavigator within a
WebMarkupContainer. Recently I added an AjaxLink to the list view that
removes an element from the underlying list. The view refreshes, but takes
off the first(!) element of the list view instead of the element that was
really deleted. If I refresh the whole page, the view displays correctly.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/PageableListView-item-removal-tp4657283.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: PageableListView item removal

Posted by "N. Metzger" <nm...@odu.edu>.
Also, the ajax timer on the markup container stops after I hit the
removeLink. 



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/PageableListView-item-removal-tp4657283p4657291.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: PageableListView item removal

Posted by "N. Metzger" <nm...@odu.edu>.
I wasn't using the "setReuseItems" property at all, but tried to set it to
false: no change. Here's the code:

     serviceContainer = new WebMarkupContainer("serviceData");
            serviceContainer.setOutputMarkupId(true);
            serviceContainer.add(new
AjaxSelfUpdatingTimerBehavior(Duration.seconds(15)){
              protected void onPostProcessTarget(AjaxRequestTarget target){
                  try {
                      services =
administrationService.updateServices(uniqueId, midm, userMidm);
                      logger.debug("{}:{}: Services refreshed for user " +
username, uniqueId, midm);
                      updateCounter ++;
                      //stop update after 15 minutes
                      if (updateCounter > 60){
                          logger.debug("{}:{}: Stopped service self updating
behavior", uniqueId, midm);
                          stop(target);
                      }
                          
                  } catch (Exception e) {
                      logger.debug("{}:{}: Unable to refresh the service
view for user " + username, 
                                   uniqueId, midm);
                      warn("The system is unable to refresh the service
view. Please reload the user.");
                  }
                  target.add(feedback);
              }
            });
            
            PageableListView<Service> serviceList = new
PageableListView<Service>("serviceList", 
                                                                new
PropertyModel<List&lt;Service>>(ServicesTabPanel.this, "services"), 
                                                               
ELEMENTS_PER_PAGE) {
                @Override
                protected void populateItem(ListItem<Service> item) {
                    final Service service = item.getModelObject();
                    final String serviceType = service.getServiceType();
                    
                    item.add(new Label("serviceType", new
PropertyModel(item.getModel(), "serviceType")));
                    item.add(new Label("login", new
PropertyModel(item.getModel(), "serviceLogin")));
                    item.add(new Label("context", new
PropertyModel(item.getModel(), "serviceContext")));
                    item.add(new Label("status", new
PropertyModel(item.getModel(), "accountStatusWebString")));
                    item.add(new Label("syncDate", new
PropertyModel(item.getModel(), "timestamp")));
                    item.add(new Label("expireDate", new
PropertyModel(item.getModel(), "serviceExpireDate")));
                    
                    if (service.isIntegrable())
                        item.add(new Label("integratable", "true"));
                    else
                        item.add(new Label("integratable", "false"));
                    
                    if (service.isIntegrated())
                        item.add(new Label("integrated", "true"));
                    else
                        item.add(new Label("integrated", "false"));
                    
                    item.add(new AjaxLink("syncButton"){
                        public void onClick(AjaxRequestTarget target) {
                            try {
                                logger.info("{}:{}: Synchonizing " +
serviceType + " services for " + userMidm, uniqueId, midm);
                               
administrationService.syncMidasUserService(uniqueId, midm, userMidm,
serviceType);
                                success("Synchronized Service
"+serviceType);
                            } catch (Exception e) {
                                logger.error(uniqueId + ": Caught an
exception during admin sync service " + serviceType, e);
                                error("An error occurred while trying to
synchronize service " + serviceType);            
                            }
                            target.add(feedback, serviceContainer);
                        }
                    });
                    addRemoveServiceLink(item, service);    
                }
                
                private void addRemoveServiceLink(ListItem item, final
Service service){
                    AjaxLink removeServiceLink = new
AjaxLink("removeServiceLink"){
                        public void onClick(AjaxRequestTarget target) {
                            int userMidm = service.getMidm();
                            try {    
                               
administrationService.removeServiceFromUser(uniqueId, midm, userMidm,
service);
                                success("Successfully removed service " +
service.getServiceType() + 
                                        "(login " +
service.getServiceLogin() +") from current user.");
                                services.remove(service);
                            } 
                            catch (UnavailableDataSourceException e) {
                                error("A database error occurred while
trying to remove the service " + service);
                            }
                            target.add(feedback, serviceContainer);
                        }
                    };
                    if (!isAccountChangePermitted)
                        removeServiceLink.setVisible(false);
                    item.add(removeServiceLink);
                }
            };
            serviceContainer.add(serviceList);
            
            AjaxPagingNavigator serviceNavigator = new
AjaxPagingNavigator("serviceNavigator", serviceList);
            if (services.size() > ELEMENTS_PER_PAGE)
                serviceNavigator.setVisible(true);
            else
                serviceNavigator.setVisible(false);
            serviceContainer.add(serviceNavigator);
            add(serviceContainer);



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/PageableListView-item-removal-tp4657283p4657290.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: PageableListView item removal

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

you're probably using #setReuseItems(true) ?

Show us your #populateItem() please.

Sven

On 03/15/2013 07:04 PM, N. Metzger wrote:
> Hi all,
>
> I'm looking at a strange behavior of my PageableListView.
>
> I have a PageableListView with an AjaxPagingNavigator within a
> WebMarkupContainer. Recently I added an AjaxLink to the list view that
> removes an element from the underlying list. The view refreshes, but takes
> off the first(!) element of the list view instead of the element that was
> really deleted. If I refresh the whole page, the view displays correctly.
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/PageableListView-item-removal-tp4657283.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