Wednesday 27 November 2013

ADF : ValueChangeEvent : Forcefully execute all event change queued logic.

ValueChangeEvent : Forcefully execute all event change queued logic.


Problem: some times on valuechangeevent you will not get latest selected value.
Because, all valuechangeevent will go to queue, and it executes at particular ADF lifecycle.

Solution: to get the latest selected value, we need to manually execute the ADF lifecycle before taking the value.

##############Your code - from ValueChangeEvent method ##########################

yourMethod(ValueChangeEvent valueChangeEvent){

----------------
------------

this.setValueChangeEventComponentToNewValue(valueChangeEvent);

                ViewObject vo =
                    this.findIterator("MktImpJobs1Iterator").getViewObject();
                this.jobrow = vo.getCurrentRow();
----------------
 -------------

}

##############new method you need to add ##############

 public  void setValueChangeEventComponentToNewValue(ValueChangeEvent vce) {
            vce.getComponent()
               .getValueExpression("value")
               .setValue(FacesContext.getCurrentInstance().getELContext(),vce.getNewValue());
          
        }

 
########################################################

Wednesday 13 November 2013

Windows Command to check port usage

Windows Command to check port usage


netstat -aon | find /i "listening"



tasklist /svc /FI "PID eq 2632"


JAVA : Java Code : Take Screenshot, Schedule Program, Send Mail.

Java Code : Take Screenshot, Schedule Program, Send Mail.


1. Take Screenshot:


##############################################################################

import java.awt.AWTException;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Date;

import javax.imageio.ImageIO;

public class RobotExp {
   
    public static void main(String[] args) {
       
        try {
            Date a = new Date();
            Robot robot = new Robot();
            // Capture the screen shot of the area of the screen defined by the rectangle
            BufferedImage bi=robot.createScreenCapture(new Rectangle(1000,1000));
            ImageIO.write(bi, "jpg", new File("D:/tt/imageTest.jpg"));
           
        } catch (AWTException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
##############################################################################

2. Schedule Program

##############################################################################

 import java.awt.Toolkit;
import java.util.Timer;
import java.util.TimerTask;
/**
 * Simple demo that uses java.util.Timer to schedule a task to execute once 5
 * seconds have passed.
 */
public class ReminderBeep {
  Toolkit toolkit;
  Timer timer;
  public ReminderBeep(int seconds) {
    toolkit = Toolkit.getDefaultToolkit();
    timer = new Timer();
    timer.schedule(new RemindTask(), seconds * 1000);
  }
  class RemindTask extends TimerTask {
    public void run() {
      System.out.println("Time's up!");
      toolkit.beep();
      String args[] = new String[3];
      main(args);
      //timer.cancel(); //Not necessary because we call System.exit
      //System.exit(0); //Stops the AWT thread (and everything else)
    }
  }
  public static void main(String args[]) {
    System.out.println("About to schedule task.");
    new ReminderBeep(5);
    System.out.println("Task scheduled.");
  }
}

    

##############################################################################

3. Send Mail

For this we need 2 Jars:
   a. javax.mail.jar
   b. activation-1.0.2.jar

Then we need: SMTP host, port

############################################################################## 

 

import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;

public class SendFileEmail
{
   public static void main(String [] args)
   {
      
      // Recipient's email ID needs to be mentioned.
      String to = "pavan.x.mr@oracle.com";

      // Sender's email ID needs to be mentioned
      String from = "web@gmail.com";

      // Assuming you are sending email from localhost
      String host = "localhost";

      // Get system properties
      Properties properties = System.getProperties();

      // Setup mail server
      properties.setProperty("mail.smtp.host", host);
      properties.setProperty("mail.smtp.port", "465");

      // Get the default Session object.
      Session session = Session.getDefaultInstance(properties);

      try{
         // Create a default MimeMessage object.
         MimeMessage message = new MimeMessage(session);

         // Set From: header field of the header.
         message.setFrom(new InternetAddress(from));

         // Set To: header field of the header.
         message.addRecipient(Message.RecipientType.TO,
                                  new InternetAddress(to));

         // Set Subject: header field
         message.setSubject("This is the Subject Line!");

         // Create the message part
         BodyPart messageBodyPart = new MimeBodyPart();

         // Fill the message
         messageBodyPart.setText("This is message body");
         
         // Create a multipar message
         Multipart multipart = new MimeMultipart();

         // Set text message part
         multipart.addBodyPart(messageBodyPart);

         // Part two is attachment
         messageBodyPart = new MimeBodyPart();
         String filename = "file.txt";
         DataSource source = new FileDataSource(filename);
         messageBodyPart.setDataHandler(new DataHandler(source));
         messageBodyPart.setFileName(filename);
         multipart.addBodyPart(messageBodyPart);

         // Send the complete message parts
         message.setContent(multipart );

         // Send message
         Transport.send(message);
         System.out.println("Sent message successfully....");
      }catch (MessagingException mex) {
         mex.printStackTrace();
      }
   }
}

##############################################################################

 

Tuesday 12 November 2013

HTML : Web Page Design : HTML, CSS, Javascript and JQuery.

Web Page Design : HTML, CSS, Javascript and JQuery.


1. Gothrough this url - which has different menu design.
       - below that u have download option, u can download the code (html,css,js)
Eg : one sample menu design as shown below

ADF Table Sort:

ADF Table Sort:


1. Sort on VO Query : For all the VO's it affects.
2. Sort for VO Iterator : only for that VO - Iterator it affects.
3. Sort for <af:table : only for that page, that table it affects (if we have 2 <af:table based on same iterator also, it affects differently, bez we are applying on <af:table)

1. Sort on VO Query : For all the VO's it affects.




 2. Sort for VO Iterator : only for that VO - Iterator it affects.




3. Sort for <af:table : only for that page, that table it affects



Thursday 7 November 2013

ADF : ViewCriteria : Change display components in af:query

ViewCriteria : Change display components in af:query


Requirement:
-> I want to change the display component in af:query
    Eg: i have "Flag" column in table, i am using "Flag" in my view criteria, but on screen i want to display check box instead of input text box.

Refer below URL:

http://andrejusb.blogspot.in/2010/05/yes-no-check-box-in-query-criteria.html