Java Code Examples for org.apache.wicket.util.string.StringValue#isEmpty()
The following examples show how to use
org.apache.wicket.util.string.StringValue#isEmpty() .
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: 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 2
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 3
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 4
Source File: CurationPage.java From webanno with Apache License 2.0 | 5 votes |
private Project getProjectFromParameters(StringValue projectParam) { Project project = null; if (projectParam != null && !projectParam.isEmpty()) { long projectId = projectParam.toLong(); project = projectService.getProject(projectId); } return project; }
Example 5
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 6
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 7
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 8
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 9
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 10
Source File: ProjectPage.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 11
Source File: BratAnnotationEditor.java From webanno with Apache License 2.0 | 5 votes |
private Object actionDoAction(AjaxRequestTarget aTarget, IRequestParameters request, CAS aCas, VID paramId) throws AnnotationException, IOException { StringValue layerParam = request.getParameterValue(PARAM_SPAN_TYPE); if (!layerParam.isEmpty()) { long layerId = decodeTypeName(layerParam.toString()); AnnotatorState state = getModelObject(); AnnotationLayer layer = annotationService.getLayer(state.getProject(), layerId) .orElseThrow(() -> new AnnotationException("Layer with ID [" + layerId + "] does not exist in project [" + state.getProject().getName() + "](" + state.getProject().getId() + ")")); if (!StringUtils.isEmpty(layer.getOnClickJavascriptAction())) { // parse the action List<AnnotationFeature> features = annotationService.listSupportedFeatures(layer); AnnotationFS anno = selectAnnotationByAddr(aCas, paramId.getId()); Map<String, Object> functionParams = OnClickActionParser.parse(layer, features, getModelObject().getDocument(), anno); // define anonymous function, fill the body and immediately execute String js = String.format("(function ($PARAM){ %s })(%s)", layer.getOnClickJavascriptAction(), JSONUtil.toJsonString(functionParams)); aTarget.appendJavaScript(js); } } return null; }
Example 12
Source File: CurationPage.java From webanno with Apache License 2.0 | 5 votes |
private SourceDocument getDocumentFromParameters(Project aProject, StringValue documentParam) { SourceDocument document = null; if (documentParam != null && !documentParam.isEmpty()) { long documentId = documentParam.toLong(); document = documentService.getSourceDocument(aProject.getId(), documentId); } return document; }
Example 13
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 14
Source File: BasePage.java From openmeetings with Apache License 2.0 | 5 votes |
protected OmUrlFragment getUrlFragment(IRequestParameters params) { for (AreaKeys key : AreaKeys.values()) { StringValue type = params.getParameterValue(key.name()); if (!type.isEmpty()) { return new OmUrlFragment(key, type.toString()); } } return null; }
Example 15
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); } } }
Example 16
Source File: CartRequestCycleListener.java From the-app 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); } } }
Example 17
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 18
Source File: BratAnnotationEditor.java From webanno with Apache License 2.0 | 4 votes |
private Object actionLookupNormData(AjaxRequestTarget aTarget, IRequestParameters request, VID paramId) throws AnnotationException, IOException { NormDataResponse response = new NormDataResponse(); // We interpret the databaseParam as the feature which we need to look up the feature // support StringValue databaseParam = request.getParameterValue("database"); // We interpret the key as the feature value or as a kind of query to be handled by the // feature support StringValue keyParam = request.getParameterValue("key"); StringValue layerParam = request.getParameterValue(PARAM_SPAN_TYPE); if (layerParam.isEmpty() || keyParam.isEmpty() || databaseParam.isEmpty()) { return response; } String database = databaseParam.toString(); long layerId = decodeTypeName(layerParam.toString()); AnnotatorState state = getModelObject(); AnnotationLayer layer = annotationService.getLayer(state.getProject(), layerId) .orElseThrow(() -> new AnnotationException("Layer with ID [" + layerId + "] does not exist in project [" + state.getProject().getName() + "](" + state.getProject().getId() + ")")); AnnotationFeature feature = annotationService.getFeature(database, layer); // Check where the query needs to be routed: to an editor extension or to a feature support if (paramId.isSynthetic()) { String extensionId = paramId.getExtensionId(); response.setResults(extensionRegistry.getExtension(extensionId) .renderLazyDetails(state.getDocument(), state.getUser(), paramId, feature, keyParam.toString()).stream() .map(d -> new NormalizationQueryResult(d.getLabel(), d.getValue())) .collect(Collectors.toList())); return response; } try { response.setResults(featureSupportRegistry.findExtension(feature) .renderLazyDetails(feature, keyParam.toString()).stream() .map(d -> new NormalizationQueryResult(d.getLabel(), d.getValue())) .collect(Collectors.toList())); } catch (Exception e) { LOG.error("Unable to load data", e); error("Unable to load data: " + ExceptionUtils.getRootCauseMessage(e)); } return response; }
Example 19
Source File: ClientManager.java From openmeetings with Apache License 2.0 | 4 votes |
Optional<InstantToken> getToken(StringValue uuid) { log.debug("Cluster:: Checking token {}, full list: {}", uuid, tokens().entrySet()); return uuid.isEmpty() ? Optional.empty() : Optional.ofNullable(tokens().remove(uuid.toString())); }
Example 20
Source File: ShoppingCartPage.java From yes-cart with Apache License 2.0 | 4 votes |
@Override protected void onBeforeRender() { executeHttpPostedCommands(); addOrReplace( new FeedbackPanel(FEEDBACK) ).addOrReplace( new ShoppingCartView(CART_VIEW) ).addOrReplace( new StandardFooter(FOOTER) ).addOrReplace( new StandardHeader(HEADER) ).addOrReplace( new ServerSideJs("serverSideJs") ).addOrReplace( new HeaderMetaInclude("headerInclude") ); final PageParameters params = getPageParameters(); final StringValue checkoutError = params.get("e"); if (!checkoutError.isEmpty()) { if ("ec".equals(checkoutError.toString())) { warn(getLocalizer().getString("orderErrorCouponInvalid", this, new Model<>(new ValueMap(Collections.singletonMap("coupon", params.get("ec").toString()))))); } else if ("es".equals(checkoutError.toString())) { warn(getLocalizer().getString("orderErrorSkuInvalid", this, new Model<>(new ValueMap(Collections.singletonMap("sku", params.get("es").toString()))))); } else { error(getLocalizer().getString("orderErrorGeneral", this)); } } addOrReplace(new WishListNotification("wishListNotification")); super.onBeforeRender(); final ShoppingCart cart = getCurrentCart(); final boolean cartModified = cart.isModified(); if (!cartModified && cart.getCartItemsCount() > 0) { // Refresh prices on cart view getShoppingCartCommandFactory().execute(ShoppingCartCommand.CMD_RECALCULATEPRICE, cart, (Map) Collections.singletonMap(ShoppingCartCommand.CMD_RECALCULATEPRICE, ShoppingCartCommand.CMD_RECALCULATEPRICE)); } persistCartIfNecessary(); if (cartModified) { // redirect to clear all command parameters throw new RestartResponseException(ShoppingCartPage.class); } }