Java Code Examples for org.apache.wicket.request.mapper.parameter.PageParameters

The following examples show how to use org.apache.wicket.request.mapper.parameter.PageParameters. These examples are extracted from open source projects. 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 Project: yes-cart   Source File: AbstractWebPage.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Construct page.
 *
 * @param params page parameters
 */
public AbstractWebPage(final PageParameters params) {
    super(params);

    final ShoppingCart cart = ApplicationDirector.getShoppingCart();

    if (cart == null) {
        // Abnormal flow (possibly due incorrect URL pattern)
        setResponsePage(Application.get().getHomePage());
    }

    if (cart != null) {
        if (StringUtils.isBlank(cart.getCurrentLocale())) {
            getShoppingCartCommandFactory().execute(cart,
                    Collections.singletonMap(
                            ShoppingCartCommand.CMD_CHANGELOCALE,
                            getSession().getLocale().getLanguage()
                    ));
        }
        // reinstate the current cart language as our session is transient
        getSession().setLocale(new Locale(cart.getCurrentLocale()));
    }
    setStatelessHint(true);

}
 
Example 2
Source Project: inception   Source File: ProjectDashboardPage.java    License: Apache License 2.0 6 votes vote down vote up
public ProjectDashboardPage(final PageParameters aPageParameters)
{
    super(aPageParameters);
    
    User currentUser = userRepository.getCurrentUser();
    
    // Check if use can access the project
    Project project = projectService.listAccessibleProjects(currentUser).stream()
            .filter(p -> p.getId().equals(
                    aPageParameters.get(PAGE_PARAM_PROJECT_ID).toOptionalLong()))
            .findFirst()
            .orElse(null);

    // If the user has no access, send the user back to the overview page
    if (project == null) {
        setResponsePage(ProjectsOverviewPage.class);
    }
    
    // Otherwise make the project the current project
    Session.get().setMetaData(CURRENT_PROJECT, project);
    
    commonInit();
}
 
Example 3
Source Project: onedev   Source File: IssueBoardsPage.java    License: MIT License 6 votes vote down vote up
private void doQuery(AjaxRequestTarget target) {
	if (backlog) {
		backlogQueryString = queryInput.getModelObject();
		getPageParameters().set(PARAM_BACKLOG_QUERY, backlogQueryString);
	} else { 
		queryString = queryInput.getModelObject();
		getPageParameters().set(PARAM_QUERY, queryString);
	}

	PageParameters params = IssueBoardsPage.paramsOf(getProject(), getBoard(), 
			getMilestone(), backlog, queryString, backlogQueryString);
		
	CharSequence url = RequestCycle.get().urlFor(IssueBoardsPage.class, params);
	pushState(target, url.toString(), queryInput.getModelObject());
	
	target.add(body);
	target.appendJavaScript("$(window).resize();");
}
 
Example 4
Source Project: syncope   Source File: Self.java    License: Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void onEvent(final IEvent<?> event) {
    if (event.getPayload() instanceof AjaxWizard.NewItemEvent) {
        if (event.getPayload() instanceof AjaxWizard.NewItemCancelEvent) {
            @SuppressWarnings("unchecked")
            final Class<? extends WebPage> beforeLogout = (Class<? extends WebPage>) SyncopeEnduserSession.get().
                    getAttribute(Constants.BEFORE_LOGOUT_PAGE);
            if (beforeLogout == null) {
                SyncopeEnduserSession.get().invalidate();
                setResponsePage(getApplication().getHomePage());
            } else {
                setResponsePage(beforeLogout);
            }
        } else if (event.getPayload() instanceof AjaxWizard.NewItemFinishEvent) {
            SyncopeEnduserSession.get().invalidate();

            final PageParameters parameters = new PageParameters();
            parameters.add(Constants.NOTIFICATION_MSG_PARAM, getString("self.wizard.success"));
            setResponsePage(getApplication().getHomePage(), parameters);
        }
    }
    super.onEvent(event);
}
 
