Monday, June 27, 2016

How to disable Choose button in PrimeFaces fileupload component

The javascript function is to disable "Choose" button in <p:fileUpload /> component a file has been uploaded.
It is applicable to PrimeFaces 3.5

function below will find the Choose button from the passed in widgetVar when the file component onchange,
if the number of uploaded files more than 1,
disable the Choose button.

<script type="text/javascript">

    function onchangeDisableChooseBtn(upload_widget_var) {
        if(upload_widget_var.buttonBar.find('input[type=file]').get(0).type == 'file') {
            upload_widget_var.buttonBar.find('input[type=file]').change(function() {
                var files = upload_widget_var.uploadContent.find('.files tr');
                if (files.length >= 1) {



Wednesday, June 22, 2016

How to hide icons in PrimeFaces fileUpload component.

PrimeFaces version: 3.5

to hide icon in choose button

  .fileupload-buttonbar .fileinput-button .ui-icon-plusthick{
         display: none !important;

to hide icon in upload button

 .fileupload-buttonbar .start .ui-icon-arrowreturnthick-1-n{
         display: none !important;

to hide icon in cancel button

 .fileupload-buttonbar .cancel .ui-icon-cancel{
         display: none !important;


Tuesday, June 21, 2016

Blinking Text effect

<span id="elementIdToBlink">    
   any text to blink.

    // Self-executing recursive animation
    (function pulse(){



Monday, June 20, 2016

Encryption/Decryption with Java

Following are the steps to encrypt/decrypt with Java
1. determine the encryption key
2. get the keyspec from the encryption key  
3. instantiate the secretkeyfactory
4. generate the secretkey from the keyfactory
5. instantiate the cipher
6. encrypt/decrypt the string into byte array
7. encode to base 64
8. return the encrypted/decrypted string

Sample Code

    public static final String key = "kianworknotes";


Related Posts Plugin for WordPress, Blogger...