Package org.apache.wicket.markup.html.link

Examples of org.apache.wicket.markup.html.link.AbstractLink


    }

    @Override
    public LinkAndLabel newLink(final ObjectAdapterMemento serviceAdapterMemento, final ObjectAction objectAction, final String linkId) {
        final ActionMemento actionMemento = new ActionMemento(objectAction);
        final AbstractLink link = new Link<Object>(linkId) {
           
            private static final long serialVersionUID = 1L;

            @Override
            public void onClick() {
                final ObjectAction objectAction = actionMemento.getAction();
                final ConcurrencyChecking concurrencyChecking =
                        ConcurrencyChecking.concurrencyCheckingFor(objectAction.getSemantics());

                try {
                    final List<ObjectAdapterMemento> toggleMementosList = model.getToggleMementosList();

                    final Iterable<ObjectAdapter> toggledAdapters =
                            Iterables.transform(toggleMementosList, ObjectAdapterMemento.Functions.fromMemento(concurrencyChecking));
                   
                    final List<Object> domainObjects = Lists.newArrayList(Iterables.transform(toggledAdapters, ObjectAdapter.Functions.getObject()));
                   
                    try {
                        final Bulk.InteractionContext interactionContext = new Bulk.InteractionContext(domainObjects);
                        Bulk.InteractionContext.current.set(interactionContext);
                        int i=0;
                        for(final ObjectAdapter adapter : toggledAdapters) {
       
                            int numParameters = objectAction.getParameterCount();
                            if(numParameters != 0) {
                                return;
                            }
                            interactionContext.setIndex(i++);
                            objectAction.execute(adapter, new ObjectAdapter[]{});
                        }
                    } finally {
                        Bulk.InteractionContext.current.set(null);
                    }
                   
                    model.clearToggleMementosList();
                    final ActionModel actionModelHint = model.getActionModelHint();
                    if(actionModelHint != null) {
                        ObjectAdapter resultAdapter = actionModelHint.getObject();
                        model.setObjectList(resultAdapter);
                    } else {
                        model.setObject(persistentAdaptersWithin(model.getObject()));
                    }

                } catch(final ConcurrencyException ex) {
                   
                    // resync with the objectstore
                    final List<ObjectAdapterMemento> toggleMementosList = Lists.newArrayList(model.getToggleMementosList());
                    for (ObjectAdapterMemento oam : toggleMementosList) {
                        // just requesting the adapter will sync the OAM's version with the objectstore
                        oam.getObjectAdapter(ConcurrencyChecking.NO_CHECK);
                    }
                   
                    // discard any adapters that might have been deleted
                    model.setObject(persistentAdaptersWithin(model.getObject()));
                   
                    // attempt to preserve the toggled adapters
                    final List<ObjectAdapter> adapters = model.getObject();
                    model.clearToggleMementosList();
                    for (ObjectAdapterMemento oam : toggleMementosList) {
                        final ObjectAdapter objectAdapter = oam.getObjectAdapter(ConcurrencyChecking.NO_CHECK);
                        if(adapters.contains(objectAdapter)) {
                            // in case it has been deleted...
                            model.toggleSelectionOn(objectAdapter);
                        }
                    }
                   
                    // display a warning to the user so that they know that the action wasn't performed
                    getMessageBroker().addWarning(ex.getMessage());
                    return;
                }
            }

            private List<ObjectAdapter> persistentAdaptersWithin(List<ObjectAdapter> adapters) {
                return Lists.newArrayList(Iterables.filter(adapters, new Predicate<ObjectAdapter>() {
                    @Override
                    public boolean apply(ObjectAdapter input) {
                        return !input.isTransient() && !input.isDestroyed();
                    }
                }));
            }

        };
        link.add(new JGrowlBehaviour());
        final boolean explorationOrPrototype = CssMenuItem.isExplorationOrPrototype(objectAction);
        final String actionIdentifier = CssMenuItem.actionIdentifierFor(objectAction);
        final String cssClass = CssMenuItem.cssClassFor(objectAction);

        return new LinkAndLabel(link, objectAction.getName(), null, false, explorationOrPrototype, actionIdentifier, cssClass);
View Full Code Here


    public LinkAndLabel newLink(final ObjectAdapterMemento adapterMemento, final ObjectAction action, final String linkId) {
        final PageParameters pageParameters = ActionModel.createPageParameters(adapterMemento.getObjectAdapter(ConcurrencyChecking.NO_CHECK), action, null, ActionModel.SingleResultsMode.REDIRECT, ConcurrencyChecking.NO_CHECK);

        final Class<? extends Page> pageClass = getPageClassRegistry().getPageClass(PageType.ACTION);

        final AbstractLink link = Links.newBookmarkablePageLink(linkId, pageParameters, pageClass);
        final String actionLabel = ObjectActions.nameFor(action);

        final boolean blobOrClob = CssMenuItem.returnsBlobOrClob(action);
        final boolean prototype = CssMenuItem.isExplorationOrPrototype(action);
        final String actionIdentifier = CssMenuItem.actionIdentifierFor(action);
View Full Code Here

      submitForm(submitLink.getForm().getPageRelativePath());
    }
    // if the link is a normal link (or ResourceLink)
    else if (linkComponent instanceof AbstractLink)
    {
      AbstractLink link = (AbstractLink)linkComponent;

      /*
       * If the link is a bookmarkable link, then we need to transfer the parameters to the
       * next request.
       */
 
View Full Code Here

  {
    // Get the index of page this link shall point to
    final long pageIndex = getStartIndex() + loopItem.getIndex();

    // Add a page link pointing to the page
    final AbstractLink link = newPagingNavigationLink("pageLink", pageable, pageIndex);
    link.add(new TitleAppender(pageIndex));
    loopItem.add(link);

    // Add a page number label to the list which is enclosed by the link
    String label = "";
    if (labelProvider != null)
    {
      label = labelProvider.getPageLabel(pageIndex);
    }
    else
    {
      label = String.valueOf(pageIndex + 1);
    }
    link.add(new Label("pageNumber", label));
  }
View Full Code Here

      private static final long serialVersionUID = 1L;

      @Override
      protected void populateItem(ListItem<PivotFieldAction> item) {
        PivotFieldAction action = item.getModelObject();
        AbstractLink link = action.getLink("link");
//        link.add(new Image("image", action.getImage()));
//        link.add(AttributeModifier.replace("title", action.getTooltip()));
        link.add(new Label("name", action.getName()));
        item.add(link);
      }

    };
    dropDownContainer.add(actionsView);   
View Full Code Here

      submitForm(submitLink.getForm().getPageRelativePath());
    }
    // if the link is a normal link (or ResourceLink)
    else if (linkComponent instanceof AbstractLink)
    {
      AbstractLink link = (AbstractLink)linkComponent;

      /*
       * If the link is a bookmarkable link, then we need to transfer the parameters to the
       * next request.
       */
 
View Full Code Here

      requestCycle.detach();
    }
    // if the link is a normal link (or ResourceLink)
    else if (linkComponent instanceof AbstractLink)
    {
      AbstractLink link = (AbstractLink)linkComponent;

      /*
       * If the link is a bookmarkable link, then we need to transfer the parameters to the
       * next request.
       */
 
View Full Code Here

      submitForm(submitLink.getForm().getPageRelativePath());
    }
    // if the link is a normal link (or ResourceLink)
    else if (linkComponent instanceof AbstractLink)
    {
      AbstractLink link = (AbstractLink)linkComponent;

      /*
       * If the link is a bookmarkable link, then we need to transfer the parameters to the
       * next request.
       */
 
View Full Code Here

  {
    // Get the index of page this link shall point to
    final int pageIndex = getStartIndex() + loopItem.getIndex();

    // Add a page link pointing to the page
    final AbstractLink link = newPagingNavigationLink("pageLink", pageable, pageIndex);
    link.add(new TitleAppender(pageIndex));
    loopItem.add(link);

    // Add a page number label to the list which is enclosed by the link
    String label = "";
    if (labelProvider != null)
    {
      label = labelProvider.getPageLabel(pageIndex);
    }
    else
    {
      label = String.valueOf(pageIndex + 1);
    }
    link.add(new Label("pageNumber", label));
  }
View Full Code Here

      submitForm(submitLink.getForm().getPageRelativePath());
    }
    // if the link is a normal link (or ResourceLink)
    else if (linkComponent instanceof AbstractLink)
    {
      AbstractLink link = (AbstractLink)linkComponent;

      /*
       * If the link is a bookmarkable link, then we need to transfer the parameters to the
       * next request.
       */
 
View Full Code Here

TOP

Related Classes of org.apache.wicket.markup.html.link.AbstractLink

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.