@Override public void handle(FacesContext context) throws IOException { Map<String, String> params = context.getExternalContext().getRequestParameterMap(); ExternalContext externalContext = context.getExternalContext(); String sessionKey = params.get(Constants.DYNAMIC_CONTENT_PARAM); Map<String, Object> session = externalContext.getSessionMap(); Map<String, String> barcodeMapping = (Map) session.get(Constants.BARCODE_MAPPING); String value = barcodeMapping.get(sessionKey); if (value != null) { boolean cache = Boolean.parseBoolean(params.get(Constants.DYNAMIC_CONTENT_CACHE_PARAM)); externalContext.setResponseStatus(200); externalContext.setResponseContentType("image/png"); handleCache(externalContext, cache); ErrorCorrectionLevel ecl = ErrorCorrectionLevel.L; String errorCorrection = params.get("qrec"); if (!LangUtils.isValueBlank(errorCorrection)) { ecl = ErrorCorrectionLevel.valueOf(errorCorrection); } QRCode.from(value).to(ImageType.PNG).withErrorCorrection(ecl).withCharset("UTF-8") .writeTo(externalContext.getResponseOutputStream()); externalContext.responseFlushBuffer(); context.responseComplete(); } }
!hostAddress.equals("127.0.0.1")){ String url = "http://"+hostAddress+":"+port; ByteArrayOutputStream bout = QRCode.from(url).to(ImageType.PNG).stream(); out.add(new PendantURLBean(url, bout.toByteArray())); System.out.println("Listening on: "+url);
public void handle(FacesContext context) throws IOException { Map<String, String> params = context.getExternalContext().getRequestParameterMap(); ExternalContext externalContext = context.getExternalContext(); String sessionKey = (String) params.get(Constants.DYNAMIC_CONTENT_PARAM); Map<String, Object> session = externalContext.getSessionMap(); Map<String, String> barcodeMapping = (Map) session.get(Constants.BARCODE_MAPPING); String value = barcodeMapping.get(sessionKey); if (value != null) { boolean cache = Boolean.valueOf(params.get(Constants.DYNAMIC_CONTENT_CACHE_PARAM)); externalContext.setResponseStatus(200); externalContext.setResponseContentType("image/png"); handleCache(externalContext, cache); ErrorCorrectionLevel ecl = ErrorCorrectionLevel.L; String errorCorrection = params.get("qrec"); if (!ComponentUtils.isValueBlank(errorCorrection)) { ecl = ErrorCorrectionLevel.valueOf(errorCorrection); } QRCode.from(value).to(ImageType.PNG).withErrorCorrection(ecl).withCharset("UTF-8") .writeTo(externalContext.getResponseOutputStream()); externalContext.responseFlushBuffer(); context.responseComplete(); } }
try imageBytes = QRCode.from( qrCodeContent ) .withCharset( PwmConstants.DEFAULT_CHARSET.toString() ) .withSize( width, height )