org.apache.wicket.Page Java Examples

The following examples show how to use org.apache.wicket.Page. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EnterTopicPage.java    From ontopia with Apache License 2.0 6 votes vote down vote up
public EnterTopicPage(PageParameters parameters) {
	super(parameters);
	
    Topic topic = new TopicModel<Topic>(parameters.getString("topicMapId"), parameters.getString("topicId")).getTopic();
    
    Class<? extends Page> pageClass;
    if (topic.isTopicType())
      pageClass = InstancesPage.class;
//    else if (topic.isAssociationType())
//      pageClass = InstancePage.class;
//    else if (topic.isOccurrenceType())
//      pageClass = InstancePage.class;
//    else if (topic.isNameType())
//      pageClass = InstancePage.class;
//    else if (topic.isRoleType())
//      pageClass = InstancePage.class;
    else
      pageClass = InstancePage.class;
    
    // redirect page
    PageParameters params = new PageParameters();
    params.add("topicMapId", topic.getTopicMap().getId());
    params.add("topicId", topic.getId());
    setResponsePage(pageClass, params);
    setRedirect(true);
  }
 
Example #2
Source File: BootstrapPaginatorTest.java    From pm-wicket-utils with GNU Lesser General Public License v3.0 6 votes vote down vote up
private WicketTester createTester(){
	WicketTester tester = new WicketTester(new WebApplication() {
		
		@Override
		public Class<? extends Page> getHomePage() {
			return null;
		}
	}){
		@Override
		protected String createPageMarkup(String componentId) {
			return "<div class=\"pagination pagination-small pagination-right\" wicket:id=\"paginator\">"+
					"</div>";
		}
	};
	
	return tester;
}
 
Example #3
Source File: ActivityWidget.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/** MiniStat:: Link for Preferences */
private WidgetMiniStat getMiniStatConfigureLink() {
	return new WidgetMiniStatLink() {
		private static final long	serialVersionUID	= 1L;

		@Override
		public Page getPageLink() {
			return new PreferencesPage(new PageParameters().set("siteId", siteId));
		}
		
		@Override
		public String getLabel() {
			return (String) new ResourceModel("overview_title_configure_activity").getObject();
		}
		
		@Override
		public String getPageLinkTooltip() {
			return (String) new ResourceModel("overview_title_configure_activity_tip").getObject();
		};
	};
}
 
Example #4
Source File: VizigatorLinkFunctionBoxPanel.java    From ontopia with Apache License 2.0 6 votes vote down vote up
@Override
protected Component getLink(String id) {
  PageParameters pageParameters = new PageParameters();
  pageParameters.put("topicMapId", getTopicMapId());
  pageParameters.put("topicId", getTopicId());
  
  return new BookmarkablePageLink<Page>(id, VizigatorPage.class, pageParameters) {
    @Override
    protected void onComponentTag(ComponentTag tag) {
      tag.setName("a");
      //tag.put("target", "_blank");
      super.onComponentTag(tag);
    }
    @Override
    protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
      replaceComponentTagBody(markupStream, openTag, new ResourceModel("vizigator.text2").getObject().toString());
    }
  };
}
 
Example #5
Source File: LinksSupportImpl.java    From yes-cart with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
@SuppressWarnings("unchecked")
public Link newAddToCartLink(final String linkId,
                             final String supplier,
                             final String skuCode,
                             final String quantity,
                             final String wishlistId,
                             final Class<Page> target,
                             final PageParameters pageParameters) {

    final PageParameters params = getFilteredCurrentParameters(pageParameters);
    params.set(ShoppingCartCommand.CMD_ADDTOCART, skuCode);
    params.set(ShoppingCartCommand.CMD_P_SUPPLIER, supplier);
    params.set(ShoppingCartCommand.CMD_REMOVEFROMWISHLIST, skuCode);
    params.set(ShoppingCartCommand.CMD_REMOVEFROMWISHLIST_P_ID, wishlistId);
    if (quantity != null) { // null quantity will pick min from product
        params.set(ShoppingCartCommand.CMD_P_QTY, quantity);
    }
    return new BookmarkablePageLink(linkId, target, params);
}
 
