Java Code Examples for org.apache.wicket.request.mapper.parameter.PageParameters#add()

The following examples show how to use org.apache.wicket.request.mapper.parameter.PageParameters#add() . 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: ListSelectActionPanel.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Constructor for normal list view for selecting one entry to edit.
 * @param id component id
 * @param model model for contact
 * @param editPageClass The edit page to redirect to.
 * @param objectId The id of the object to edit in edit page.
 * @param label The label to show (additional to the row_pointer.png). The id of the label should be LABEL_ID.
 * @param params Pairs of params (key, value).
 * @see WicketUtils#getPageParameters(String[])
 */
public ListSelectActionPanel(final String id, final IModel< ? > model, final Class< ? extends WebPage> editPageClass,
    final Integer objectId, final WebPage returnToPage, final Label label, final String... params)
{
  super(id, model);
  setRenderBodyOnly(true);
  final Link< ? > link = new Link<Void>(LINK_ID) {
    @Override
    public void onClick()
    {
      final PageParameters pageParams = WicketUtils.getPageParameters(params);
      if (objectId != null) {
        pageParams.add(AbstractEditPage.PARAMETER_KEY_ID, String.valueOf(objectId));
      }
      final AbstractSecuredPage editPage = (AbstractSecuredPage) ReflectionHelper.newInstance(editPageClass, PageParameters.class,
          pageParams);
      if (editPage instanceof AbstractEditPage) {
        ((AbstractEditPage< ? , ? , ? >) editPage).setReturnToPage(returnToPage);
      }
      setResponsePage(editPage);
    };
  };
  add(link);
  add(label);
}
 
Example 2
Source File: ManageAddressesView.java    From yes-cart with Apache License 2.0 6 votes vote down vote up
/**
 * Extension hook to override classes for themes.
 *
 * @param isCheckout is this checkout address panel
 * @param addressId address PK or 0
 * @param addressType address type
 *
 * @return redirect target
 */
protected Pair<Class<? extends Page>, PageParameters> determineAddressPage(final boolean isCheckout,
                                                                           final long addressId,
                                                                           final String addressType) {

    final Class<? extends Page> successfulPage = (Class) wicketPagesMounter.getPageProviderByUri(getAddressPageUri()).get();
    final PageParameters parameters = new PageParameters();

    parameters.add(WebParametersKeys.ADDRESS_FORM_RETURN_LABEL,
            isCheckout ? CreateEditAddressPage.RETURN_TO_CHECKOUT : CreateEditAddressPage.RETURN_TO_PROFILE);
    parameters.add(WebParametersKeys.ADDRESS_ID, String.valueOf(addressId));
    parameters.add(WebParametersKeys.ADDRESS_TYPE, addressType);
    if (isCheckout) {
        parameters.add(CheckoutPage.STEP, CheckoutPage.STEP_ADDR);
    }

    return new Pair<>(successfulPage, parameters);
}
 
Example 3
Source File: PullRequestChangesPage.java    From onedev with MIT License 6 votes vote down vote up
public static void fillParams(PageParameters params, State state) {
	if (state.oldCommitHash != null)
		params.add(PARAM_OLD_COMMIT, state.oldCommitHash);
	if (state.newCommitHash != null)
		params.add(PARAM_NEW_COMMIT, state.newCommitHash);
	if (state.whitespaceOption != WhitespaceOption.DEFAULT)
		params.add(PARAM_WHITESPACE_OPTION, state.whitespaceOption.name());
	if (state.pathFilter != null)
		params.add(PARAM_PATH_FILTER, state.pathFilter);
	if (state.blameFile != null)
		params.add(PARAM_BLAME_FILE, state.blameFile);
	if (state.commentId != null)
		params.add(PARAM_COMMENT, state.commentId);
	if (state.mark != null)
		params.add(PARAM_MARK, state.mark.toString());
}
 
