Exemplo n.º 1
0
 /**
  * Apply a mask to the textbox. Value get/set from the textbox will have the mask. <br>
  * Example: ({{000}}) {{000}}.{{0000}}
  *
  * @param pattern {{[0A]+}}
  * @param showMask true to display the mask when input is empty
  * @param freeSymbol replacement char when there is no input yet
  */
 public void applyMask(final String pattern, final boolean showMask, final String freeSymbol) {
   final Update update = new Update(getID());
   update.put(PROPERTY.MASK, pattern);
   update.put(PROPERTY.VISIBILITY, showMask);
   update.put(PROPERTY.REPLACEMENT_STRING, freeSymbol);
   Txn.get().getTxnContext().save(update);
 }
Exemplo n.º 2
0
  public PImage(final ClassPathURL classpathURL) {

    InputStream in = null;
    ByteArrayOutputStream out = null;

    String imageToBase64 = null;

    try {
      in = classpathURL.getUrl().openStream();
      final byte[] buffer = new byte[1024];
      out = new ByteArrayOutputStream();
      while (in.read(buffer) != -1) {
        out.write(buffer);
      }

      imageToBase64 = new String(out.toByteArray(), "UTF-8");

    } catch (final IOException e) {
      log.error("Cannot load resource from " + classpathURL, e);
    } finally {
      try {
        if (in != null) in.close();
      } catch (final Exception e) {
      }
      try {
        if (out != null) out.close();
      } catch (final Exception e) {
      }
    }

    final String extension =
        classpathURL
            .getUrl()
            .getFile()
            .substring(classpathURL.getUrl().getFile().lastIndexOf('.') + 1);

    final Update update = new Update(getID());
    update.put(PROPERTY.IMAGE_URL, "data:image/" + extension + ";base64," + imageToBase64);
    Txn.get().getTxnContext().save(update);
  }
Exemplo n.º 3
0
 public void setUrl(final String url) {
   this.url = url;
   final Update update = new Update(getID());
   update.put(PROPERTY.IMAGE_URL, url);
   Txn.get().getTxnContext().save(update);
 }