Example #6
Source File: PageExpiredErrorPage.java    From ontopia with Apache License 2.0 6 votes vote down vote up
public PageExpiredErrorPage(final Class<? extends Page> previousPage, PageParameters parameters) {	
  super(parameters);
  
  createTitle();
  
  add(new OntopolyBookmarkablePageLink("startPage", StartPage.class, new ResourceModel("topic.map.index.page").getObject().toString()));
  
  // The bookmarkablePageLink class demands that the page argument is not equal to null, so
  // it has to be set to a concrete page if previousPage is null.
  Class<? extends Page> page = StartPage.class;
  if(previousPage != null) {
    page = previousPage;
  }
  
  WebMarkupContainer previousPageLinkContainer = new WebMarkupContainer("previousPageLinkContainer") {
    @Override
    public boolean isVisible() {
      return previousPage != null ? true : false;
    }  
  };
  previousPageLinkContainer.setOutputMarkupPlaceholderTag(true);
  add(previousPageLinkContainer);
  
  String label = "previous page";
  previousPageLinkContainer.add(new OntopolyBookmarkablePageLink("previousPage", page, parameters, label));
}
 
Example #7
Source File: LoginPanel.java    From yes-cart with Apache License 2.0 6 votes vote down vote up
/**
 * Construct login panel.
 *
 * @param id panel id
 * @param isCheckout is we are on checkout
 */
public LoginPanel(final String id, final boolean isCheckout) {
    super(id);
    this.isCheckout = isCheckout;

    final Pair<Class<? extends Page>, PageParameters> target = determineRedirectTarget(this.isCheckout);
    final AttrValueWithAttribute emailConfig = customerServiceFacade.getShopEmailAttribute(getCurrentShop());
    final IValidator<String> emailValidator;
    if (emailConfig != null && StringUtils.isNotBlank(emailConfig.getAttribute().getRegexp())) {
        final String regexError = new FailoverStringI18NModel(
                emailConfig.getAttribute().getValidationFailedMessage(),
                emailConfig.getAttribute().getCode()).getValue(getLocale().getLanguage());

        emailValidator = new CustomPatternValidator(emailConfig.getAttribute().getRegexp(), new Model<>(regexError));
    } else {
        emailValidator = EmailAddressValidator.getInstance();
    }
    add(new LoginForm(LOGIN_FORM, target.getFirst(), target.getSecond(), emailValidator));

}
 
Example #8
Source File: AddOArtifactCommand.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected void initializeContent(ModalWindow modal) {
    modal.setOutputMarkupPlaceholderTag(true);
    modal.setTitle(new ResourceModel(MODAL_WINDOW_TITLE));

    modal.setPageCreator(new ModalWindow.PageCreator() {
        @Override
        public Page createPage() {
            return modalWindowPage;
        }
    });

    modal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
        @Override
        public void onClose(AjaxRequestTarget target) {
            target.add(table);
        }
    });

    modal.setAutoSize(true);
    modal.setMinimalWidth(800);
    modal.setMinimalHeight(600);
    modalWindowPage.setModalWindow(modal);
}
 
Example #9
Source File: NavigationEntry.java    From the-app with Apache License 2.0 5 votes vote down vote up
public NavigationEntry(String name, int sortOrder, Class<? extends Page> pageClass, PageParameters pageParameters, boolean visible) {
    this.name = name;
    this.sortOrder = sortOrder;
    this.pageClass = pageClass;
    this.pageParameters = pageParameters;
    this.visible = visible;

}
 
Example #10
Source File: SpringSecurityAuthorizationStrategy.java    From AppStash with Apache License 2.0 5 votes vote down vote up
@Override
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(Class<T> componentClass) {
    if (!hasSpringSecuredAnnotation(componentClass)) {
        return true;
    }
    boolean authorized = isAuthorized(componentClass);
    if (Page.class.isAssignableFrom(componentClass) && !authorized) {
        String missingPermissions = ArrayUtils.toString(componentClass.getAnnotation(Secured.class).value());
        Session.get().error("Zugriff verweigert fehlende Berechtigung(en): " + missingPermissions);
        throw new RestartResponseAtInterceptPageException(LoginPage.class);
    }
    return authorized;
}
 