Example 4
Source File: RevisionComparePage.java    From onedev with MIT License 6 votes vote down vote up
public static void fillParams(PageParameters params, State state) {
	if (state.leftSide.getRevision() != null)
		params.add(PARAM_LEFT, state.leftSide.toString());
	else
		params.add(PARAM_LEFT, state.leftSide.getProjectId());
	if (state.rightSide.getRevision() != null)
		params.add(PARAM_RIGHT, state.rightSide.toString());
	else
		params.add(PARAM_RIGHT, state.rightSide.getProjectId());
	params.add(PARAM_COMPARE_WITH_MERGE_BASE, state.compareWithMergeBase);
	if (state.whitespaceOption != WhitespaceOption.DEFAULT)
		params.add(PARAM_WHITESPACE_OPTION, state.whitespaceOption.name());
	if (state.pathFilter != null)
		params.add(PARAM_PATH_FILTER, state.pathFilter);
	if (state.commitQuery != null)
		params.add(PARAM_COMMIT_QUERY, state.commitQuery);
	if (state.blameFile != null)
		params.add(PARAM_BLAME_FILE, state.blameFile);
	if (state.commentId != null)
		params.add(PARAM_COMMENT, state.commentId);
	if (state.mark != null)
		params.add(PARAM_MARK, state.mark.toString());
	if (state.tabPanel != null)
		params.add(PARAM_TAB, state.tabPanel.name());
}
 
Example 5
Source File: OIDCClientSelfReg.java    From syncope with Apache License 2.0 5 votes vote down vote up
public OIDCClientSelfReg(final PageParameters parameters) {
    super(parameters);

    PageParameters params = new PageParameters();
    try {
        params.add("oidcClientUserAttrs", ((ServletWebRequest) getRequest()).getContainerRequest().
                getSession().getAttribute(Constants.OIDCCLIENT_USER_ATTRS));
    } catch (Exception e) {
        LOG.error("While extracting user attributes", e);

        params.add("errorMessage", OIDC_ACCESS_ERROR);
    }
    setResponsePage(Self.class, params);
}
 
Example 6
Source File: AbstractMobileViewPage.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void addTopRightButton()
{
  final PageParameters params = new PageParameters();
  params.add(AbstractEditPage.PARAMETER_KEY_ID, data.getId());
  headerContainer.add(new JQueryButtonPanel(TOP_RIGHT_BUTTON_ID, JQueryButtonType.CHECK, AddressMobileEditPage.class, params,
      getString("edit")));
}
 
Example 7
Source File: TeamCalCalendarForm.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
private void redirectToImportPage(final List<VEvent> events, final TemplateEntry activeTemplate)
{
  final PageParameters parameters = new PageParameters();
  if (activeTemplate != null) {
    parameters.add(TeamCalImportPage.PARAM_KEY_TEAM_CAL_ID, activeTemplate.getDefaultCalendarId());
  }
  final TeamCalImportPage importPage = new TeamCalImportPage(parameters);
  importPage.setReturnToPage(parentPage);
  importPage.setEventsToImport(events);
  setResponsePage(importPage);
}
 
Example 8
Source File: BasePage.java    From sakai with 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 9
Source File: BuildListPage.java    From onedev with 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 10
Source File: ShoppingCartSavedItemsList.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
/**
 * Extension hook for sub classes.
 *
 * @param links links support
 * @param linkId link id
 * @param product product
 * @param itemData wish list item
 * @param qty quantity as string
 *
 * @return link
 */
@Override
protected Link determineAtbLink(final LinksSupport links,
                                final String linkId,
                                final ProductSearchResultDTO product,
                                final CustomerWishList itemData,
                                final String qty) {
    final PageParameters params = new PageParameters();
    for (final ProductSkuSearchResultDTO sku : product.getSearchSkus()) {
        if (sku.getCode().equals(itemData.getSkuCode())) {
            params.add(WebParametersKeys.SKU_ID, sku.getId());
        }
    }
    return links.newAddToCartLink(linkId, product.getFulfilmentCentreCode(), product.getDefaultSkuCode(), qty, String.valueOf(itemData.getCustomerwishlistId()), (Class) getPage().getClass(), params);
}
 
Example 11
Source File: ProjectIssueListPage.java    From onedev with MIT License 5 votes vote down vote up
public static PageParameters paramsOf(Project project, @Nullable String query, int page) {
	PageParameters params = paramsOf(project);
	if (query != null)
		params.add(PARAM_QUERY, query);
	if (page != 0)
		params.add(PARAM_PAGE, page);
	return params;
}
 
Example 12
Source File: SAML2SPSelfReg.java    From syncope with Apache License 2.0 5 votes vote down vote up
public SAML2SPSelfReg(final PageParameters parameters) {
    super(parameters);

    PageParameters params = new PageParameters();
    params.add("errorMessage", SAML_ACCESS_ERROR);
    setResponsePage(Login.class, params);
}
 