Example 5
protected AbstractMobileViewPage(final PageParameters parameters)
{
  super(parameters);
  final Integer id = WicketUtils.getAsInteger(parameters, AbstractEditPage.PARAMETER_KEY_ID);
  data = null;
  if (NumberHelper.greaterZero(id) == true) {
    data = getBaseDao().getById(id);
  }
  if (data == null) {
    // Create empty address for avoiding NPE...
    data = getBaseDao().newInstance();
    getLogger().error("Oups, no object id given. Can't display object.");
    setResponsePage(getListPageClass());
    return;
  }
  final RepeatingView flowfields = new RepeatingView("flowfields");
  pageContainer.add(flowfields);
  gridBuilder = new MobileGridBuilder(flowfields);
}
 
Example 6
Source Project: yes-cart   Source File: LinksSupportImpl.java    License: 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 PageParameters pageParameters) {

    final PageParameters params = getFilteredCurrentParameters(pageParameters);
    params.set(ShoppingCartCommand.CMD_ADDTOCART, skuCode);
    params.set(ShoppingCartCommand.CMD_P_SUPPLIER, supplier);
    if (quantity != null) { // null quantity will pick min from product
        params.set(ShoppingCartCommand.CMD_P_QTY, quantity);
    }
    return new BookmarkablePageLink(linkId, getHomePage(), params);
}
 
Example 7
Source Project: onedev   Source File: PullRequestActivitiesPage.java    License: MIT License 6 votes vote down vote up
public PullRequestActivitiesPage(PageParameters params) {
	super(params);

	WebRequest request = (WebRequest) RequestCycle.get().getRequest();
	Cookie cookie = request.getCookie(COOKIE_SHOW_COMMENTS);
	if (cookie != null)
		showComments = Boolean.valueOf(cookie.getValue());
	
	cookie = request.getCookie(COOKIE_SHOW_COMMITS);
	if (cookie != null)
		showCommits = Boolean.valueOf(cookie.getValue());
	
	cookie = request.getCookie(COOKIE_SHOW_CHANGE_HISTORY);
	if (cookie != null)
		showChangeHistory = Boolean.valueOf(cookie.getValue());
}
 
Example 8
Source Project: artifact-listener   Source File: DashboardPage.java    License: Apache License 2.0 6 votes vote down vote up
public DashboardPage(PageParameters parameters) {
	super(parameters);
	
	addBodyCssClass("force-vertical-scroll");
	
	addHeadPageTitleElement(new BreadCrumbElement(new ResourceModel("dashboard.pageTitle")));
	addBreadCrumbElement(new BreadCrumbElement(new ResourceModel("dashboard.pageTitle"), DashboardPage.linkDescriptor()));
	
	add(new Label("pageTitle", new ResourceModel("dashboard.pageTitle")));
	
	DashboardNotificationListViewPanel notificationsPanel = new DashboardNotificationListViewPanel("notificationPanel",
			new NotificationsModel(MavenArtifactNotifierSession.get().getUserModel()));
	add(notificationsPanel);
	
	DashboardArtifactPortfolioPanel artifactPanel = new DashboardArtifactPortfolioPanel("artifactPanel",
			new LoadableDetachableModel<Collection<FollowedArtifact>>() {
		private static final long serialVersionUID = -8484961470906264804L;

		@Override
		protected Collection<FollowedArtifact> load() {
			return userService.listFollowedArtifacts(MavenArtifactNotifierSession.get().getUser());
		}
	});
	add(artifactPanel);
}
 
Example 9
Source Project: the-app   Source File: ProductItemPanel.java    License: Apache License 2.0 6 votes vote down vote up
private Component productDetailImageLink() {
    Link<Void> detailPageLink = new Link<Void>("productDetailLink") {
        @Override
        public void onClick() {
            PageParameters pageParameters = new PageParameters();
            pageParameters.set("urlname", productUrlModel.getObject());
            setResponsePage(new ProductDetailPage(pageParameters));
        }
    };
    WebMarkupContainer image = new WebMarkupContainer("image");
    image.add(new AttributeModifier("src", new ImageLinkModel(productInfoModel, this)));
    image.add(new AttributeModifier("title", new PropertyModel<String>(productInfoModel, "description")));
    image.add(new AttributeModifier("alt", new PropertyModel<String>(productInfoModel, "name")));
    image.setOutputMarkupId(true);

    detailPageLink.add(image);
    return detailPageLink;
}
 