Example #11
Source File: UploadPanel.java    From ontopia with Apache License 2.0 5 votes vote down vote up
@Override
protected void onBeforeRender() {
    super.onBeforeRender();
    
    if (uploadIFrame == null) {
      // the iframe should be attached to a page to be able to get its pagemap,
      // that's why i'm adding it in onBeforeRender
      IPageLink iFrameLink = new IPageLink() {
        @Override
        public Page getPage() {
          return new UploadIFrame(parentField.getFieldValueModel()) {
            @Override
            protected String getOnUploadedCallback() {
              return "onUpload_" + UploadPanel.this.getMarkupId();
            }
            @Override
            protected LifeCycleListener getLifeCycleListener() {
              return (AbstractOntopolyPage)UploadPanel.this.getPage();
            }
          };
        }
        @Override
        public Class<? extends Page> getPageIdentity() {
          return UploadIFrame.class;
        }            
    };
    uploadIFrame = new InlineFrame("upload", getPage().getPageMap(), iFrameLink);
    add(uploadIFrame);
  }
}
 
Example #12
Source File: AnnotatorStateImpl.java    From webanno with Apache License 2.0 5 votes vote down vote up
private void fireViewStateChanged()
{
    RequestCycle requestCycle = RequestCycle.get();
    
    if (requestCycle == null) {
        return;
    }
    
    Optional<IPageRequestHandler> handler = requestCycle.find(IPageRequestHandler.class);
    if (handler.isPresent() && handler.get().isPageInstanceCreated()) {
        Page page = (Page) handler.get().getPage();
        page.send(page, BREADTH, new AnnotatorViewportChangedEvent(
                requestCycle.find(AjaxRequestTarget.class).orElse(null)));
    }
}
 
Example #13
Source File: MarkdownReportTab.java    From onedev with MIT License 5 votes vote down vote up
@Override
public Component render(String componentId) {
	return new PageTabLink(componentId, this) {

		@Override
		protected Link<?> newLink(String linkId, Class<? extends Page> pageClass) {
			BuildDetailPage page = (BuildDetailPage) getPage();
			String startPage = LockUtils.read(page.getBuild().getReportLockKey(JobMarkdownReport.DIR), new Callable<String>() {

				@Override
				public String call() throws Exception {
					File startPageFile = new File(page.getBuild().getReportDir(JobMarkdownReport.DIR), 
							getTitle() + "/" + JobMarkdownReport.START_PAGE);
					if (startPageFile.exists())
						return FileUtils.readFileToString(startPageFile, StandardCharsets.UTF_8);
					else
						return null;
				}
				
			});
			
			PageParameters params = MarkdownReportPage.paramsOf(page.getBuild(), getTitle(), startPage);
			return new ViewStateAwarePageLink<Void>(linkId, pageClass, params);
		}
		
	};
}
 
Example #14
Source File: LinksSupportImpl.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
@SuppressWarnings("unchecked")
public Link newChangeLocaleLink(final String linkId,
                                final String language,
                                final Class<? extends Page> target,
                                final PageParameters pageParameters) {

    final PageParameters params = getFilteredCurrentParameters(pageParameters);
    params.set(ShoppingCartCommand.CMD_CHANGELOCALE, language);
    return new BookmarkablePageLink(
            linkId,
            target == null ? getHomePage() : target,
            params);
}
 
Example #15
Source File: MarkdownReportTab.java    From onedev with MIT License 5 votes vote down vote up
@Override
public boolean isActive(Page currentPage) {
	if (super.isActive(currentPage)) {
		MarkdownReportPage markdownReportPage = (MarkdownReportPage) currentPage;
		return getTitle().equals(markdownReportPage.getReportName());
	} else {
		return false;
	}
}
 
