Examples of AbstractLink


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

      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

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

      requestCycle.getRequestTarget().respond(requestCycle);
    }
    // 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

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

                cssMenuContext.getActionPromptProvider());
        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

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

            final ObjectAction objectAction,
            final CssMenuBuilder.CssMenuContext cssMenuContext) {

        final LinkAndLabel linkAndLabel = cssMenuContext.getCssMenuLinkFactory().newLink(null, objectAction, PageAbstract.ID_MENU_LINK, cssMenuContext.getActionPromptProvider());

        final AbstractLink link = linkAndLabel.getLink();
        final String actionLabel = linkAndLabel.getLabel();
        Builder builder = this.newSubMenuItem(actionLabel).link(link).prototyping(linkAndLabel.isPrototype()).returnsBlobOrClob(linkAndLabel.isBlobOrClob());

        CssClassFacet cssClassFacet = objectAction.getFacet(CssClassFacet.class);
        if (cssClassFacet != null) {
View Full Code Here

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

        addCssClassAttributesIfRequired(menuItemComponent);
    }

    private Component addMenuItemComponentTo(final MarkupContainer markupContainer) {
        final AbstractLink link = getLink();
        final Label label = new Label(CssMenuItem.ID_MENU_LABEL, Model.of(this.getName()));

        if (this.isEnabled() && link != null) {
            // show link...
            markupContainer.add(link);
            link.add(label);

            if(this.description != null) {
                label.add(new AttributeModifier("title", Model.of(description)));
            }
            if(this.blobOrClob) {
                link.add(new CssClassAppender("noVeil"));
            }
            if(this.prototype) {
                link.add(new CssClassAppender("prototype"));
            }
            if(this.cssClass != null) {
                markupContainer.add(new CssClassAppender(this.cssClass));
            }
            link.add(new CssClassAppender(this.actionIdentifier));

            // .. and hide label
            Components.permanentlyHide(markupContainer, CssMenuItem.ID_MENU_LABEL);
            return link;
        } else {
View Full Code Here

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

            cssMenuItem.setParent(parent);
            return this;
        }

        public <T extends Page> Builder link(final Class<T> pageClass) {
            final AbstractLink link = new SubmitLink(ID_MENU_LINK);
            return link(link);
        }
View Full Code Here

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

    }

    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

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

            final ActionModel actionModel = ActionModel.create(objectAdapter, action);
            actionModel.setActionPrompt(actionPrompt);
           
            final AjaxDeferredBehaviour ajaxDeferredBehaviour = determineDeferredBehaviour(action, actionModel);

            final AbstractLink link = new AjaxLink<Object>(linkId) {
                private static final long serialVersionUID = 1L;
               
                @Override
                public void onClick(AjaxRequestTarget target) {

                    if(ajaxDeferredBehaviour != null) {
                        ajaxDeferredBehaviour.initiate(target);
                    } else {
                        final ActionPanel actionPanel =
                                (ActionPanel) getComponentFactoryRegistry().createComponent(
                                        ComponentType.ACTION_PROMPT, actionPrompt.getContentId(), actionModel);
                       
                        actionPrompt.setPanel(actionPanel, target);
                        actionPanel.setActionPrompt(actionPrompt);
                        actionPrompt.show(target);

                        focusOnFirstParameter(target, actionPanel);
                    }
                }

                private void focusOnFirstParameter(AjaxRequestTarget target, ActionPanel actionPanel) {

                    // first, force all parameters to build themselves...
                    actionPanel.visitChildren(new IVisitor<Component, Component>() {
                        @Override
                        public void component(Component object, IVisit<Component> visit) {
                            if (object instanceof ScalarPanelAbstract) {
                                ScalarPanelAbstract spa = (ScalarPanelAbstract) object;
                                spa.forceBuildGui();
                                visit.dontGoDeeper();
                            }
                        }
                    });

                    // second, go searching for the first <input> in the action panel.
                    final Component actionPanelFirstParam = actionPanel.visitChildren(new IVisitor<Component, Component>() {
                        @Override
                        public void component(Component object, IVisit<Component> visit) {
                            if (object instanceof FormComponent &&
                                !"scalarIfCompact".equals(object.getId()) &&
                                object.getOutputMarkupId()) {
                                // there are components for 'compact' and 'regular'; we want the 'regular' one
                                // also double check that has outputMarkupId enabled (prereq for setting focus)
                                visit.stop(object);
                            }
                        }
                    });

                    // third, if found then use Wicket API to focus on this component
                    if(actionPanelFirstParam != null) {
                        target.focusComponent(actionPanelFirstParam);
                    }
                }
            };

            if(ajaxDeferredBehaviour != null) {
                link.add(ajaxDeferredBehaviour);
            }

            link.add(new CssClassAppender("noVeil"));

            return link;
           
        } else {
           
            // use the action semantics to determine whether invoking this action will require a concurrency check or not
            // if it's "safe", then we'll just continue without any checking.
            final ConcurrencyChecking concurrencyChecking = ConcurrencyChecking.concurrencyCheckingFor(action.getSemantics());
            final PageParameters pageParameters = ActionModel.createPageParameters(objectAdapter, action, concurrencyChecking);
            final Class<? extends Page> pageClass = getPageClassRegistry().getPageClass(PageType.ACTION_PROMPT);
            AbstractLink link = Links.newBookmarkablePageLink(linkId, pageParameters, pageClass);
           
            // special case handling if this a no-arg action is returning a URL
            if(action.getParameterCount()==0) {
                addTargetBlankIfActionReturnsUrl(link, action);
            }
View Full Code Here

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

                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

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

            final ObjectAction objectAction,
            final String linkId,
            final ActionPromptProvider actionPromptProvider) {
       
        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
TOP
Copyright © 2018 www.massapi.com. 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.