Example 10
public DocumentationPage(final PageParameters parameters)
{
  super(parameters);
  final Locale locale = PFUserContext.getLocale();
  final boolean isGerman = locale != null && locale.toString().startsWith("de") == true;
  addDocLink(body, "newsLink", "doc/News.html");
  addDocLink(body, "tutorialLink", "doc/ProjectForge.html");
  addDocLink(body, "handbookLink", "doc/UserGuide.html");
  if (isGerman == true) {
    addDocLink(body, "faqLink", "doc/FAQ_de.html");
  } else {
    addDocLink(body, "faqLink", "doc/FAQ.html");
  }
  addDocLink(body, "licenseLink", "LICENSE.txt");

  addDocLink(body, "adminLogbuchLink", "doc/AdminLogbuch.html");
  addDocLink(body, "adminGuideLink", "doc/AdministrationGuide.html");
  addDocLink(body, "developerGuideLink", "doc/DeveloperGuide.html");
  addDocLink(body, "projectDocLink", "site/index.html");
  addDocLink(body, "javaDocLink", "site/apidocs/index.html");
}
 
Example 11
Source Project: sakai   Source File: ReportDataPage.java    License: Educational Community License v2.0 6 votes vote down vote up
public ReportDataPage(final ReportDefModel reportDef, final PageParameters pageParameters, final WebPage returnPage) {
	this.reportDefModel = reportDef;
	realSiteId = Locator.getFacade().getToolManager().getCurrentPlacement().getContext();
	if(pageParameters != null) {
		siteId = pageParameters.get("siteId").toString();
		inPrintVersion = pageParameters.get("printVersion").toBoolean(false);
	}
	if(siteId == null){
		siteId = realSiteId;
	}
	if(returnPage == null) {
		this.returnPage = new ReportsPage(pageParameters);			
	}else{
		this.returnPage = returnPage;
	}
	boolean allowed = Locator.getFacade().getStatsAuthz().isUserAbleToViewSiteStats(siteId);
	if(allowed) {
		if(reportDef != null && getReportDef() != null && getReportDef().getReportParams() != null) {
			renderBody();
		}else{
			setResponsePage(ReportsPage.class);
		}
	}else{
		setResponsePage(NotAuthorizedPage.class);
	}
}
 
Example 12
Source Project: yes-cart   Source File: LinksSupportImpl.java    License: Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
@SuppressWarnings("unchecked")
public Link newRemoveFromWishListLink(final String linkId,
                                      final String supplier,
                                      final String skuCode,
                                      final Long itemId,
                                      final Class<Page> target,
                                      final PageParameters pageParameters) {

    final PageParameters params = getFilteredCurrentParameters(pageParameters);
    params.set(ShoppingCartCommand.CMD_REMOVEFROMWISHLIST, skuCode);
    params.set(ShoppingCartCommand.CMD_P_SUPPLIER, supplier);
    params.set(ShoppingCartCommand.CMD_REMOVEFROMWISHLIST_P_ID, itemId);
    return new BookmarkablePageLink(linkId, target, params);
}
 
Example 13
Source Project: Orienteer   Source File: ODocumentsPage.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected IModel<List<ODocument>> resolveByPageParameters(PageParameters params) {
    String docs = params.get("docs").toOptionalString();
    IModel<List<ODocument>> result = new ListModel<>();

    if (!Strings.isNullOrEmpty(docs)) {
        List<ODocument> docsList = new LinkedList<>();
        result.setObject(docsList);
        if (docs.contains(",")) {
            String [] rids = docs.split(",");
            for (String rid : rids) {
                docsList.add(new ORecordId(rid).getRecord());
            }
        } else {
            docsList.add(new ORecordId(docs).getRecord());
        }
    }
    return result;
}
 
