Posts

Showing posts from 2014

DISABLE Browser Caching

Browser caching of page content has negative security implications when your application runs on shared terminals (like the public library). You can turn it off with this simple phase listener. Well, maybe. As some of the comments indicate, browsers are finicky, and of course, we never trust the browser, anyway, so using this technique is certainly not a security guarantee of any kind. import javax.faces.context.FacesContext; import javax.faces.event.PhaseEvent; import javax.faces.event.PhaseId; import javax.faces.event.PhaseListener; import javax.servlet.http.HttpServletResponse; public class CacheControlPhaseListener implements PhaseListener {      public PhaseId getPhaseId()      {          return PhaseId.RENDER_RESPONSE;      }      public void afterPhase(PhaseEvent event)      {      }      public void beforePhase(PhaseEvent event)      {          FacesContext facesContext = event.getFacesContext();          HttpServl

Sample IO Files Methods

How to delete file:             private void deleteOldFiles() {                 String path = JSFUtils.getContextPath();                 File userDirectory = new File(path + "\\tempDoc\\" +     ADFContext.getCurrent().getSessionScope().get("UserName"));                 if (userDirectory.exists()) {                     try {                         FileUtils.deleteDirectory(userDirectory);                     } catch (IOException e) {                         e.printStackTrace();                     }                 }             } how to  upload array of files

Upload data from excel + Oracle from

First, add a button to your canvas and write this code:when button pressed Declare   vfilename varchar2(500);   in_file   Client_Text_IO.File_Type;   linebuf   VARCHAR2(1800);    i number := 0; BEGIN     vfilename := client_get_file_name('c:/temp/', File_Filter=>'Comma Dialimeted Files (*.csv)|*.csv|');      in_file := client_Text_IO.Fopen(vfilename, 'r');       GO_BLOCK('DATA');      FIRST_RECORD;     LOOP     Client_Text_IO.Get_Line(in_file, linebuf);      p_output_line(linebuf);     Client_Text_IO.New_Line;      Next_record;      i:=i+1;   END LOOP;     FIRST_RECORD; EXCEPTION   WHEN no_data_found THEN     Client_Text_IO.Put_Line('Closing the file...');     Client_Text_IO.Fclose(in_file); END; --------------------------- Secode , add this procedure to your program unit ------------------------------------------------------------------------------------ -- TAREK FATHY -- MARCH 1

How to get Conection Using JNDI

    public Connection getJdbcUrl() {         Connection connection = null;         try {             InitialContext context = new InitialContext();             DataSource dataSource = (DataSource) context.lookup("jdbc/pmsDS");             connection = dataSource.getConnection();         } catch (NamingException e) {             e.printStackTrace();         } catch (SQLException e) {             e.printStackTrace();         }         return connection;     }

Logout From ADF application

Image
I implemented this method in the Action of the logout button public String logout{         FacesContext fctx = FacesContext.getCurrentInstance();         ExternalContext ectx = fctx.getExternalContext();         HttpSession session = (HttpSession) ectx.getSession(false);         session.invalidate();         HttpServletRequest request = (HttpServletRequest)ectx.getRequest();         HttpServletResponse response = (HttpServletResponse) ectx.getResponse();         ServletAuthentication.logout(request,response,false);         try{                ectx.redirect("http://iaigc.net");              }              catch(Exception e){                e.printStackTrace();              }              fctx.responseComplete();         return null; } Then I changed the property of the ADF taskflow Taskflow Reentry to reentery-not-allowed to prevent the The browser back  button to return to my page

Showing Popup when clicking on calendar activity

First set the calendar activity calendarActivityListener="#{calActivityBean.activityListener}" second insert the popup and the panelform containg the iterator in the facet activityDetail thired,in the backing beean add implements calendarActivityListener     public void activityListener(CalendarActivityEvent calendarActivityEvent) {         CalendarActivity activity =               calendarActivityEvent. getCalendarActivity ();                   if (activity != null) {               DCBindingContainer dcbindings =                   (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();               DCIteratorBinding iterator =                   dcbindings.findIteratorBinding("CalenderEventsVoIterator");               Key key = new Key(new Object[] { activity.getId() });               RowSetIterator rsi = iterator.getRowSetIterator();               Row row = rsi.findByKey(key, 1)[0];               rsi. setCurrentRow (row);  

Programatically Applying and Creating View Criteria

CASE 1: I have already created a view criteria in EmployeeVO, and I want to call it programmatically. public   void   searchEmployee(Number employeeId) {    ViewObjectImpl vo = getEmployeesView1();    ViewCriteria vc = vo.getViewCriteria( "findEmployeeVC" );    vo.applyViewCriteria(vc);    vo.setNamedWhereClauseParam( "pEmployeeId" , employeeId);    vo.executeQuery(); } CASE 2: I want to create a view criteria dynamically and execute it programmatically. public   void   searchByEmployeeIdEmail(Number employeeId, String email) {    ViewObjectImpl vo = getEmployeesView2();    ViewCriteria vc = vo.createViewCriteria();    ViewCriteriaRow vcRow = vc.createViewCriteriaRow();    vcRow.setAttribute( "EmployeeId" , employeeId);    vc.addRow(vcRow);    vcRow.setAttribute( "Email" , email);    vc.addRow(vcRow);    vo.applyViewCriteria(vc);    vo.executeQuery(); } This is a helper method     public st

Solution for Error FRM-92095: Oracle Jnitiator version too low

After logging into application, system pop up below error message: FRM-92095: Oracle JInitiator version too low. Please install version 1.1.8.2 or higher Cause : The JRE version is not incompatible. Solution open Control panel > java Click on java tab and click on view button add this parameter : -Djava.vendor="Sun Microsystems Inc." restart the IE or Chrome

how to get the iterator binding of an adf RichTable

import oracle.adf.model.binding.DCIteratorBinding; import oracle.adf.view.rich.component.rich.data.RichTable; import oracle.jbo.uicli.binding.JUCtrlHierBinding; import org.apache.myfaces.trinidad.model.CollectionModel;     public static DCIteratorBinding getDciteratorFromTable(RichTable table) {             CollectionModel model = (CollectionModel)table.getValue();             JUCtrlHierBinding treeBinding = (JUCtrlHierBinding)model.getWrappedData();             return treeBinding.getDCIteratorBinding();         }

How to dynamically create commandNavigationItem at runtime

Image
I you want to make a dynamic navigation Pane like this when you click on the tree node on the right side, the page fragment on the left side is populated dynamically at runtime with a navigationPane.The commandNavigationItems are rendered at runtime. To do this , follow theses steps: 1- you must have a database table that stores the data of the commandNavigationItem like this CREATE TABLE SMM_SYS_OBJECTS (   ID                NUMBER(10)                  NOT NULL,   OBJECT_REASON     VARCHAR2(3 BYTE)            DEFAULT 'REP'                 NOT NULL,   OBJ_SEQ           NUMBER(3),   FILE_TYPE         VARCHAR2(1 BYTE)            DEFAULT 'M'                   NOT NULL,   EMP_ID_REQUEST    NUMBER(10),   EMP_ID_REVIEW     NUMBER(10),   EMP_ID_DEVELOP    NUMBER(10),   OBJ_ID            NUMBER(10),   NAME_AR           VARCHAR2(100 BYTE),   NAME_EN           VARCHAR2(100 BYTE),   PURPOSE           VARCHAR2(2000 BYTE),   TITLE             VARCHAR2(200 BYTE),

Exception "Object of type ApplicationModule is not found"

Image
Hi This error happens when you make a nested a pplication module. to solve this error go to the page definition of your page or fragments and search for " Binds=" as follow   <iterator RangeSize="25" DataControl="HrmsAppModuleDataControl"               id="EmpVacationsViewIterator" Binds="Root.VacAppModule.EmpVacationsView" />   </executables> then open the property pallet  and remove the value of "binds" property then click edit and select your view object from the iterator, for example see this picture

the meaning of life

Post by Anas Basmala .

"Lambda" New feature of java 8

<object id="flashObj" width="640" height="358" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,47,0"><param name="movie" value="http://c.brightcove.com/services/viewer/federated_f9?isVid=1&isUI=1" /><param name="bgcolor" value="#FFFFFF" /><param name="flashVars" value="videoId=3373491280001&linkBaseURL=http%3A%2F%2Fwww.oracle.com%2Fevents%2Fus%2Fen%2Fjava8%2Findex.html&playerID=1787102915001&playerKey=AQ~~,AAAAAFcSbzI~,OkyYKKfkn3xPOduPEsqhjskdCvDxqymz&domain=embed&dynamicStreaming=true" /><param name="base" value="http://admin.brightcove.com" /><param name="seamlesstabbing" value="false" /><param name="allowFullScreen" value="true" /><param name="swLive

how to get the value of a parameter "of OperationBinding" at runtime

Hi This method is used to retrieve the input value of a parameter of an Operation     public String viewScannedDocumentAction() {         String outcome = null;         Long doctype = null;         String yer = null;         DCIteratorBinding scanedDocIter = ADFUtils.findIterator("DocTransDocDtlVoIterator");         DCIteratorBinding currentIterator = ADFUtils.findIterator("DocTransDocCountIterator");         OperationBinding opr = getOperation("ExecuteWithParams");         Row row = currentIterator.getCurrentRow();         if (row != null) {          //   Map operationParamsMap = opr.getParamsMap();             DCInvokeMethod method = (DCInvokeMethod) opr.getOperationInfo();             if (method != null) {                 DCInvokeMethodDef methodDef = method.getDef();                 if (methodDef != null) {                     OperationParameter[] operationParameters = null;                     operationParameters = methodDef.getPara

Scanning Document from ADF Application

Using JTwain library , I managed to capture images from scanners and convert it to PDF file and upload this file to the database column "BLOB' Here is a demonstration Archiving System

LOV switcher proplem

Image
In Jdeveloper 12 c , there is a bug  when you create a lov switcher. The Bug is the display list is disabled. You cannot add or delete any display attribute in the display list as show in this image To solve this problem , you have to edit the source of the view object by adding  this tag  <AttrArray Name="ListDisplayAttrNames"/> inside the list binding tag Example      <AttrArray Name="ListDisplayAttrNames">       <Item Value="Description"/>       <Item Value="RefNum"/>     </AttrArray> see the image below