congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
WebContext.setVariable
Code IndexAdd Tabnine to your IDE (free)

How to use
setVariable
method
in
org.thymeleaf.context.WebContext

Best Java code snippets using org.thymeleaf.context.WebContext.setVariable (Showing top 20 results out of 315)

origin: ff4j/ff4j

/** {@inheritDoc} */
public void get(HttpServletRequest req, HttpServletResponse res, WebContext ctx)
throws IOException {
  ctx.setVariable(KEY_TITLE, "Not Found ");
}
origin: ff4j/ff4j

/** {@inheritDoc} */
public void get(HttpServletRequest req, HttpServletResponse res, WebContext ctx)
throws IOException {
  ctx.setVariable(KEY_TITLE, "About ");
}
origin: stackoverflow.com

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);
origin: stackoverflow.com

 WebContext ctx = new WebContext(request, servletContext, request.getLocale());
ctx.setVariable("today", dateFormat.format(cal.getTime()));
origin: ff4j/ff4j

/** {@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);
}
origin: ff4j/ff4j

/**
 * 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())));
}
origin: ff4j/ff4j

/**
 * 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())));
}
origin: ff4j/ff4j

/**
 * 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));
}
origin: ff4j/ff4j

/**
 * 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);
  }
}

origin: ff4j/ff4j

/**
 * 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);
}

origin: ff4j/ff4j

/**
 * 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());
}
origin: ff4j/ff4j

ctx.setVariable(KEY_TITLE, "Features");
ctx.setVariable("listOfFeatures", orderedFeatures);
ctx.setVariable("listOfStrategyUsed", orderedStrategyUsed);
ctx.setVariable("groupList", myGroupList);
origin: ff4j/ff4j

/** {@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);
}
origin: ff4j/ff4j

  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);
origin: stackoverflow.com

request.getServletContext(), request.getLocale());
ctx.setVariable("info", info);
origin: ff4j/ff4j

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());
origin: stackoverflow.com

ctx.setVariable("tokenLink", link);
String template = templateEngine.process("email/email_join", ctx);
msg.setSubject("subject", "UTF-8");
origin: ff4j/ff4j

/** {@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);
}
origin: ff4j/ff4j

ctx.setVariable("msgType", msgType);
ctx.setVariable("msgInfo", msg);
renderPage(ctx);
origin: ff4j/ff4j

ctx.setVariable("msgType", msgType);
ctx.setVariable("msgInfo", msg);
renderPage(ctx);
org.thymeleaf.contextWebContextsetVariable

Popular methods of WebContext

  • <init>
    Create an instance specifying a locale and an initial set of context variables.
  • setVariables
  • getHttpServletRequest
  • getLocale
  • getRequest
  • getResponse
  • getSession
  • getVariables
  • getWebVariablesMap
  • setLocale

Popular in Java

  • Updating database using SQL prepared statement
  • getContentResolver (Context)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • notifyDataSetChanged (ArrayAdapter)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • Top 17 Free Sublime Text Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now