Example 14
Source Project: onedev   Source File: MilestoneDetailPage.java    License: MIT License 5 votes vote down vote up
public static PageParameters paramsOf(Milestone milestone, @Nullable String query) {
	PageParameters params = paramsOf(milestone.getProject());
	params.add(PARAM_MILESTONE, milestone.getId());
	if (query != null)
		params.add(PARAM_QUERY, query);
	return params;
}
 
Example 15
public SkillTreePage(final ISelectCallerPage caller, final String selectProperty)
{
  super(new PageParameters());
  this.caller = caller;
  this.selectProperty = selectProperty;
  init();
}
 
Example 16
Source Project: wicket-spring-boot   Source File: CustomerEditPageTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void assert_customer_on_load_existing(){
	PageParameters params = new PageParameters();
	params.add(CustomerEditPage.CUSTOMER_ID_PARAM, "3");
	getTester().startPage(CustomerEditPage.class, params);

	getTester().assertNoErrorMessage();
	getTester().assertNoInfoMessage();
	
	getTester().assertRenderedPage(CustomerEditPage.class);
	
	FormTester formTester = getTester().newFormTester("form");
	
	String username = formTester.getTextComponentValue(borderPath("username"));
	String firstname = formTester.getTextComponentValue(borderPath("firstname"));
	String lastname = formTester.getTextComponentValue(borderPath("lastname"));
	
	assertThat(username, equalTo("username3"));
	assertThat(firstname, equalTo("firstname3"));
	assertThat(lastname, equalTo("lastname3"));
	
	getTester().debugComponentTrees();
	
	String usernameFieldPath = "form:" + borderPath("username");
	getTester().assertComponent(usernameFieldPath, UsernameTextField.class);
	getTester().isDisabled(usernameFieldPath);
	
	String passwordFieldPath = "form:" + borderPath("password");
	getTester().isInvisible(passwordFieldPath);
}
 
Example 17
Source Project: onedev   Source File: BuildListPage.java    License: MIT License 5 votes vote down vote up
public static PageParameters paramsOf(@Nullable String query, int page, int expectedCount) {
	PageParameters params = new PageParameters();
	if (query != null)
		params.add(PARAM_QUERY, query);
	if (page != 0)
		params.add(PARAM_PAGE, page);
	if (expectedCount != 0)
		params.add(PARAM_EXPECTED_COUNT, expectedCount);
	return params;
}
 
Example 18
Source Project: yes-cart   Source File: ProfilePage.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Construct page.
 *
 * @param params page parameters
 */
public ProfilePage(final PageParameters params) {
    super(params);

    final String email = getCurrentCart().getCustomerEmail();
    final Customer customer;
    if (StringUtils.isNotBlank(email)) {
        customer = customerServiceFacade.getCustomerByEmail(getCurrentShop(), email);
    } else {
        customer = null;
        // Redirect away from profile!
        final PageParameters logOutParams = new PageParameters();
        logOutParams.set(ShoppingCartCommand.CMD_LOGOUT, ShoppingCartCommand.CMD_LOGOUT);
        setResponsePage(Application.get().getHomePage(), logOutParams);
    }

    final Model<Customer> customerModel = new Model<>(customer);

    add(new FeedbackPanel(FEEDBACK));
    add(new PasswordPanel(PASSWORD_PANEL, customerModel));
    add(new DeleteAccountPanel(DELETE_PANEL, customerModel));
    add(new ManageAddressesView(SHIPPING_ADDR_PANEL, customerModel, Address.ADDR_TYPE_SHIPPING, false));
    add(new ManageAddressesView(BILLING_ADDR_PANEL, customerModel, Address.ADDR_TYPE_BILLING, false));
    add(new DynaFormPanel(ATTR_PANEL, customerModel));
    add(new SummaryPanel(SUMMARY_PANEL, customerModel));
    add(new StandardFooter(FOOTER));
    add(new StandardHeader(HEADER));
    add(new ServerSideJs("serverSideJs"));
    add(new HeaderMetaInclude("headerInclude"));

}
 
