Friday, April 12, 2024

Javascript-Lesson2 - Functions

 <!DOCTYPE HTML>

<html>

<head>

 <title> Functions</title>

</head>

<body bgcolor="aqua">

   <h1>Functions in Javascript</h1>


   <script>

      //document.write("Welcome to programming world of javascript");

      function hello(){

         //document.write("Welcome to programming world of javascript");

         alert("Welcome to programming world of javascript");


      }

      //hello();

   </script>

      <!--create button call above hello() function in onclick -->

      <input type="button" value="Click Here" onclick="hello()" />

</body>

</html>

Javascript-Lesson1- Different ways to dispaly content on webpage

 <!DOCTYPE HTML>

<html>

<head>

 <title> Different ways to dispaly content on webpage 3 ways to display content 1. document.write(Testing Purpose) 2. window.alert (Alert Box) 3. innerHTML (Form Validations)</title>


</head>

<body>

   <p id = "demo"> paragraph</p>

    <script type= "text/javascript"> 

      document.getElementById("demo").innerHTML = "Hi Narendra innerHTML message display"; // form validations it is very useful

     //window.alert("Narendra first alert js"); // it will show alert popup/window

     //alert("Narendra first alert js"); // it will show alert popup/window

     //document.write("Narendra first js"); //testing purpose to display the data


    </script>

</body>

</html>

Wednesday, February 8, 2023

set focus on first field by default

     /**

     * To set focus in first field in af:table

     *

     */

    public static void setFocusInTableFirstField(RichTable table, String componentId) {

        FacesContext facesContext = FacesContext.getCurrentInstance();

        String tableId = table.getClientId(facesContext);

        RowKeySet rks = table.getSelectedRowKeys();

        String inputId = null;

        if (rks != null && rks.size() > 0) {

            Object rowKey = rks.iterator().next();

            String rowId = table.getClientRowKeyManager().getClientRowKey(facesContext, table, rowKey);

            inputId = tableId + ":" + rowId + ":" + componentId;

            System.out.println("@@ClientId Value:" + inputId);

        } else {

            // handle error

        }


        ExtendedRenderKitService service = Service.getRenderKitService(facesContext, ExtendedRenderKitService.class);

        service.addScript(facesContext,

                          "   var comp = AdfPage.PAGE.findComponent('" + inputId + "');" + "   if(comp!=undefined){ comp.focus(); } ");

    }



and call this method in any button action

setFocusInTableFirstField(getT3(), "soc6");

On Enter Date assigning

  /**

   * assigning date by double click

   * @param evt 

   */           

            function setDate(evt) {

            var comp = evt.getSource()

            if (evt.getKeyCode() == AdfKeyStroke.ENTER_KEY) {

            comp.setValue(new Date());

            }

            }


<af:clientListener method="setDate" type="keyPress"/>

Tuesday, July 26, 2022

Java Script Notes

1. Java Script --> Used to Write validations at Client Side / Server Side

2. JS -->  * Change the HTML content

                * Change the CSS

                * Change the attributes 

                * 

    


Tuesday, June 18, 2019

Stop closing popup when pressing escape(Esc)

Stop closing popup when pressing escape(Esc)
function handleDialog(event) {
        if(event.getOutcome() ==  AdfDialogEvent.OUTCOME_CANCEL) {
            event.cancel();
        }                      
    }


<af:clientListener method="handleDialog" type="dialog"/>

Wednesday, April 17, 2019

Set current date in af:inputDate on double click using javascript in ADF

set current date in af:inputDate component on double click of the mouse. For this, we need to use a simple javascript function.


Here we have an inputDate component on the page and added javascript function as a resource in the page. See page XML source

  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:f="http://java.sun.com/jsf/core"
  3. xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
  4. <jsp:directive.page contentType="text/html;charset=UTF-8"/>
  5. <f:view>
  6. <af:document title="SetCurrentDate.jspx" id="d1">
  7. <af:resource type="javascript">
  8. function setDate(evt) {
  9. var comp = evt.getSource()
  10. comp.setValue(new Date());
  11. }
  12. </af:resource>
  13. <af:form id="f1">
  14. <af:inputDate label="Label 1" id="id1">
  15. <af:clientListener method="setDate" type="dblClick"/>
  16. </af:inputDate>
  17. </af:form>
  18. </af:document>
  19. </f:view>
  20. </jsp:root>