Example #16
Source File: TelemetrySettingsInterceptor.java    From webanno with Apache License 2.0 5 votes vote down vote up
@Override
public void intercept(Page aPage)
{
    // We actually have to check for this interceptor only once since the telemetry settings
    // cannot (normally) become invalid while the application is running and therefore
    // once we have asserted that they are all valid, we don't have to check anymore.
    if (allValid) {
        return;
    }
    
    // Do nothing if we are already on the telemetry settings page
    if (aPage instanceof TelemetrySettingsPage) {
        return;
    }

    // Intercept only if the user is already logged in
    if (SecurityContextHolder.getContext()
            .getAuthentication() instanceof AnonymousAuthenticationToken) {
        return;
    }
    
    // Only direct admin users to the telemetry settings page
    if (!userService.isAdministrator(userService.getCurrentUser())) {
        return;
    }
    
    
    for (TelemetrySupport<?> support : telemetryService.getTelemetrySupports()) {
        if (!support.hasValidSettings()) {
            throw new RestartResponseException(TelemetrySettingsPage.class);
        }
    }
    
    allValid = true;
}
 
Example #17
Source File: OIndexPageLink.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
private static Class<? extends Page> resolvePageClass(DisplayMode mode)
{
	switch (mode) {
	case VIEW:
		return OIndexPage.class;
	case EDIT:
		return OIndexPage.class;
	default:
		return OIndexPage.class;
	}
}
 
Example #18
Source File: NextServerApplication.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
protected void addSecurityAuthorization() {
	Class<? extends Page> signInPageClass = LoginPage.class;
	if (CasUtil.isCasUsed()) {
		signInPageClass = CasLoginPage.class;
	}

	IAuthorizationStrategy authStrategy = new SimplePageAuthorizationStrategy(SecurePage.class, signInPageClass) {

		@Override
		protected boolean isAuthorized() {
			boolean b = NextServerSession.get().isSignedIn();
			if (!b) {
				if (CasUtil.isCasUsed()) {
					LOG.debug("Checking if context contains CAS authentication");
					b = NextServerSession.get().checkForSignIn();
					if (!b) {
						String serviceUrl = CasUtil.getServiceProperties().getService();
						String loginUrl = CasUtil.getLoginUrl();
						LOG.debug("cas authentication: service URL: " + serviceUrl);
						String redirectUrl = loginUrl + "?service=" + serviceUrl;
						LOG.debug("attempting to redirect to: " + redirectUrl);
						throw new RestartResponseAtInterceptPageException(new RedirectPage(redirectUrl));
					}
				}
			}

			return b;
		}

	};
	getSecuritySettings().setAuthorizationStrategy(authStrategy);
}
 
Example #19
Source File: WicketUtils.java    From onedev with MIT License 5 votes vote down vote up
@Nullable
public static PageKey getPageKey() {
	Page page = getPage();
	if (page != null) {
		String sessionId = page.getSession().getId();
		if (sessionId != null) {
			return new PageKey(sessionId, new PageIdKey(page.getPageId()));
		}
	}
	return null;
}
 
Example #20
Source File: ApplicationSettingsConfig.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
private void configureExpiredPage(ApplicationSettings applicationSettings, List<WicketClassCandidate<Page>> expiredPageCandidates, Builder builder) {
	Class<Page> candidate = null;
	if(expiredPageCandidates.size() > 0) {
		if(expiredPageCandidates.size() == 1){
			WicketClassCandidate<Page> expiredPageCandidate = expiredPageCandidates.get(0);
			applicationSettings.setPageExpiredErrorPage(expiredPageCandidate.getCandidate());
			candidate = expiredPageCandidate.getCandidate();
			builder.withDetail("expiredPage", expiredPageCandidate.getCandidate().getName());
		} else {
			throwExceptionOnMultipleAnnotations(WicketExpiredPage.class, expiredPageCandidates);
		}
	}
	builder.withDetail("expiredPage", candidate);
}
 
Example #21
Source File: ShoppingCartItemsList.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
/**
 * Create BookmarkablePageLink for add one sku to cart command.
 *
 * @param skuCode   sku code
 * @param supplier  supplier
 *
 * @return BookmarkablePageLink for add one sku to cart command
 */
private BookmarkablePageLink createAddOneSkuLink(final String skuCode, final String supplier) {
    final PageParameters paramsMap = new PageParameters();
    paramsMap.set(ShoppingCartCommand.CMD_ADDTOCART, skuCode);
    paramsMap.set(ShoppingCartCommand.CMD_P_SUPPLIER, supplier);
    return new BookmarkablePageLink<Page>(
            ADD_ONE_LINK,
            getPage().getPageClass(),
            paramsMap
    );
}
 
