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.
Example 1
Project: yes-cart   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
Project: inception   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
Project: onedev   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
Project: syncope   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
Project: projectforge-webapp   File: AbstractMobileViewPage.java    License: GNU General Public License v3.0 6 votes vote down vote up
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
Project: yes-cart   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
Project: onedev   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
Project: artifact-listener   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
Project: the-app   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
Project: projectforge-webapp   File: DocumentationPage.java    License: GNU General Public License v3.0 6 votes vote down vote up
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
Project: sakai   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
Project: yes-cart   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
Project: Orienteer   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
Project: onedev   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
Project: projectforge-webapp   File: SkillTreePage.java    License: GNU General Public License v3.0 5 votes vote down vote up
public SkillTreePage(final ISelectCallerPage caller, final String selectProperty)
{
  super(new PageParameters());
  this.caller = caller;
  this.selectProperty = selectProperty;
  init();
}
 
Example 16
Project: wicket-spring-boot   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
Project: onedev   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
Project: yes-cart   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
Project: onedev   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
Project: syncope   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
Project: onedev   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
Project: onedev   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
Project: projectforge-webapp   File: LoginPageTest.java    License: GNU General Public License v3.0 5 votes vote down vote up
@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
Project: openmeetings   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
Project: yes-cart   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
Project: yes-cart   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
Project: sakai   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
Project: openmeetings   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
Project: onedev   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
Project: onedev   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);
}
 
Example 31
Project: projectforge-webapp   File: WicketUtils.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Tuples of parameters converted to Wicket parameters.
 * @param params
 * @return
 */
public static PageParameters getPageParameters(final String[] params)
{
  final PageParameters pageParameters = new PageParameters();
  if (params != null) {
    for (int i = 0; i < params.length; i += 2) {
      if (i + 1 < params.length) {
        pageParameters.add(params[i], params[i + 1]);
      } else {
        pageParameters.add(params[i], null);
      }
    }
  }
  return pageParameters;
}
 
Example 32
Project: onedev   File: ProjectDashboardPage.java    License: MIT License 5 votes vote down vote up
public ProjectDashboardPage(PageParameters params) {
	super(params);
	
	if (SecurityUtils.canReadCode(getProject()))
		throw new RestartResponseException(ProjectBlobPage.class, ProjectBlobPage.paramsOf(getProject()));
	else 
		throw new RestartResponseException(ProjectIssueListPage.class, ProjectIssueListPage.paramsOf(getProject()));
	
}
 
Example 33
Project: openmeetings   File: Application.java    License: Apache License 2.0 5 votes vote down vote up
public static String urlForPage(Class<? extends Page> clazz, PageParameters pp, String inBaseUrl) {
	RequestCycle rc = RequestCycle.get();
	String baseUrl = isUrlValid(inBaseUrl) ? inBaseUrl
			: (isUrlValid(getBaseUrl()) ? getBaseUrl() : "");
	if (!Strings.isEmpty(baseUrl) && !baseUrl.endsWith("/")) {
		baseUrl += "/";
	}
	return rc.getUrlRenderer().renderFullUrl(Url.parse(baseUrl + rc.mapUrlFor(clazz, pp)));
}
 
Example 34
Project: onedev   File: NewPullRequestPage.java    License: MIT License 5 votes vote down vote up
public static PageParameters paramsOf(Project project, ProjectAndBranch target, ProjectAndBranch source) {
	PageParameters params = paramsOf(project);
	if (target.getBranch() != null)
		params.set("target", target.toString());
	else
		params.set("target", target.getProjectId());
	if (source.getBranch() != null)
		params.set("source", source.toString());
	else
		params.set("source", source.getProjectId());
	return params;
}
 
Example 35
Project: openmeetings   File: MysqlPatcher.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected String getUrl(String inUrl, String host, String inPort, String inDb) {
	Url url = Url.parse(inUrl);
	url.setHost(host);
	url.setPort((inPort == null) ? 3306 : Integer.valueOf(inPort));
	url.getSegments().set(1, (inDb == null) ? DEFAULT_DB_NAME : inDb);
	PageParameters pp = new PageParametersEncoder().decodePageParameters(url);
	StringValue tz = pp.get(TZ_PARAM);
	if (tz.isEmpty()) {
		url.setQueryParameter(TZ_PARAM, TimeZone.getDefault().getID());
	}
	return url.toString(Url.StringMode.FULL);
}
 
