1) Compile the java code to generate the class files.
++ Since the sample code uses forms classes also, it is necessary to include the frmall.jar(10.1.2)/f90all.jar(9.0.4) in CLASSPATH before compilation.
set CLASSPATH=%ORACLE_HOME%\forms\java\frmall.jar;%CLASSPATH% (in 10.1.2 windows)
%ORACLE_HOME%\jdk\bin\javac ChangeInputMethodOnFocus.java
%ORACLE_HOME%\jdk\bin\javac VTextFieldHeb.java
%ORACLE_HOME%\jdk\bin\javac VTextFieldEng.java
2) Generate the jar file with the 'jar' command to package the class files in step 1.
%ORACLE_HOME%\jdk\bin\jar -cvf InputMethod.jar VTextFieldEng.class VTextFieldHeb.class ChangeInputMethodOnFocus.class
3) Place the jar file in the codebase directory of Forms which is ORACLE_HOME/forms90/java(9.0.4 version) or ORACLE_HOME/forms/java(10.1.2 version) directory by default.
4) Include the jar file in the archive parameter in formsweb.cfg to enable the jar file to be downloaded and cached on the client machine.
archive=frmall.jar,InputMethod.jar
5) Set the 'Implementation Class' property in the form to 'VTextFieldHeb' for the Hebrew text items and 'VTextFieldEng' for english text items where this functionality is required.
Sample Code
-------------------ChangeInputMethodOnFocus.java--------------------
import java.awt.Component;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.im.InputContext;
import java.util.Locale;
public class ChangeInputMethodOnFocus extends FocusAdapter
{
Locale _locale;
class="km">Locale defLocale;public ChangeInputMethodOnFocus(Locale locale)
{
_locale = locale;
}
public void focusGained(FocusEvent fe)
{
Component c = fe.getComponent();
InputContext inputContext = c.getInputContext();
defLocale = inputContext.getLocale();
inputContext.selectInputMethod(_locale);
}
public void focusLost(FocusEvent fe) {
Component c = fe.getComponent();
InputContext inputContext = c.getInputContext();
inputContext.selectInputMethod(defLocale);
}
}
----------------VTextFieldHeb.java ------------------
import java.util.Locale;
import oracle.forms.handler.IHandler;
import oracle.forms.ui.VTextField;
public class VTextFieldHeb extends VTextField
{
public void init(IHandler ih)
{
super.init(ih);
ChangeInputMethodOnFocus focusAdapter = new ChangeInputMethodOnFocus (new Locale("iw","IL"));
this.addFocusListener(focusAdapter);
}
}
----------------VTextFieldEng.java ------------------
import java.util.Locale;
import oracle.forms.handler.IHandler;
import oracle.forms.ui.VTextField;
public class VTextFieldEng extends VTextField
{
public void init(IHandler ih)
{
super.init(ih);
ChangeInputMethodOnFocus focusAdapter = new ChangeInputMethodOnFocus (new Locale("en","US"));
this.addFocusListener(focusAdapter);
}
}
Sample Code Output
When you navigate to text items which implement the 'VTextFieldHeb' class, the input locale automatically changes to 'HE' (Hebrew)
and you can begin to enter Hebrew characters. Then when you navigate to text items which implement the 'VTextFieldEng' class, the input locale automatically changes to 'EN' (English) and you can enter English characters.
Additional information
This solution is also applicable for arabic language after performing the following:
1)-On the client machine ,set "Arabic
(Egypt)" as an input keyboard language.
2)-In the above code,change:
ChangeInputMethodOnFocus (new Locale("iw","IL"));
To be:
ChangeInputMethodOnFocus (new Locale("ar","EG"));
No comments:
Post a Comment