Re: forms6i built-in package TEXT_IO on forms server

From: Crypti <ninjadesign_at_gmx.de>
Date: 10 Dec 2002 07:22:17 -0800
Message-ID: <c5df9e15.0212100722.e6cd785_at_posting.google.com>


<rx_at_wo.cz> wrote in message news:<at2vt0$vnlgt$1_at_ID-123390.news.dfncis.de>...
> When I use my forms on clients side I can save and write file on my client
> directory.
>
> But I don't know how can I use TEXT_IO for save some file on my client side
> when I run my forms as java applet from forms server on client browser.
>
> Or some another ways?

When running Forms as Java-applet TEXT_IO just writes on Application-Server, but not on client-machine. If you like to write to client you should use a Pluggable Java Component.

  • CUT HERE
import oracle.forms.ui.*; 
import oracle.forms.properties.ID; 
import oracle.ewt.lwAWT.lwText.*; 

import java.awt.*;
import java.io.*;
public class TextPJC extends VTextArea {

   private static final ID READFILE =
ID.registerProperty("readfile");

   private static final ID WRITEFILE = ID.registerProperty("writefile");

   private String filename=null;

   public TextPJC() {     
       super();   }    
   public boolean setProperty(ID pid, Object value)   {     
        if(pid ==READFILE) {
          try { File inputFile = new File((String)value);
                FileReader in = new FileReader(inputFile);
                char c[] = new char[(int)inputFile.length()];
                char c1[]= new char[(int)inputFile.length()];
                in.read(c);              
                int j=0;              
                for (int i=0;i<inputFile.length();i++)              
                {if((int)c[i]==13);              
                 else              
                  c1[j++]=c[i];              
                }              
                String str = String.copyValueOf(c1,0,j);
                ((LWTextArea)getContent()).setText(str);              
                in.close();            
              }
              catch(Exception e){System.out.println("Error in PJC " );
                                 e.printStackTrace();}        
              return true;        
      }      
      else if(pid==WRITEFILE) {
            try {              
                  File inputFile = new File((String)value);
                  FileWriter in = new FileWriter(inputFile);
                  LWTextArea lw = (LWTextArea)(this.getContent());
                  String text1 = lw.getText();              
                  int length1 = text1.length();               
                  char c[] = new char[(int)length1];               
                  char c1[]= new char[(int)length1*2];               
                  text1.getChars(0,length1,c,0);               
                  int j=0; 
                 String s1= System.getPropert("line.separator");
                 for(int i=0;i<length1;i++)               
                   {               
                       if ((int)c[i]==10)               
                       {                  
                          s1.getChars(0,s1.length(),c1,j);
                          j=j+s1.length();               
                       }  else               
                            c1[j++]=c[i];               
                       }              
                       in.write(c1,0,j);              
                       in.flush();              
                       in.close();                      
                       }              
                       catch(Exception e) 
                       {System.out.println("Error " );
                        e.printStackTrace();}              
                        return true;                              
                       }       
                       else       
                           return super.setProperty(pid,value);   
           }   

  }
  • CUT HERE ---------------------------
Ensure the environment variable CLASSPATH contains $ORACLE_HOME\forms60\java. c:\>cd $ORACLE_HOME\forms60\java e:\orant\forms60\java> javac TextPJC.java c. Package the class file into a jar file e:\orant\forms60\java> jar cvf TextPJC.jar TextPJC.class The jar file needs to be signed, to provide the class file access to the local filesystem.Check out the links mentioned below for more information on signing a jar file http://java.sun.com/security/signExample/ http://java.sun.com/security/usingJavakey.html After signing the jar file you would have the certificate file (Assume TextPJC.x509) which needs to be imported into the identity database of the client system d. Include the above signed jar file in the html file, by including the jar file in the ARCHIVE tag of the applet e. Setup the client to use the jar file The certificate needs to be imported into the client's system & needs to be trusted. This needs to be done using the javakey executable. The above mentioned links would provide more information about it. f. In the Form, Set the implementation class of the TextItem whose data needs to be uploaded/saved from/to a file as "TextPJC". Make sure the Jar file created is in the CLASSPATH, before invoking the forms builder. For reading a file content into the textitem use set_custom_property('TEXT_ITEM',1,'readfile','filename'); Where TEXT_ITEM is the name of the Text Item and 'filename' is the name of the file to be read. For writing the contents of the textitem to a file use set_custom_property('TEXT_ITEM',1,'writefile', 'filename'); Note : - You could create a Bean to display a FileDialog to select the file. - If you receive Security Exception even after trusting the jar file. cd $JINITIATOR_HOME\lib\security ( JINITIATOR_HOME is home directory for   Jinitiator used. eg the default directory for Jinitiator v1.1.7.18 would be c:\program files\oracle\Jinitiator1.1.7.18) Take a backup of the java.security file Edit the java.security file and have only one entry for the identity.database pointing to c:\\identitydb.obj.

Sorry for bad format, I've copied from Metalink. I hope it will help you a little bit.

Bye,
Crypti Received on Tue Dec 10 2002 - 16:22:17 CET

Original text of this message