Posts

Showing posts from December, 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