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

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


  }
 
 
  @Test
  public void testSayHiPage() {
    final AbstractLink link = WicketTesterUtils.findLink(tester, componentId);
    Assert.assertNotNull("Link \"" + componentId + "\" not found", link);
   
    tester.clickLink(link.getPageRelativePath());
    tester.assertRenderedPage(PAGE_TO_TEST);
  }
View Full Code Here


    tester.assertRenderedPage(RedirectPage.class);
  }
 
  private void clickToggleLink() {
    final String componentId = "toggleGatherExtendedBrowserInfo";
    final AbstractLink link = WicketTesterUtils.findLink(tester, componentId);
    Assert.assertNotNull("Link \"" + componentId + "\" not found", link);
   
    tester.clickLink(link.getPageRelativePath());
  }
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

      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

      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

                protected void populateItem(ListItem<ComponentFactory> item) {
                   
                    final int underlyingViewNum = item.getIndex();
                   
                    final ComponentFactory componentFactory = item.getModelObject();
                    final AbstractLink link = new AjaxLink<Void>(ID_VIEW_LINK) {
                        private static final long serialVersionUID = 1L;
                        @Override
                        public void onClick(AjaxRequestTarget target) {
                            LinksSelectorPanelAbstract<T> linksSelectorPanel = LinksSelectorPanelAbstract.this;
                            linksSelectorPanel.setViewHintAndBroadcast(underlyingViewNum, target);
                           
                            final T dummyModel = dummyOf(model);
                            for(int i=0; i<MAX_NUM_UNDERLYING_VIEWS; i++) {
                                final Component component = underlyingViews[i];
                                if(component == null) {
                                    continue;
                                }
                                final boolean isSelected = i == underlyingViewNum;
                                applyCssVisibility(component, isSelected);
                                component.setDefaultModel(isSelected? model: dummyModel);
                            }
                           
                            selectorPanel.selectedComponentFactory = componentFactory;
                            selectorPanel.selectedComponent = underlyingViews[underlyingViewNum];
                            selectorPanel.onSelect(target);
                            target.add(selectorPanel, views);
                        }
                    };
                    String name = nameFor(componentFactory);
                    Label viewTitleLabel = new Label(ID_VIEW_TITLE, name);
                    viewTitleLabel.add(new CssClassAppender(StringExtensions.asLowerDashed(name)));
                    link.add(viewTitleLabel);
                    item.add(link);
                   
                    link.setEnabled(componentFactory != selectorPanel.selectedComponentFactory);
                }

                private String nameFor(final ComponentFactory componentFactory) {
                    return componentFactory instanceof CollectionContentsAsUnresolvedPanelFactory ? "hide" : componentFactory.getName();
                }