Example 19
Source Project: onedev   Source File: MilestoneListPage.java    License: MIT License 5 votes vote down vote up
public static PageParameters paramsOf(Project project, boolean closed, @Nullable MilestoneSort sort) {
	PageParameters params = paramsOf(project);
	if (closed)
		params.add(PARAM_STATE, "closed");
	else
		params.add(PARAM_STATE, "open");
		
	if (sort != null)
		params.add(PARAM_SORT, sort.name().toLowerCase());
	return params;
}
 
Example 20
Source Project: syncope   Source File: Security.java    License: Apache License 2.0 5 votes vote down vote up
public Security(final PageParameters parameters) {
    super(parameters);

    body.add(BookmarkablePageLinkBuilder.build("dashboard", "dashboardBr", Dashboard.class));
    WebMarkupContainer content = new WebMarkupContainer("content");
    content.setOutputMarkupId(true);
    content.setMarkupId("security");
    content.add(new AjaxBootstrapTabbedPanel<>("tabbedPanel", buildTabList()));
    body.add(content);
}
 
Example 21
Source Project: onedev   Source File: HtmlReportDownloadResource.java    License: MIT License 5 votes vote down vote up
public static PageParameters paramsOf(Project project, Long buildNumber, String reportName, String path) {
	PageParameters params = new PageParameters();
	params.set(PARAM_PROJECT, project.getName());
	params.set(PARAM_BUILD, buildNumber);
	params.set(PARAM_REPORT, reportName);
	params.set(PARAM_PATH, path);
	return params;
}
 
Example 22
Source Project: onedev   Source File: SourceViewPanel.java    License: MIT License 5 votes vote down vote up
private String getJsonOfBlameInfos(boolean blamed) {
	String jsonOfBlameInfos;
	if (blamed) {
		List<BlameInfo> blameInfos = new ArrayList<>();
		
		String commitHash = context.getCommit().name();
		
		BlameCommand cmd = new BlameCommand(context.getProject().getGitDir());
		cmd.commitHash(commitHash).file(context.getBlobIdent().path);
		for (BlameBlock blame: cmd.call()) {
			BlameInfo blameInfo = new BlameInfo();
			blameInfo.commitDate = DateUtils.formatDate(blame.getCommit().getCommitter().getWhen());
			blameInfo.authorName = HtmlEscape.escapeHtml5(blame.getCommit().getAuthor().getName());
			blameInfo.hash = blame.getCommit().getHash();
			blameInfo.abbreviatedHash = GitUtils.abbreviateSHA(blame.getCommit().getHash(), 7);
			CommitDetailPage.State state = new CommitDetailPage.State();
			state.revision = blame.getCommit().getHash();
			if (context.getBlobIdent().path != null)
				state.pathFilter = PatternSet.quoteIfNecessary(context.getBlobIdent().path);
			PageParameters params = CommitDetailPage.paramsOf(context.getProject(), state);
			blameInfo.url = RequestCycle.get().urlFor(CommitDetailPage.class, params).toString();
			blameInfo.ranges = blame.getRanges();
			blameInfos.add(blameInfo);
		}
		try {
			jsonOfBlameInfos = OneDev.getInstance(ObjectMapper.class).writeValueAsString(blameInfos);
		} catch (JsonProcessingException e) {
			throw new RuntimeException(e);
		}
	} else {
		jsonOfBlameInfos = "undefined";
	}
	return jsonOfBlameInfos;
}
 