Example #22
Source File: BuildTab.java    From onedev with MIT License 5 votes vote down vote up
@Override
public Component render(String componentId) {
	return new PageTabLink(componentId, this) {

		@Override
		protected Link<?> newLink(String linkId, Class<? extends Page> pageClass) {
			BuildDetailPage page = (BuildDetailPage) getPage();
			return new ViewStateAwarePageLink<Void>(linkId, pageClass, 
					BuildDetailPage.paramsOf(page.getBuild()));
		}
		
	};
}
 
Example #23
Source File: SyncopeWebApplication.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Override
public Class<? extends Page> getHomePage() {
    return SyncopeEnduserSession.get().isAuthenticated()
            && SyncopeEnduserSession.get().getSelfTO().isMustChangePassword()
            ? MustChangePassword.class
            : SyncopeEnduserSession.get().isAuthenticated()
            ? Self.class
            : Login.class;
}
 
Example #24
Source File: PageTab.java    From onedev with MIT License 5 votes vote down vote up
public PageTab(IModel<String> titleModel, Class<? extends Page> mainPageClass, 
		Class<? extends Page> additionalPageClass1, 
		Class<? extends Page> additionalPageClass2,
		Class<? extends Page> additionalPageClass3, 
		Class<? extends Page> additionalPageClass4) {
	this(titleModel, mainPageClass, asList(additionalPageClass1, 
			additionalPageClass2, additionalPageClass3, additionalPageClass4));
}
 
Example #25
Source File: WicketApplicationBase.java    From webanno with Apache License 2.0 5 votes vote down vote up
protected void addJQueryJavascriptToAllPages()
{
    getComponentInstantiationListeners().add(component -> {
        if (component instanceof Page) {
            component.add(new JQueryJavascriptBehavior());
        }
    });
}
 
Example #26
Source File: ShoppingCartItemsList.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
/**
 * Create BookmarkablePageLink for remove one sku from cart command.
 *
 * @param skuCode   sku code
 * @param supplier  supplier
 *
 * @return BookmarkablePageLink for remove one sku from cart command
 */
private BookmarkablePageLink createRemoveAllSkuLink(final String skuCode, final String supplier) {
    final PageParameters paramsMap = new PageParameters();
    paramsMap.set(ShoppingCartCommand.CMD_REMOVEALLSKU, skuCode);
    paramsMap.set(ShoppingCartCommand.CMD_P_SUPPLIER, supplier);
    return new BookmarkablePageLink<Page>(
            REMOVE_ALL_LINK,
            getPage().getPageClass(),
            paramsMap
    );
}
 
Example #27
Source File: Selection.java    From webanno with Apache License 2.0 5 votes vote down vote up
private void fireSelectionChanged()
{
    Optional<IPageRequestHandler> handler = RequestCycle.get().find(IPageRequestHandler.class);
    if (handler.isPresent() && handler.get().isPageInstanceCreated()) {
        Page page = (Page) handler.get().getPage();
        page.send(page, BREADTH, new SelectionChangedEvent(
                RequestCycle.get().find(AjaxRequestTarget.class).orElse(null)));
    }
}
 
Example #28
Source File: MenuItemDef.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds the given menu entry as root menu entry.
 * @param mobileParentEntry
 * @param mobileMenuOrderNumber
 * @return this for chaining.
 */
public MenuItemDef setMobileMenu(final Class< ? extends Page> mobilePageClass, final int mobileMenuOrderNumber)
{
  this.mobileMenuSupport = true;
  this.mobilePageClass = mobilePageClass;
  this.mobileMenuOrderNumber = mobileMenuOrderNumber;
  return this;
}
 
Example #29
Source File: WicketClassCandidatesHolder.java    From wicket-spring-boot with Apache License 2.0 4 votes vote down vote up
public Set<WicketClassCandidate<Page>> getAccessDeniedPageCandidates() {
	return accessDeniedPageCandidates;
}
 
Example #30
Source File: ProjectIssuesPage.java    From onedev with MIT License 4 votes vote down vote up
public IssuesTab(String title, Class<? extends Page> pageClass, Class<? extends Page> additionalPageClass1) {
	super(Model.of(title), pageClass, additionalPageClass1);
}