View Full Code Here

            final ObjectAction objectAction,
            final String linkId,
            final ActionPromptProvider actionPromptModalWindowProvider) {
       
        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()));
                   
                   
                    final Bulk.InteractionContext bulkInteractionContext = Bulk.InteractionContext.current.get();
                    if (bulkInteractionContext != null) {
                        bulkInteractionContext.setInvokedAs(InvokedAs.BULK);
                        bulkInteractionContext.setDomainObjects(domainObjects);
                    }
                   
                    final CommandContext commandContext = getServicesInjector().lookupService(CommandContext.class);
                    final Command command;
                    if (commandContext != null) {
                        command = commandContext.getCommand();
                        command.setExecutor(Executor.USER);
                    } else {
                        command = null;
                    }


                    ObjectAdapter lastReturnedAdapter = null;
                    int i=0;
                    for(final ObjectAdapter adapter : toggledAdapters) {
   
                        int numParameters = objectAction.getParameterCount();
                        if(numParameters != 0) {
                            return;
                        }
                        if (bulkInteractionContext != null) {
                            bulkInteractionContext.setIndex(i++);
                        }
                        lastReturnedAdapter = objectAction.execute(adapter, new ObjectAdapter[]{});
                    }
                   
                    model.clearToggleMementosList();
                    toggleboxColumn.clearToggles();
                    final ActionModel actionModelHint = model.getActionModelHint();
                    if(actionModelHint != null && actionModelHint.getActionMemento().getAction().getSemantics().isIdempotentInNature()) {
                        ObjectAdapter resultAdapter = actionModelHint.getObject();
                        model.setObjectList(resultAdapter);
                    } else {
                        model.setObject(persistentAdaptersWithin(model.getObject()));
                    }
                   
                    if(lastReturnedAdapter != null) {
                        final ActionResultResponse resultResponse =
                                ActionResultResponseType.determineAndInterpretResult(actionModelHint, null, lastReturnedAdapter);
                        resultResponse.getHandlingStrategy().handleResults(this, resultResponse);
                    }

                } catch(final ConcurrencyException ex) {
                   
                    recover();
                    // display a warning to the user so that they know that the action wasn't performed
                    getMessageBroker().addWarning(ex.getMessage());
                    return;

                } catch(final RuntimeException ex) {
                   
                    final RecoverableException appEx = ActionModel.getApplicationExceptionIfAny(ex);
                    if (appEx != null) {

                        recover();
                       
                        getMessageBroker().setApplicationError(appEx.getMessage());
                       
                        // there's no need to abort the transaction, it will have already been done
                        // (in IsisTransactionManager#executeWithinTransaction(...)).
                        return;
                    }
                    throw ex;
                }
            }
           
            private void recover() {
                // 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);
                    }
                }
            }

            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

    }

    private AbstractLink createSubscribingLink(UiHintContainer uiHintContainer) {
        if(uiHintContainer == null || !(uiHintContainer instanceof EntityModel)) {
            // return a no-op
            AbstractLink link = new AbstractLink(ID_SUBSCRIBING_LINK) {
                private static final long serialVersionUID = 1L;
            };
            return link;
        } else {
            final EntityModel entityModel = (EntityModel) uiHintContainer;
View Full Code Here

            @Override
            protected void populateItem(ListItem<LinkAndLabel> item) {
                final LinkAndLabel linkAndLabel = item.getModelObject();
               
                final AbstractLink link = linkAndLabel.getLink();

                Label viewTitleLabel = new Label(ID_ADDITIONAL_LINK_TITLE, linkAndLabel.getLabel());
                String disabledReasonIfAny = linkAndLabel.getDisabledReasonIfAny();
                if(disabledReasonIfAny != null) {
                    viewTitleLabel.add(new AttributeAppender("title", disabledReasonIfAny));
                }
                if(linkAndLabel.isBlobOrClob()) {
                    link.add(new CssClassAppender("noVeil"));
                }
                if(linkAndLabel.isPrototype()) {
                    link.add(new CssClassAppender("prototype"));
                }
                link.add(new CssClassAppender(linkAndLabel.getActionIdentifier()));
                String cssClass = linkAndLabel.getCssClass();
                if(cssClass != null) {
                    item.add(new CssClassAppender(cssClass));
                }
                viewTitleLabel.add(new CssClassAppender(StringExtensions.asLowerDashed(linkAndLabel.getLabel())));
                link.addOrReplace(viewTitleLabel);
                item.addOrReplace(link);
            }
        };
        container.addOrReplace(listView);
    }
View Full Code Here

        final LinkAndLabel linkAndLabel = cssMenuLinkFactory.newLink(targetAdapterMemento, objectAction, PageAbstract.ID_MENU_LINK, actionPromptModalWindowProvider);
        if(linkAndLabel==null) {
            // can only get a null if invisible, so this should not happen given guard above
            return null;
        }
        final AbstractLink link = linkAndLabel.getLink();
        final String actionLabel = linkAndLabel.getLabel();

        final Consent usability = objectAction.isUsable(session, adapter, where);
        final String reasonDisabledIfAny = usability.getReason();
       
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.