Example 13
Source File: WbWebSocketHelper.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
public static JSONObject addFileUrl(String ruid, JSONObject _file, BaseFileItem fi, Client c) {
	JSONObject file = new JSONObject(_file.toString(new NullStringer()));
	final FileSystemResourceReference ref;
	final PageParameters pp = new PageParameters()
			.add("id", fi.getId())
			.add("ruid", ruid)
			.add("wuid", _file.optString("uid"));
	if (c != null) {
		pp.add("uid", c.getUid());
	}
	file.put("deleted", !fi.exists());
	switch (fi.getType()) {
		case VIDEO:
			ref = new RoomResourceReference();
			file.put(PARAM__SRC, urlFor(ref, pp));
			file.put(PARAM__POSTER, urlFor(new RoomPreviewResourceReference(), pp));
			break;
		case RECORDING:
			ref = new Mp4RecordingResourceReference();
			file.put(PARAM__SRC, urlFor(ref, pp));
			file.put(PARAM__POSTER, urlFor(new PngRecordingResourceReference(), pp));
			break;
		case PRESENTATION:
			ref = new RoomResourceReference();
			file.put(PARAM__SRC, urlFor(ref, pp));
			break;
		default:
			ref = new RoomResourceReference();
			file.put(PARAM_SRC, urlFor(ref, pp));
			break;
	}
	return file;
}
 
Example 14
Source File: TutorialPage.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
private PageParameters createEditPageParameters(final BaseDO< ? > obj)
{
  final PageParameters params = new PageParameters();
  params.add(AbstractEditPage.PARAMETER_KEY_ID, obj.getId());
  return params;
}
 
Example 15
Source File: NewIssuePage.java    From onedev with MIT License 4 votes vote down vote up
public static PageParameters paramsOf(Project project, String query) {
	PageParameters params = paramsOf(project);
	if (query != null)
		params.add(PARAM_QUERY, query);
	return params;
}
 
Example 16
Source File: SyncopeUIRequestCycleListener.java    From syncope with Apache License 2.0 4 votes vote down vote up
@Override
public IRequestHandler onException(final RequestCycle cycle, final Exception e) {
    LOG.error("Exception found", e);

    PageParameters errorParameters = new PageParameters();

    IRequestablePage errorPage;
    if (instanceOf(e, UnauthorizedInstantiationException.class) != null) {
        errorParameters.add("errorMessage", BaseSession.Error.AUTHORIZATION.fallback());
        errorPage = getErrorPage(errorParameters);
    } else if (instanceOf(e, AccessControlException.class) != null) {
        if (StringUtils.containsIgnoreCase(instanceOf(e, AccessControlException.class).getMessage(), "expired")) {
            errorParameters.add("errorMessage", BaseSession.Error.SESSION_EXPIRED.fallback());
        } else {
            errorParameters.add("errorMessage", BaseSession.Error.AUTHORIZATION.fallback());
        }
        errorPage = getErrorPage(errorParameters);
    } else if (instanceOf(e, PageExpiredException.class) != null || !isSignedIn()) {
        errorParameters.add("errorMessage", BaseSession.Error.SESSION_EXPIRED.fallback());
        errorPage = getErrorPage(errorParameters);
    } else if (instanceOf(e, BadRequestException.class) != null
            || instanceOf(e, WebServiceException.class) != null
            || instanceOf(e, SyncopeClientException.class) != null) {

        errorParameters.add("errorMessage", BaseSession.Error.REST.fallback());
        errorPage = getErrorPage(errorParameters);
    } else {
        Throwable cause = instanceOf(e, ForbiddenException.class);
        if (cause == null) {
            // redirect to default Wicket error page
            errorPage = new ExceptionErrorPage(e, null);
        } else {
            errorParameters.add("errorMessage", cause.getMessage());
            errorPage = getErrorPage(errorParameters);
        }
    }

    if (errorPage instanceof BaseLogin) {
        try {
            invalidateSession();
        } catch (Throwable t) {
            // ignore
            LOG.debug("Unexpected error while forcing logout after error", t);
        }
    }

    return new RenderPageRequestHandler(new PageProvider(errorPage));
}
 