Example 36
Project: sakai   File: UserPageSiteSearch.java    License: Educational Community License v2.0 5 votes vote down vote up
public UserPageSiteSearch(PageParameters params){
	String search = "";
	if(params.getNamedKeys().contains("search")){
		search = params.get("search").toString();
	}
	Map<String, Object> advancedFields = new HashMap<String, Object>();
	if(params.getNamedKeys().contains("term")){
		advancedFields.put(DelegatedAccessConstants.ADVANCED_SEARCH_TERM, params.get("term").toString());
	}
	if(params.getNamedKeys().contains("instructor")){
		advancedFields.put(DelegatedAccessConstants.ADVANCED_SEARCH_INSTRUCTOR, params.get("instructor").toString());
		//set type:
		String instructorType = DelegatedAccessConstants.ADVANCED_SEARCH_INSTRUCTOR_TYPE_INSTRUCTOR;
		if(params.getNamedKeys().contains("instructorType") && DelegatedAccessConstants.ADVANCED_SEARCH_INSTRUCTOR_TYPE_MEMBER.equals(params.get("instructorType").toString())){
			instructorType = DelegatedAccessConstants.ADVANCED_SEARCH_INSTRUCTOR_TYPE_MEMBER;
		}
		advancedFields.put(DelegatedAccessConstants.ADVANCED_SEARCH_INSTRUCTOR_TYPE, instructorType);
	}
	//we have at least one  hierarchy key/value:
	Map<String, String> hierarchyParams = new HashMap<String, String>();
	int i = 0;
	while(params.getNamedKeys().contains("hierarchyKey" + i) && params.getNamedKeys().contains("hierarchyValue" + i)){
		hierarchyParams.put(params.get("hierarchyKey").toString() + i, params.get("hierarchyValue").toString() + i);
		i++;
	}
	if(hierarchyParams.size() > 0){
		advancedFields.put(DelegatedAccessConstants.ADVANCED_SEARCH_HIERARCHY_FIELDS, hierarchyParams);
	}
	
	buildPage(search, advancedFields, false, false);
}
 
Example 37
Project: webanno   File: ProjectPage.java    License: Apache License 2.0 5 votes vote down vote up
public ProjectPage(final PageParameters aPageParameters)
{
    super(aPageParameters);
    
    commonInit();
   
    preSelectedModelMode = true;
    
    sidebar.setVisible(false);
    
    // Fetch project parameter
    StringValue projectParameter = aPageParameters.get(PAGE_PARAM_PROJECT_ID);
    // Check if we are asked to create a new project
    if (projectParameter != null && NEW_PROJECT_ID.equals(projectParameter.toString())) {
        selectedProject.setObject(new Project());
    }
    // Check if we are asked to open an existing project
    else {
        Optional<Project> project = getProjectFromParameters(projectParameter);
        if (project.isPresent()) {
            // Check access to project
            if (!projectService.isAdmin(project.get(), userRepository.getCurrentUser())) {
                error("You have no permission to access project [" + project.get().getId() + "]");
                setResponsePage(getApplication().getHomePage());
            }
            
            selectedProject.setObject(project.get());
        }
        else {
            error("Project [" + projectParameter + "] does not exist");
            setResponsePage(getApplication().getHomePage());
        }
    }
}
 
Example 38
Project: openmeetings   File: ProfileImageResourceReference.java    License: Apache License 2.0 5 votes vote down vote up
public static String getUrl(RequestCycle rc, User u) {
	String uri = u.getPictureUri();
	if (isRelative(uri)) {
		File img = OmFileHelper.getUserProfilePicture(u.getId(), uri);
		uri = rc.urlFor(new ProfileImageResourceReference()
				, new PageParameters().add("id", u.getId()).add("anticache", img.lastModified())).toString();
	}
	return uri;
}
 
Example 39
Project: Orienteer   File: BookmarkablePageLinkCommand.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected AbstractLink newLink(String id) {
	return new BookmarkablePageLink<T>(id, pageClass) {
		@Override
		public PageParameters getPageParameters() {
			return BookmarkablePageLinkCommand.this.getPageParameters();
		}
	};
}
 
Example 40
Project: yes-cart   File: PaginationSupportImpl.java    License: Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public void removePageParam(final PageParameters pageParameters) {
    pageParameters.remove(WebParametersKeys.PAGE);
}