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) {
                    upload_widget_var.buttonBar.find('input[type=file]').get(0).disabled=true;
                }
                onchangeDisableChooseBtn(upload_widget);
            });
        }
    }

</script>



Done!!

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;
 }




Done!!

Tuesday, June 21, 2016

Blinking Text effect


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

<script>
$(function(){
    // Self-executing recursive animation
    (function pulse(){
        $('#elementIdToBlink').delay(1000).fadeOut('slow').delay(50).fadeIn('slow',pulse);
    })();
});
</script>


reference:
http://stackoverflow.com/questions/7223503/jquery-pulsate-times



Done!!

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";


Monday, February 22, 2016

How to override JSF library in JBoss

In normal scenario, JBoss is bundled with JSF libraries.
But it might be older and stable version of JSF.

 Due to more features enhancement, bug fixes. We might want to use a more latest version of JSF for our application.
1 way is to upgrade the entire JBoss AS, but this is risky to all the existing applications that are running on the same JBoss AS.

to avoid unexpected issues to existing applications. we can proceed to upgrade the JSF libraries on the new JSF applications only.
We just need to bundled the latest JSF libraris in the same application, and add the following context-param into the web.xml.

<context-param>
    <param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
    <param-value>true</param-value>
</context-param>


Done!!

LinkWithin

Related Posts Plugin for WordPress, Blogger...