Tag Archives: Java

How to do an LDAP Search of Various fields

Requirement:┬áretrieving various values such as Description, Office, etc. from LDAP after authentication. An LDAP client retrieves attribute values (referred to as “fields” in the question) by transmitting a search request to the server and then reading the server’s response. A … Continue reading

Posted in LDAP | Tagged , , | Leave a comment

Email Validation

CHALLENGE DESCRIPTION: You are given several strings that may/may not be valid emails. You should write a regular expression that determines if the email id is a valid email id or not. You may assume all characters are from the … Continue reading

Posted in Java | Tagged , , , | Leave a comment

Swaps letters’ case in a sentence. All non-letter characters should remain the same.

INPUT SAMPLE: Your program should accept as its first argument a path to a filename. Input example is the following Hello world! JavaScript language 1.8 A letter OUTPUT SAMPLE: hELLO WORLD! jAVAsCRIPT LANGUAGE 1.8 a LETTER Solution import java.io.BufferedReader; import … Continue reading

Posted in Java | Tagged , | Leave a comment

How to check if 2 Date Ranges Overlap in Java

Code to check if 2 date ranges overlap each other or not. /** * @return boolean true in case the date ranges overlap. */ boolean isOverLaped(Date start1,Date end1,Date start2,Date end2) throws NullPointerException{ if ((start1.before(start2) && end1.after(start2)) || (start1.before(end2) && end1.after(end2)) … Continue reading

Posted in Java | Tagged , , | 8 Comments

Creating a re-organizable list of Items using Drag and Drop in Oracle ADF

Sometimes the requirement is to create a list of UI Items which can be rearranged using Drag and Drop in Oracle ADF, similar to the one in jQuery. Oracle ADF Drag and Drop doesn’t provide the ability to identify, where … Continue reading

Posted in Oracle ADF | Tagged , , , , , , , | 1 Comment

Parse String as Date in Java

Date and Time patterns used in java.text.SimpleDateFormat Letter Date or Time Component Presentation Examples G Era designator Text AD y Year Year 1996; 96 Y Week year Year 2009; 09 M Month in year Month July; Jul; 07 w Week … Continue reading

Posted in Java | Tagged , | Leave a comment

Two player game program – e.g. TIC TAC TOE…

This is an abstract State class public abstract class State { // This method is abstract, the extending class has to give the implementation // It will return a list of all the possible children from the current state. public … Continue reading

Posted in Java | Tagged , , , | Leave a comment

Programmatically Populate View Objects Based on ArrayList of custom Bean Class In Oracle ADF

Lets say you have a Custom Bean Class EmpData defined as: EmpData And you wish to use the same as a View Object, Then below is the method for the same: First create a Proxy View Object Class: ProxyDataSourceObject Now … Continue reading

Posted in Oracle ADF | Tagged , , , | Leave a comment

ADFUtils Class: Best for Accessing Components in from the Managed Bean

import java.util.Iterator; import java.util.Map; import javax.el.ELContext; import javax.el.ExpressionFactory; import javax.el.MethodExpression; import javax.el.ValueExpression; import javax.faces.application.ViewHandler; import javax.faces.component.UIComponent; import javax.faces.component.UIViewRoot; import javax.faces.context.FacesContext; import oracle.adf.model.BindingContext; import oracle.adf.model.DataControlFrame; import oracle.adf.view.rich.context.AdfFacesContext; import org.apache.myfaces.trinidad.render.ExtendedRenderKitService; import org.apache.myfaces.trinidad.util.Service; public class ADFUtils { private ADFUtils() { } /** * … Continue reading

Posted in Oracle ADF | Tagged , , , | Leave a comment

How to show Popup programmatically in Oracle ADF

When trying to open a Popup on JSF/JSFF page programmatically through Managed Bean, use the following method and pass the ID of the popup to the method: ┬ápublic void openPopup(String popupId) { ExtendedRenderKitService erkService = Service.getService(FacesContext.getCurrentInstance().getRenderKit(), ExtendedRenderKitService.class); erkService.addScript(FacesContext.getCurrentInstance(), “var hints … Continue reading

Posted in Oracle ADF | Tagged , , , | Leave a comment