Example 23
@Test
public void testLoginAndLogout()
{
  final LoginPage loginPage = new LoginPage(new PageParameters());
  // start and render the test page
  tester.startPage(loginPage);
  // assert rendered page class
  tester.assertRenderedPage(LoginPage.class);
  // assert rendered label component
  tester.assertVisible("body:form:username");
  FormTester form = tester.newFormTester("body:form");
  form.setValue(findComponentByLabel(form, "username"), "demo");
  form.setValue(findComponentByLabel(form,"password"), "wrong");
  form.submit(KEY_LOGINPAGE_BUTTON_LOGIN);
  tester.assertRenderedPage(LoginPage.class);
  form = tester.newFormTester("body:form");
  form.setValue(findComponentByLabel(form,"username"), TestBase.TEST_ADMIN_USER);
  form.setValue(findComponentByLabel(form,"password"), TestBase.TEST_ADMIN_USER_PASSWORD);
  form.submit(KEY_LOGINPAGE_BUTTON_LOGIN);
  tester.assertRenderedPage(CalendarPage.class);
  tester.startPage(AddressListPage.class);
  tester.assertRenderedPage(AddressListPage.class);

  loginTestAdmin(); // login should be ignored.
  tester.assertRenderedPage(WicketUtils.getDefaultPage());

  logout();
  try {
    tester.startPage(AddressListPage.class);
    Assert.fail("Page must not be available, user not logged-in.");
  } catch (final WicketRuntimeException ex) {
    // Everything fine.
  }
}
 
Example 24
Source Project: openmeetings   Source File: Application.java    License: Apache License 2.0 5 votes vote down vote up
public static String getInvitationLink(Invitation i, String baseUrl) {
	String link = "";
	Room r = i.getRoom();
	User u = i.getInvitee();
	if (r != null) {
		if (r.isAppointment() && i.getInvitedBy().getId().equals(u.getId())) {
			link = getRoomUrlFragment(r.getId()).getLink();
		} else {
			boolean allowed = Type.CONTACT != u.getType() && Type.EXTERNAL != u.getType();
			if (allowed) {
				allowed = get().isRoomAllowedToUser(r, u);
			}
			if (allowed) {
				link = getRoomUrlFragment(r.getId()).getLink();
			} else {
				PageParameters pp = new PageParameters();
				pp.add(INVITATION_HASH, i.getHash());
				if (u.getLanguageId() > 0) {
					pp.add("language", u.getLanguageId());
				}
				link = urlForPage(HashPage.class, pp, baseUrl);
			}
		}
	}
	Recording rec = i.getRecording();
	if (rec != null) {
		link = urlForPage(HashPage.class, new PageParameters().add(INVITATION_HASH, i.getHash()), baseUrl);
	}
	return link;
}
 
Example 25
Source Project: yes-cart   Source File: WicketUtilTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testGetFilteredRequestParametersKeyName() throws Exception {

    final CommandConfig commandConfig = context.mock(CommandConfig.class, "config");

    context.checking(new Expectations() {{
        allowing(commandConfig).isCommandKey("asd"); will(returnValue(false));
        allowing(commandConfig).isCommandKey("toRemove"); will(returnValue(false));
        allowing(commandConfig).isCommandKey("cmd1"); will(returnValue(true));
    }});

    assertNotNull(new WicketUtil(commandConfig).getFilteredRequestParameters(null));
    PageParameters parametersToFilter = new PageParameters()
        .add("cmd1", "val1")
        .add("asd", "dsa")
        .add("toRemove", "ppp")
        .add("toRemove", "zzz");
    assertEquals(3, parametersToFilter.getNamedKeys().size());
    assertEquals(2, new WicketUtil(commandConfig).getFilteredRequestParameters(parametersToFilter).getNamedKeys().size());
    PageParameters filtered = new WicketUtil(commandConfig).getFilteredRequestParameters(parametersToFilter, "toRemove", null);
    assertNotNull(filtered);
    assertEquals(2, filtered.getNamedKeys().size());
    assertEquals("dsa", filtered.get("asd").toString());
    assertEquals("ppp", filtered.getValues("toRemove").get(0).toString());
    assertEquals("zzz", filtered.getValues("toRemove").get(1).toString());
    filtered = new WicketUtil(commandConfig).getFilteredRequestParameters(parametersToFilter, "toRemove", "zzz");
    assertNotNull(filtered);
    assertEquals(2, filtered.getNamedKeys().size());
    assertEquals("dsa", filtered.get("asd").toString());
    assertEquals(1, filtered.getValues("toRemove").size());
    assertEquals("ppp", filtered.getValues("toRemove").get(0).toString());
    filtered = new WicketUtil(commandConfig).getFilteredRequestParameters(parametersToFilter, "toRemove", "ppp");
    assertNotNull(filtered);
    assertEquals(2, filtered.getNamedKeys().size());
    assertEquals("dsa", filtered.get("asd").toString());
    assertEquals(1, filtered.getValues("toRemove").size());
    assertEquals("zzz", filtered.getValues("toRemove").get(0).toString());
}
 