Example 17
Source File: AddressEditPage.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("serial")
public AddressEditPage(final PageParameters parameters)
{
  super(parameters, "address");
  init();
  if (isNew() == false) {
    ContentMenuEntryPanel menu = new ContentMenuEntryPanel(getNewContentMenuChildId(), new Link<Void>(ContentMenuEntryPanel.LINK_ID) {
      @Override
      public void onClick()
      {
        final Integer addressId = form.getData().getId();
        final PageParameters params = new PageParameters();
        params.add(AbstractEditPage.PARAMETER_KEY_ID, addressId);
        final AddressViewPage addressViewPage = new AddressViewPage(params);
        setResponsePage(addressViewPage);
      };
    }, getString("printView"));
    addContentMenuEntry(menu);

    final ContentMenuEntryPanel singleIcalExport = new ContentMenuEntryPanel(getNewContentMenuChildId(), new Link<Void>(ContentMenuEntryPanel.LINK_ID) {
      @Override
      public void onClick()
      {
        final AddressDO address = form.getData();
        final String filename = "ProjectForge-" + address.getFullName() + "_" + DateHelper.getDateAsFilenameSuffix(new Date()) + ".vcf";
        final StringWriter writer = new StringWriter();
        addressDao.exportVCard(new PrintWriter(writer), address);
        DownloadUtils.setUTF8CharacterEncoding(getResponse());
        DownloadUtils.setDownloadTarget(writer.toString().getBytes(), filename);
      };
    }, getString("address.book.vCardSingleExport"));
    addContentMenuEntry(singleIcalExport);


    if (ConfigXml.getInstance().isTelephoneSystemUrlConfigured() == true) {
      menu = new ContentMenuEntryPanel(getNewContentMenuChildId(), new Link<Void>(ContentMenuEntryPanel.LINK_ID) {
        @Override
        public void onClick()
        {
          final Integer addressId = form.getData().getId();
          final PageParameters params = new PageParameters();
          params.add(PhoneCallPage.PARAMETER_KEY_ADDRESS_ID, addressId);
          setResponsePage(new PhoneCallPage(params));
        };
      }, getString("address.directCall.call"));
      addContentMenuEntry(menu);
    }
  }
}
 
Example 18
Source File: PullRequestDetailPage.java    From onedev with MIT License 4 votes vote down vote up
public static PageParameters paramsOf(ProjectScopedNumber requestFQN) {
	PageParameters params = ProjectPage.paramsOf(requestFQN.getProject());
	params.add(PARAM_REQUEST, requestFQN.getNumber());
	return params;
}
 
Example 19
Source File: LinkUtils.java    From artifact-listener with Apache License 2.0 4 votes vote down vote up
public static PageParameters getUserHashPageParameters(User user) {
	PageParameters parameters = new PageParameters();
	parameters.add(HASH_PARAMETER, user.getNotificationHash());
	return parameters;
}
 
Example 20
Source File: TaskWizardForm.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("serial")
private void createGroupComponents(final int number, final String key)
{
  gridBuilder.newGridPanel();
  final DivPanel section = gridBuilder.getPanel();
  section.add(new Heading3Panel(section.newChildId(), String.valueOf(number) + ". " + getString("task.wizard." + key)));
  section.add(new DivTextPanel(section.newChildId(), getString("task.wizard." + key + ".intro")));
  {
    final FieldsetPanel fs = gridBuilder.newFieldset(getString("group")).suppressLabelForWarning();
    final NewGroupSelectPanel groupSelectPanel = new NewGroupSelectPanel(fs.newChildId(), new PropertyModel<GroupDO>(this, key), parentPage,
        key + "Id");
    fs.add(groupSelectPanel);
    groupSelectPanel.setShowFavorites(false).init();
    final Button createGroupButton = new Button("button", new Model<String>("createGroup" + key)) {
      @Override
      public final void onSubmit()
      {
        parentPage.managerGroupCreated = "managerGroup".equals(key);
        final PageParameters params = new PageParameters();
        final StringBuffer buf = new StringBuffer();
        if (task != null) {
          buf.append(task.getTitle());
        }
        if (parentPage.managerGroupCreated == true) {
          if (task != null) {
            buf.append("-");
          }
          buf.append(getString("task.wizard.managerGroup.groupNameSuffix"));
        }
        params.add(GroupEditPage.PARAM_GROUP_NAME, buf.toString());
        final GroupEditPage editPage = new GroupEditPage(params);
        editPage.setReturnToPage(parentPage);
        setResponsePage(editPage);
      }

      @Override
      public boolean isVisible()
      {
        return task != null;
      }
    };
    createGroupButton.setDefaultFormProcessing(false);
    final SingleButtonPanel createGroupButtonPanel = new SingleButtonPanel(fs.newChildId(), createGroupButton,
        getString("task.wizard.button.createGroup"), SingleButtonPanel.NORMAL);
    WicketUtils.addTooltip(createGroupButton, getString("task.wizard.button.createGroup.tooltip"));
    fs.add(createGroupButtonPanel);
  }
}