/** {@inheritDoc} */ public void get(HttpServletRequest req, HttpServletResponse res, WebContext ctx) throws IOException { ctx.setVariable(KEY_TITLE, "Not Found "); }
/** {@inheritDoc} */ public void get(HttpServletRequest req, HttpServletResponse res, WebContext ctx) throws IOException { ctx.setVariable(KEY_TITLE, "About "); }
WebContext wc=new WebContext(request,response,servletContext,request.getLocale());//servletContext Spring Context MimeMessage message = this.mailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(message, true); wc.setVariable("name", "abc");// If you want to pass params to Template final String htmlContent = this.templateEngine.process("TemplateName", wc);
WebContext ctx = new WebContext(request, servletContext, request.getLocale()); ctx.setVariable("today", dateFormat.format(cal.getTime()));
/** {@inheritDoc} */ public void get(HttpServletRequest req, HttpServletResponse res, WebContext ctx) throws Exception { ctx.setVariable(KEY_TITLE, "Home"); ctx.setVariable("today", Calendar.getInstance()); HomeBean hb = new HomeBean(); try { hb = new HomeBean(ff4j); } catch(RuntimeException e) { LOGGER.error("Cannot read store", e); ctx.setVariable("msgType", ERROR); ctx.setVariable("msgInfo", "Cannot read store:" + e.getMessage()); } ctx.setVariable("homebean", hb); }
/** * Define output context for audit. * * @param ctx * current web contetx * @param eqd * curren query */ private void createPage(WebContext ctx, EventQueryDefinition eqd) { ctx.setVariable(KEY_TITLE, "Feature Usage"); ctx.setVariable("from", SDFSLOT.format(new Date(eqd.getFrom()))); ctx.setVariable("to", SDFSLOT.format(new Date(eqd.getTo()))); ctx.setVariable("fromJS", SDF.format(new Date(eqd.getFrom()))); ctx.setVariable("toJS", SDF.format(new Date(eqd.getTo()))); }
/** * Define output context for audit. * * @param ctx * current web contetx * @param eqd * curren query */ private void createPage(WebContext ctx, EventQueryDefinition eqd) { ctx.setVariable(KEY_TITLE, "Time Series"); ctx.setVariable("from", SDFSLOT.format(new Date(eqd.getFrom()))); ctx.setVariable("to", SDFSLOT.format(new Date(eqd.getTo()))); ctx.setVariable("fromJS", SDF.format(new Date(eqd.getFrom()))); ctx.setVariable("toJS", SDF.format(new Date(eqd.getTo()))); }
/** * Define output context for audit. * * @param ctx * current web contetx * @param eqd * curren query */ private void createPage(WebContext ctx, EventQueryDefinition eqd) { ctx.setVariable(KEY_TITLE, "AuditTrail"); ctx.setVariable("from", SDFSLOT.format(new Date(eqd.getFrom()))); ctx.setVariable("to", SDFSLOT.format(new Date(eqd.getTo()))); ctx.setVariable(WebConstants.KEY_AUDITTRAIL, ff4j.getEventRepository().getAuditTrail(eqd)); }
/** * Public interface to add images to webcontext for rendering. * * @param ctx * thymeleaf context * @param imageName * current image name * @param type * current image type */ public void addImageToContext(WebContext ctx, String imageName, ImageType type) { String base64 = getImage(imageName, type); if (base64 != null) { ctx.setVariable("flagFrance", "data:image/jpg;base64," + base64); } }
/** * Both get and post operation will render the page. * * @param ctx * current web context */ private void renderPage(WebContext ctx) { ctx.setVariable(KEY_TITLE, "Properties"); // Sort natural Order Map<String, Property<?>> mapOfProperties = ff4j.getPropertiesStore().readAllProperties(); List<String> propertyNames = Arrays.asList(mapOfProperties.keySet().toArray(new String[0])); Collections.sort(propertyNames); List<Property<?>> orderedProperties = new ArrayList<Property<?>>(); for (String propName : propertyNames) { orderedProperties.add(mapOfProperties.get(propName)); } ctx.setVariable("listOfProperties", orderedProperties); }
/** * Invoked by dispatcher. * * @param req * current request * @param res * current response * @throws IOException * error occured. */ public void post(HttpServletRequest req, HttpServletResponse res) throws IOException { WebContext ctx = new WebContext(req, res, req.getSession().getServletContext(), req.getLocale()); ctx.setVariable("uptime", getUptime()); ctx.setVariable("version", ff4j.getVersion()); // Adding attribute to response try { post(req, res, ctx); } catch(Throwable t) { ctx.setVariable("msgType", "error"); ctx.setVariable("msgInfo", t.getMessage()); } // Render to view templateEngine.process(getSuccessView(), ctx, res.getWriter()); }
ctx.setVariable(KEY_TITLE, "Features"); ctx.setVariable("listOfFeatures", orderedFeatures); ctx.setVariable("listOfStrategyUsed", orderedStrategyUsed); ctx.setVariable("groupList", myGroupList);
/** {@inheritDoc} */ public void get(HttpServletRequest req, HttpServletResponse res, WebContext ctx) throws IOException { ctx.setVariable(KEY_TITLE, "Settings"); String operation = req.getParameter(WebConstants.OPERATION); String msgType = "success"; String msg = null; if (Util.hasLength(operation) && TOGGLE_AUDIT.equalsIgnoreCase(operation)) { if (getFf4j().isEnableAudit()) { getFf4j().audit(false); msg = "Audit is now DISABLED"; LOGGER.info("Audit has been disabled"); } else { getFf4j().audit(true); msg = "Audit is now ENABLED"; LOGGER.info("Audit has been enabled"); } } ctx.setVariable(KEY_AUDITENABLE, getFf4j().isEnableAudit()); ctx.setVariable("msgType", msgType); ctx.setVariable("msgInfo", msg); }
ctx.setVariable("msgType", msgType); ctx.setVariable("msgInfo", msg); get(req, res, ctx); } else if (WebConstants.OP_CREATE_SCHEMA.equalsIgnoreCase(operation)) { getFf4j().createSchema(); msg = "Schema has been created in DB (if required)."; ctx.setVariable("msgType", msgType); ctx.setVariable("msgInfo", msg); get(req, res, ctx); } catch(RuntimeException re) { ctx.setVariable("msgType", ERROR); ctx.setVariable("msgInfo", "Cannot create Schema:" + re.getMessage()); ctx.setVariable(KEY_TITLE, "Home"); ctx.setVariable("today", Calendar.getInstance()); ctx.setVariable("homebean", new HomeBean()); msg = "Cache not present: it cannot be cleared!"; ctx.setVariable("msgType", msgType); ctx.setVariable("msgInfo", msg); get(req, res, ctx);
request.getServletContext(), request.getLocale()); ctx.setVariable("info", info);
ctx.setVariable("uptime", getUptime()); ctx.setVariable("version", ff4j.getVersion()); ctx.setVariable("secure", false); if (getFf4j().getAuthorizationsManager() != null) { ctx.setVariable("secure", true); ctx.setVariable("userName", getFf4j().getAuthorizationsManager().getCurrentUserName()); Set < String > permissions = getFf4j().getAuthorizationsManager().getCurrentUserPermissions(); ctx.setVariable("userPermissions", permissions); get(req, res, ctx); } catch(Throwable t) { ctx.setVariable("msgType", "error"); ctx.setVariable("msgInfo", t.getMessage());
ctx.setVariable("tokenLink", link); String template = templateEngine.process("email/email_join", ctx); msg.setSubject("subject", "UTF-8");
/** {@inheritDoc} */ public void get(HttpServletRequest req, HttpServletResponse res, WebContext ctx) throws IOException { String operation = req.getParameter(WebConstants.OPERATION); String propertyName = req.getParameter(WebConstants.FEATID); String msgType = "success"; String msg = null; if (Util.hasLength(operation) && Util.hasLength(propertyName) && getFf4j().getPropertiesStore().existProperty(propertyName)) { if (OP_DELETE_FIXEDVALUE.equalsIgnoreCase(operation)) { String fixedValue = req.getParameter(PARAM_FIXEDVALUE); Property<?> ap = getFf4j().getPropertiesStore().readProperty(propertyName); // Need to convert back to object to use the remove() ap.getFixedValues().remove(ap.fromString(fixedValue)); getFf4j().getPropertiesStore().updateProperty(ap); LOGGER.info("Property '" + propertyName + "' remove fixedValue '" + fixedValue + "'"); } if (OP_ADD_FIXEDVALUE.equalsIgnoreCase(operation)) { String fixedValue = req.getParameter(PARAM_FIXEDVALUE); Property<?> ap = getFf4j().getPropertiesStore().readProperty(propertyName); ap.add2FixedValueFromString(fixedValue); getFf4j().getPropertiesStore().updateProperty(ap); LOGGER.info("Property '" + propertyName + "' add fixedValue '" + fixedValue + "'"); } } ctx.setVariable("msgType", msgType); ctx.setVariable("msgInfo", msg); renderPage(ctx); }
ctx.setVariable("msgType", msgType); ctx.setVariable("msgInfo", msg); renderPage(ctx);
ctx.setVariable("msgType", msgType); ctx.setVariable("msgInfo", msg); renderPage(ctx);