org.apache.wicket.util.string.StringValue Java Examples
The following examples show how to use
org.apache.wicket.util.string.StringValue.
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: AnnotationPage.java From webanno with Apache License 2.0 | 6 votes |
public AnnotationPage() { super(); LOG.debug("Setting up annotation page without parameters"); setModel(Model.of(new AnnotatorStateImpl(Mode.ANNOTATION))); // Ensure that a user is set getModelObject().setUser(userRepository.getCurrentUser()); Map<String, StringValue> fragmentParameters = Session.get() .getMetaData(SessionMetaData.LOGIN_URL_FRAGMENT_PARAMS); StringValue focus = StringValue.valueOf(0); if (fragmentParameters != null) { // Clear the URL fragment parameters - we only use them once! Session.get().setMetaData(SessionMetaData.LOGIN_URL_FRAGMENT_PARAMS, null); StringValue project = fragmentParameters.get(PAGE_PARAM_PROJECT_ID); StringValue projectName = fragmentParameters.get(PAGE_PARAM_PROJECT_NAME); StringValue document = fragmentParameters.get(PAGE_PARAM_DOCUMENT_ID); StringValue name = fragmentParameters.get(PAGE_PARAM_DOCUMENT_NAME); focus = fragmentParameters.get(PAGE_PARAM_FOCUS); handleParameters(project, projectName, document, name, focus, false); } commonInit(focus); }
Example #2
Source File: MenuConfig.java From projectforge-webapp with GNU General Public License v3.0 | 6 votes |
/** * @param id */ @SuppressWarnings("serial") public MenuConfig(final String id, final Menu menu, final FavoritesMenu favoritesMenu) { super(id); configureLink = new WebMarkupContainer("configureLink"); add(configureLink); configureBehavior = new AbstractDefaultAjaxBehavior() { @Override protected void respond(final AjaxRequestTarget target) { final Request request = RequestCycle.get().getRequest(); final StringValue configuration = request.getPostParameters().getParameterValue("configuration"); final String xml = configuration.toString(""); if (log.isDebugEnabled() == true) { log.debug(xml); } favoritesMenu.readFromXml(xml); favoritesMenu.storeAsUserPref(); } }; add(configureBehavior); add(new MenuConfigContent("content", menu)); }
Example #3
Source File: DirectBuyRequestCycleListener.java From the-app with Apache License 2.0 | 6 votes |
@Override public void onBeginRequest(RequestCycle cycle) { StringValue directBuyParameterValue = cycle.getRequest().getRequestParameters().getParameterValue(DIRECT_BUY_PARAMETER); if (!directBuyParameterValue.isEmpty()) { try { ProductInfo productInfo = productService.findByQuery(ProductQuery.create().withUrlname(directBuyParameterValue.toString())); if (productInfo != null) { cart.addItem(productInfo); } else { ShopSession.get().error(String.format("Das Product '%s' konnte nicht gefunden werden.", directBuyParameterValue)); } Url urlWithoutDirectBuy = removeDirectBuyFromUrl(cycle); redirectTo(cycle, urlWithoutDirectBuy); } catch (Exception e) { ShopSession.get().error(DIRECT_BUY_PROCESSING_FAILED_MESSAGE); LOGGER.error(DIRECT_BUY_PROCESSING_FAILED_MESSAGE, e); } } }
Example #4
Source File: ConceptFeatureEditor.java From inception with Apache License 2.0 | 6 votes |
@Override public String[] getInputAsArray() { // If the web request includes the additional "identifier" parameter which is supposed // to contain the IRI of the selected item instead of its label, then we use that as the // value. WebRequest request = getWebRequest(); IRequestParameters requestParameters = request.getRequestParameters(); StringValue identifier = requestParameters .getParameterValue(getInputName() + ":identifier"); if (!identifier.isEmpty()) { return new String[] { identifier.toString() }; } return super.getInputAsArray(); }
Example #5
Source File: WicketUtil.java From yes-cart with Apache License 2.0 | 6 votes |
/** * Transform wicket 1.5 page parameter to more traditional map. Expensive operation. * * @param pageParameters given parameters to transform. * @return parameters transformed to map */ public Map<String, List<String>> pageParametersAsMultiMap(final PageParameters pageParameters) { final Map<String, List<String>> map = new LinkedHashMap<>(); if (pageParameters != null) { for (String key : pageParameters.getNamedKeys()) { if (!commandConfig.isInternalCommandKey(key)) { final List<String> vals = new ArrayList<>(); for (final StringValue value : pageParameters.getValues(key)) { vals.add(value.toString()); } map.put(key, vals); } } } return map; }
Example #6
Source File: AjaxWlPage.java From yes-cart with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override protected void onBeforeRender() { executeHttpPostedCommands(); final StringValue skuValue = getPageParameters().get(ShoppingCartCommand.CMD_ADDTOWISHLIST); final String sku = skuValue.toString(); final StringBuilder outJson = new StringBuilder(); outJson.append("{ \"SKU\": \"").append(sku.replace("\"", "")).append("\" }"); addOrReplace(new Label("wlAddedObj", outJson.toString()).setEscapeModelStrings(false)); super.onBeforeRender(); persistCartIfNecessary(); }
Example #7
Source File: RecordingResourceReference.java From openmeetings with Apache License 2.0 | 6 votes |
@Override protected Recording getFileItem(Attributes attributes) { PageParameters params = attributes.getParameters(); StringValue _id = params.get("id"); String ruid = params.get("ruid").toString(); String uid = params.get("uid").toString(); Long id = null; try { id = _id.toOptionalLong(); } catch (Exception e) { //no-op expected } WebSession ws = WebSession.get(); if (id == null && ws.signIn(_id.toString(), true)) { id = getRecordingId(); } if (id != null && ws.isSignedIn()) { return getRecording(id, ruid, uid); } return null; }
Example #8
Source File: DirectBuyRequestCycleListener.java From AppStash with Apache License 2.0 | 6 votes |
@Override public void onBeginRequest(RequestCycle cycle) { StringValue directBuyParameterValue = cycle.getRequest().getRequestParameters().getParameterValue(DIRECT_BUY_PARAMETER); if (!directBuyParameterValue.isEmpty()) { try { ProductInfo productInfo = productService.findByQuery(ProductQuery.create().withUrlname(directBuyParameterValue.toString())); if (productInfo != null) { cart.addItem(productInfo); } else { ShopSession.get().error(String.format("Das Product '%s' konnte nicht gefunden werden.", directBuyParameterValue)); } Url urlWithoutDirectBuy = removeDirectBuyFromUrl(cycle); redirectTo(cycle, urlWithoutDirectBuy); } catch (Exception e) { ShopSession.get().error(DIRECT_BUY_PROCESSING_FAILED_MESSAGE); LOGGER.error(DIRECT_BUY_PROCESSING_FAILED_MESSAGE, e); } } }
Example #9
Source File: CustomerEditPage.java From wicket-spring-boot with Apache License 2.0 | 6 votes |
public CustomerEditPage(PageParameters params){ super(); StringValue customerIdParam = params.get(CUSTOMER_ID_PARAM); if(customerIdParam.isEmpty() || !StringUtils.isNumeric(customerIdParam.toString())){ getSession().error(MessageFormat.format(getString("param.customer.id.missing"), customerIdParam)); // "Missing customer id " + stringValue setResponsePage(CustomerListPage.class); } Long customerId = customerIdParam.toLong(); Customer customer = service.findById(customerId); if(customer == null){ getSession().error(MessageFormat.format(getString("customer.not-found"), customerId.toString())); setResponsePage(CustomerListPage.class); } StringValue pageReferfenceIdParam = params.get(PAGE_REFERENCE_ID); if(!pageReferfenceIdParam.isEmpty() || StringUtils.isNumeric(pageReferfenceIdParam.toString())){ setPageReferenceId(pageReferfenceIdParam.toInteger()); } getCustomerModel().setObject(customer); }
Example #10
Source File: CurationPage.java From webanno with Apache License 2.0 | 6 votes |
public CurationPage() { super(); LOG.debug("Setting up curation page without parameters"); commonInit(); Map<String, StringValue> fragmentParameters = Session.get() .getMetaData(SessionMetaData.LOGIN_URL_FRAGMENT_PARAMS); if (fragmentParameters != null) { // Clear the URL fragment parameters - we only use them once! Session.get().setMetaData(SessionMetaData.LOGIN_URL_FRAGMENT_PARAMS, null); StringValue project = fragmentParameters.get(PAGE_PARAM_PROJECT_ID); StringValue document = fragmentParameters.get(PAGE_PARAM_DOCUMENT_ID); StringValue focus = fragmentParameters.get(PAGE_PARAM_FOCUS); handleParameters(null, project, document, focus, false); } }
Example #11
Source File: AnnotationPage.java From webanno with Apache License 2.0 | 6 votes |
public AnnotationPage(final PageParameters aPageParameters) { super(aPageParameters); LOG.debug("Setting up annotation page with parameters: {}", aPageParameters); setModel(Model.of(new AnnotatorStateImpl(Mode.ANNOTATION))); // Ensure that a user is set getModelObject().setUser(userRepository.getCurrentUser()); StringValue project = aPageParameters.get(PAGE_PARAM_PROJECT_ID); StringValue projectName = aPageParameters.get(PAGE_PARAM_PROJECT_NAME); StringValue document = aPageParameters.get(PAGE_PARAM_DOCUMENT_ID); StringValue name = aPageParameters.get(PAGE_PARAM_DOCUMENT_NAME); StringValue focus = aPageParameters.get(PAGE_PARAM_FOCUS); if (focus == null) { focus = StringValue.valueOf(0); } handleParameters(project, projectName, document, name, focus, true); commonInit(focus); }
Example #12
Source File: LoginPage.java From webanno with Apache License 2.0 | 6 votes |
private void setDefaultResponsePageIfNecessary() { // This does not work because it was Spring Security that intercepted the access, not // Wicket continueToOriginalDestination(); String redirectUrl = getRedirectUrl(); if (redirectUrl == null || redirectUrl.contains(".IBehaviorListener.") || redirectUrl.contains("-logoutPanel-")) { log.debug("Redirecting to welcome page"); setResponsePage(getApplication().getHomePage()); } else { log.debug("Redirecting to saved URL: [{}]", redirectUrl); if (isNotBlank(form.urlfragment) && form.urlfragment.startsWith("!")) { Url url = Url.parse("http://dummy?" + form.urlfragment.substring(1)); UrlRequestParametersAdapter adapter = new UrlRequestParametersAdapter(url); LinkedHashMap<String, StringValue> params = new LinkedHashMap<>(); for (String name : adapter.getParameterNames()) { params.put(name, adapter.getParameterValue(name)); } Session.get().setMetaData(SessionMetaData.LOGIN_URL_FRAGMENT_PARAMS, params); } throw new NonResettingRestartException(redirectUrl); } }
Example #13
Source File: AbstractBpmnProcessResource.java From syncope with Apache License 2.0 | 5 votes |
protected BpmnProcess getBpmnProcess(final Attributes attributes) { StringValue modelId = attributes.getRequest().getQueryParameters().getParameterValue(Constants.MODEL_ID_PARAM); BpmnProcess bpmnProcess = modelId == null || modelId.isNull() ? null : BpmnProcessRestClient.getDefinitions().stream(). filter(object -> modelId.toString().equals(object.getModelId())).findAny().orElse(null); if (bpmnProcess == null) { throw new NotFoundException("BPMN process with modelId " + modelId); } return bpmnProcess; }
Example #14
Source File: HelloDbResponse.java From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License | 5 votes |
private byte[] getDataFromDatabase(final StringValue queriesParam, final int queries) throws SQLException, JsonProcessingException { final ThreadLocalRandom random = ThreadLocalRandom.current(); DataSource dataSource = WicketApplication.get().getDataSource(); World[] worlds = new World[queries]; try (Connection connection = dataSource.getConnection()) { try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM World WHERE id = ?", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)) { for (int i = 0; i < queries; i++) { statement.setInt(1, random.nextInt(DB_ROWS) + 1); try (ResultSet resultSet = statement.executeQuery()) { resultSet.next(); worlds[i] = new World(resultSet.getInt("id"), resultSet.getInt("randomNumber")); } } } } byte[] data; if (queriesParam.isNull()) { // request to /db should return JSON object data = HelloJsonResponse.MAPPER.writeValueAsBytes(worlds[0]); } else { // request to /db?queries=xyz should return JSON array (issue #648) data = HelloJsonResponse.MAPPER.writeValueAsBytes(worlds); } return data; }
Example #15
Source File: WicketUtils.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
public static String getAsString(final PageParameters parameters, final String name) { final StringValue sval = parameters.get(name); if (sval == null || sval.isNull() == true) { return null; } else { return sval.toString(); } }
Example #16
Source File: HelloDbResponse.java From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void respond(Attributes attributes) { final StringValue queriesParam = attributes.getRequest().getQueryParameters().getParameterValue("queries"); int qs = queriesParam.toInt(1); if (qs < 1) { qs = 1; } else if (qs > 500) { qs = 500; } final int queries = qs; try { byte[] data = getDataFromDatabase(queriesParam, queries); final WebResponse webResponse = (WebResponse) attributes.getResponse(); webResponse.setContentLength(data.length); webResponse.setContentType(HelloJsonResponse.APPLICATION_JSON); webResponse.write(data); } catch (Exception ex) { WebResponse response = (WebResponse) attributes.getResponse(); response.setContentType(TEXT_PLAIN); response.setStatus(500); response.write(ex.getClass().getSimpleName() + ": " + ex.getMessage()); ex.printStackTrace(); } }
Example #17
Source File: TransparentParameterPageEncoder.java From Orienteer with Apache License 2.0 | 5 votes |
@Override public Url encodePageParameters(PageParameters pageParameters) { StringValue sv = pageParameters.get(parameter); if (!sv.isEmpty()) { pageParameters.remove(parameter); } Url ret = super.encodePageParameters(pageParameters); if (!sv.isEmpty()) { pageParameters.add(parameter, sv.toString()); } return ret; }
Example #18
Source File: WicketUtils.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
public static boolean contains(final PageParameters parameters, final String name) { final StringValue sval = parameters.get(name); if (sval == null) { return false; } else { return sval.isNull() == false; } }
Example #19
Source File: AgreementPage.java From webanno with Apache License 2.0 | 5 votes |
private Optional<Project> getProjectFromParameters(StringValue projectParam) { if (projectParam == null || projectParam.isEmpty()) { return Optional.empty(); } try { return Optional.of(projectService.getProject(projectParam.toLong())); } catch (NoResultException e) { return Optional.empty(); } }
Example #20
Source File: AgreementPage.java From webanno with Apache License 2.0 | 5 votes |
public AgreementPage(final PageParameters aPageParameters) { super(aPageParameters); commonInit(); projectSelectionForm.setVisibilityAllowed(false); User user = userRepository.getCurrentUser(); // Get current project from parameters StringValue projectParameter = aPageParameters.get(PAGE_PARAM_PROJECT_ID); Optional<Project> project = getProjectFromParameters(projectParameter); if (project.isPresent()) { Project p = project.get(); // Check access to project if (!(projectService.isCurator(p, user) || projectService.isManager(p, user))) { error("You have no permission to access project [" + p.getId() + "]"); setResponsePage(getApplication().getHomePage()); } projectSelectionForm.getModelObject().project = p; } else { error("Project [" + projectParameter + "] does not exist"); setResponsePage(getApplication().getHomePage()); } }
Example #21
Source File: WicketUtils.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
public static Object getAsObject(final PageParameters parameters, final String name, final Class< ? > type) { final StringValue sval = parameters.get(name); if (sval == null || sval.isNull() == true) { return null; } else { return sval.to(type); } }
Example #22
Source File: MonitoringPage.java From webanno with Apache License 2.0 | 5 votes |
private Optional<Project> getProjectFromParameters(StringValue projectParam) { if (projectParam == null || projectParam.isEmpty()) { return Optional.empty(); } try { return Optional.of(projectService.getProject(projectParam.toLong())); } catch (NoResultException e) { return Optional.empty(); } }
Example #23
Source File: MonitoringPage.java From webanno with Apache License 2.0 | 5 votes |
public MonitoringPage(final PageParameters aPageParameters) { super(aPageParameters); commonInit(); projectSelectionForm.setVisibilityAllowed(false); User user = userRepository.getCurrentUser(); // Get current project from parameters StringValue projectParameter = aPageParameters.get(PAGE_PARAM_PROJECT_ID); Optional<Project> project = getProjectFromParameters(projectParameter); if (project.isPresent()) { // Check access to project if (project != null && !(projectService.isCurator(project.get(), user) || projectService.isManager(project.get(), user))) { error("You have no permission to access project [" + project.get().getId() + "]"); setResponsePage(getApplication().getHomePage()); } projectSelectionForm.selectProject(project.get()); } else { error("Project [" + projectParameter + "] does not exist"); setResponsePage(getApplication().getHomePage()); } }
Example #24
Source File: AnnotationPage.java From webanno with Apache License 2.0 | 5 votes |
private UrlParametersReceivingBehavior createUrlFragmentBehavior() { return new UrlParametersReceivingBehavior() { private static final long serialVersionUID = -3860933016636718816L; @Override protected void onParameterArrival(IRequestParameters aRequestParameters, AjaxRequestTarget aTarget) { StringValue project = aRequestParameters.getParameterValue(PAGE_PARAM_PROJECT_ID); StringValue projectName = aRequestParameters.getParameterValue(PAGE_PARAM_PROJECT_NAME); StringValue document = aRequestParameters.getParameterValue(PAGE_PARAM_DOCUMENT_ID); StringValue name = aRequestParameters.getParameterValue(PAGE_PARAM_DOCUMENT_NAME); StringValue focus = aRequestParameters.getParameterValue(PAGE_PARAM_FOCUS); // nothing changed, do not check for project, because inception always opens // on a project if (document.isEmpty() && name.isEmpty() && focus.isEmpty()) { return; } SourceDocument previousDoc = getModelObject().getDocument(); handleParameters(project, projectName, document, name, focus, false); // url is from external link, not just paging through documents, // tabs may have changed depending on user rights if (previousDoc == null) { leftSidebar.refreshTabs(aTarget); } updateDocumentView(aTarget, previousDoc, focus); } }; }
Example #25
Source File: AnnotationPage.java From webanno with Apache License 2.0 | 5 votes |
private SourceDocument getDocumentFromParameters(Project aProject, StringValue documentParam, StringValue nameParam) { SourceDocument document = null; if (documentParam != null && !documentParam.isEmpty()) { long documentId = documentParam.toLong(); document = documentService.getSourceDocument(aProject.getId(), documentId); } else if (nameParam != null && !nameParam.isEmpty()) { document = documentService.getSourceDocument(aProject, nameParam.toString()); } return document; }
Example #26
Source File: AnnotationPage.java From webanno with Apache License 2.0 | 5 votes |
private Project getProjectFromParameters(StringValue projectParam, StringValue projectNameParam) { Project project = null; if (projectParam != null && !projectParam.isEmpty()) { long projectId = projectParam.toLong(); project = projectService.getProject(projectId); } else if (projectNameParam != null && !projectNameParam.isEmpty()) { project = projectService.getProject(projectNameParam.toString()); } return project; }
Example #27
Source File: AnnotationPage.java From webanno with Apache License 2.0 | 5 votes |
protected void commonInit(StringValue focus) { createChildComponents(); SourceDocument doc = getModelObject().getDocument(); updateDocumentView(null, doc, focus); }
Example #28
Source File: AddressCampaignValueEditPage.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
public AddressCampaignValueEditPage(final PageParameters parameters) { super(parameters, "plugins.marketing.addressCampaign"); StringValue sval = parameters.get(AbstractEditPage.PARAMETER_KEY_ID); final Integer id = sval.isEmpty() == true ? null : sval.toInteger(); if (id == null) { // Create new entry. sval = parameters.get(PARAMETER_ADDRESS_ID); final Integer addressId = sval.isEmpty() ? null : sval.toInteger(); sval = parameters.get(PARAMETER_ADDRESS_CAMPAIGN_ID); final Integer addressCampaignId = sval.isEmpty() || "null".equals(sval.toString()) ? null : sval.toInteger(); if (addressId == null || addressCampaignId == null) { throw new UserException("plugins.marketing.addressCampaignValue.error.addressOrCampaignNotGiven"); } final AddressDO address = addressDao.getById(addressId); final AddressCampaignDO addressCampaign = addressCampaignDao.getById(addressCampaignId); if (address == null || addressCampaign == null) { throw new UserException("plugins.marketing.addressCampaignValue.error.addressOrCampaignNotGiven"); } AddressCampaignValueDO data = addressCampaignValueDao.get(addressId, addressCampaignId); if (data == null) { data = new AddressCampaignValueDO(); data.setAddress(address); data.setAddressCampaign(addressCampaign); } init(data); } else { init(); } }
Example #29
Source File: KnowledgeBasePage.java From inception with Apache License 2.0 | 5 votes |
public KnowledgeBasePage(PageParameters aPageParameters) { super(aPageParameters); User user = userRepository.getCurrentUser(); // Project has been specified when the page was opened Project project = null; StringValue projectParam = aPageParameters.get(PAGE_PARAM_PROJECT_ID); if (!projectParam.isEmpty()) { long projectId = projectParam.toLong(); try { project = projectService.getProject(projectId); // Check access to project if (!projectService.isAnnotator(project, user)) { error("You have no permission to access project [" + project.getId() + "]"); abort(); } } catch (NoResultException e) { error("Project [" + projectId + "] does not exist"); abort(); } } // If a KB id was specified in the URL, we try to get it KnowledgeBase kb = null; String kbName = aPageParameters.get("kb").toOptionalString(); if (project != null && kbName != null) { kb = kbService.getKnowledgeBaseByName(project, kbName).orElse(null); } commonInit(project, kb); }
Example #30
Source File: CartRequestCycleListener.java From AppStash with Apache License 2.0 | 5 votes |
@Override public void onBeginRequest(RequestCycle cycle) { StringValue cartParameterValue = cycle.getRequest().getRequestParameters().getParameterValue(CART_PARAMETER); if (!cartParameterValue.isEmpty()) { try { selectedRedisMicroserviceCart(); cart.setCartId(cartParameterValue.toString()); LOGGER.info(String.format("Session '%s' set cart '%s'", ShopSession.get().getId(), cartParameterValue.toString())); } catch (Exception e) { LOGGER.error("Cart processing failed:", e); } } }