Example 26
Source Project: yes-cart   Source File: WicketUtilTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testGetFilteredRequestParametersForSearch() {
    PageParameters parametersToFilter = new PageParameters()
        .add("query", "val1")
        .add("query", "val2")
        .add("query", "val3");
    assertEquals(1, parametersToFilter.getNamedKeys().size());
    assertEquals(3, parametersToFilter.getValues("query").size());
    parametersToFilter.remove("query", "val2");
    assertEquals(2, parametersToFilter.getValues("query").size());
    for (StringValue val : parametersToFilter.getValues("query")) {
        assertFalse("val2".equals(val.toString()));
    }
}
 
Example 27
Source Project: sakai   Source File: BasePage.java    License: Educational Community License v2.0 5 votes vote down vote up
/**
 * Send a user to the access denied page with a message
 * 
 * @param message the message
 */
public final void sendToAccessDeniedPage(final String message) {
	final PageParameters params = new PageParameters();
	params.add("message", message);
	log.debug("Redirecting to AccessDeniedPage: " + message);
	throw new RestartResponseException(AccessDeniedPage.class, params);
}
 
Example 28
Source Project: openmeetings   Source File: TestHashPage.java    License: Apache License 2.0 5 votes vote down vote up
private void checkMainPanel(PageParameters pp, Class<? extends Panel> clazz) {
	HashPage page = commonCheck(pp);
	tester.assertComponent(PANEL_MAIN, MainPanel.class);
	tester.assertInvisible("header");

	WebSocketTester webSocketTester = new WebSocketTester(tester, page);
	webSocketTester.sendMessage(CONNECTED_MSG);
	tester.assertComponent(String.format("%s:contents:%s", PANEL_MAIN, CHILD_ID), clazz);
}
 
Example 29
Source Project: onedev   Source File: ModeUrlResourceReference.java    License: MIT License 5 votes vote down vote up
@Override
public List<HeaderItem> getDependencies() {
	List<HeaderItem> dependencies = super.getDependencies();
	WebjarsJavaScriptResourceReference metaReference = new WebjarsJavaScriptResourceReference("codemirror/current/mode/meta.js");
	String modeBase = StringUtils.substringBeforeLast(RequestCycle.get().urlFor(metaReference, new PageParameters()).toString(), "/");
	dependencies.add(OnDomReadyHeaderItem.forScript("CodeMirror.modeURL = '" + modeBase + "/%N/%N.js';"));		
	return dependencies;
}
 
Example 30
Source Project: onedev   Source File: JobDefLink.java    License: MIT License 5 votes vote down vote up
@Override
public PageParameters getPageParameters() {
	ProjectBlobPage.State state = new ProjectBlobPage.State();
	state.blobIdent = new BlobIdent(commitId.name(), BuildSpec.BLOB_PATH, FileMode.REGULAR_FILE.getBits()); 
	if (getProject().getBlob(state.blobIdent, false) == null)
		state.blobIdent = new BlobIdent(commitId.name(), ".onedev-buildspec", FileMode.REGULAR_FILE.getBits());
	state.position = BuildSpecRendererProvider.getPosition(Job.SELECTION_PREFIX + jobName);
	return ProjectBlobPage.paramsOf(getProject(), state);
}