Breaking a focuslost event in validating a JTextfield

This problem seems to occur often but I have not found a solution. A JTextfield gets its content validated (for example the field must not be blank) when the focus on the field is lost, and retains the focus until the user enters valid data, after which the focus moves to another field. But say the user decides not to proceed with the input and just decides to click a Close or Exit JButton and come back later. Of course each click of the Close button triggers the focuslost validation on the textfield, making it programatically impossible to quit the frame normally. How does one break the focus on the textfield and exit gracefully?

Yes, that works. In the jtextfieldFieldFocusLost method i included:
String jcomponent = evt.getOppositeComponent().getClass().getName();
       if (jcomponent.equals("javax.swing.JTextField"))
          ..do the validation
       else
         ..let the Quit button close the form
       }Great answer, many thanks.

Similar Messages

  • FocusLost event on same component generated multiple times... why?

    This is a reiteration of the topic of a post from Jan. 2006 by Toxter.
    Although Toxter got his problem resolved, the question of the title of his post (same as mine) was never answered.
    Suppose you want to validate text of a component (say, a JTextField) by checking the text when the component loses focus, by implementing the focusLost method in a FocusListener. The listener catches focusLost events from the given component and does validation and if found invalid, opens a warning dialog (say, a JOptionPane). Suppose further that in your implementation of the focusLost method, after returning from the JOptionPane call, you call requestFocusInWindow() on the JTextField so the user can make the correction straight-away. What happens, weirdly, is that you get multiple recurrences of a focusLost event from the very same textfield component, generating multiple JOptionPane popups, before the user is actually able to access the textfield and make a correction.
    No reason was given as to why this happens. Toxter reported that focusLost would get called twice. I routinely get 3 occurrences.
    In any case, why does this happen?
    There are at least a couple of other workarounds besides the one accepted by Toxter:
    1) you can drop the call to textField.requestFocusInWindow... without that call you don't get multiple occurrences of focusLost FocusEvents
    2) you can wrap the call to requestFocusInWindow in a call to SwingUtilities.invokeLater (within the run method of an anonymous Runnable):
         if( !validatePositiveIntegerField(txtFld) )
             JOptionPane.showMessageDialog(this, INPUT_ERR_MSG,
                      INVALID_ENTRY_TITLE, JOptionPane.WARNING_MESSAGE);
             SwingUtilities.invokeLater(new Runnable()
                public void run()
                   txtFld.requestFocusInWindow();
          }Workarounds are great but it's nice to understand the underlying causes of problems too... If anyone (Toxter, do you know?) can give even just a brief nutshell explanation as to why this occurs, I'd like to hear it.
    Thanks in advance.

    Use an InputVerifier:
    http://forum.java.sun.com/thread.jspa?forumID=57&threa
    dID=776107&start=6Thanks for the reply, camickr. Several workarounds were already noted. That wasn't the question. The question was: what is the underlying cause of the multiple occurrences of focusLost events from the given JTextField which cause the JOptionPane to pop up multiple times? On the face of it, it seems to be a bug in how focus events are getting generated. Here is a bit of code that will generate the problem:
       public void focusLost(FocusEvent e)
          if( e.getSource() == txtFld && !validatePositiveIntegerField(txtFld) )
             JOptionPane.showMessageDialog(this, INPUT_ERR_MSG, INVALID_ENTRY_TITLE,
                                           JOptionPane.WARNING_MESSAGE);
             txtFld.requestFocusInWindow();
       }In my previous post, I pointed out that the multiple focusLost events can be avoided if one either drops the call to txtFld.requestFocusInWindow() altogether, or else wraps that call in the run method of a Runnable executed with SwingUtilities.invokeLater. But the question I posed was, why is the code above causing multiple occurrences of focusLost events from the txtFld component?
    Any help in getting an explanation of that seemingly buggy behavior would be appreciated.
    Cheers

  • FocusLost event for JTextField sometimes triggered, sometimes not

    Some background.
    A column in a table consists of a number of cells.
    Each cell can be a JTextField or a JComboBox.
    I have written a CellEditor who returns either a JTextField or a JComboBox depending on some conditions.
    The JTextField listens for a FocusLost event to update the database.
    When I leave the first cell the FocusLost event is always triggered.
    For the ther cells the FocusLost event is triggeed every now and then.
    In the mean time I have found a simple workaround by placing the update code in method getCellEditorValue() which is called always by the table when moving to the next cell.
    I am just curious if someone has an explanation for this inconsistent behaviour of the FocusLost event.
    Code is below:
    * QuoteProductPropertyValueEditor.java
    * Created on May 4, 2005
    package tsquote.gui;
    * @author johnz
    import java.awt.Component;
    import java.util.EventObject;
    import java.awt.event.*;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import tsquote.controller.QueryHandler;
    import tsquote.exception.FinderException;
    import tsquote.gui.control.GenericTableModel;
    import tsquote.gui.control.Table;
    import tsquote.util.Messager;
    public class QuoteProductPropertyValueEditor implements TableCellEditor {
          * We use EvetListenerList, because it is thread-safe
         protected EventListenerList listenerList = new EventListenerList();
         protected ChangeEvent changeEvent = new ChangeEvent(this);
         private List<Component> componentList = new ArrayList();
         private Map<Integer, Integer> indexMap = new HashMap(); // maps row to index
         private Table table;
         private int currentRow;
         private QueryHandler queryHandler = QueryHandler.getInstance();
         public QuoteProductPropertyValueEditor() {
              super();
         public Object getCellEditorValue() {
              Component component = componentList.get(indexMap.get(currentRow));
              if (component instanceof JComboBox) {
                   JComboBox comboBox = (JComboBox) component;
                   return comboBox.getSelectedItem();
              JTextField textField = (JTextField) component;
              return textField.getText();
         public Component getTableCellEditorComponent(
                   JTable jTable,
                   Object value,
                   boolean isSelected,
                   int row,
                   int column) {
              final int thisRow = row;
              System.out.println("getTableCellEditorComponent(): thisRow=" + thisRow);
              table = (Table) jTable;
              currentRow = thisRow;
              if (!indexMap.containsKey(thisRow)) {
                   System.out.println("Control added: thisRow=" + thisRow);
                   indexMap.put(thisRow, componentList.size());
                   // This is actually a tsquote.gui.control.Table
                   GenericTableModel genericTableModel = table.getGenericTableModel();
                   List<Map> list = genericTableModel.getList();
                   Map recordMap = list.get(thisRow);
                   Boolean hasList = (Boolean) recordMap.get("product_property.has_list");
                   if (hasList) {
                        JComboBox comboBox = new JComboBox();
                        componentList.add(comboBox);
                        comboBox.addActionListener(new ActionListener() {
                             public void actionPerformed(ActionEvent event) {
                                  fireEditingStopped();
                        for (int i=0; i<=row +1; i++) {
                             comboBox.addItem("Item" + i);
                   } else {
                        JTextField textField = new JTextField();
                        componentList.add(textField);
                        textField.addFocusListener(new FocusAdapter() {
                             public void focusLost(FocusEvent e) {
                                  System.out.println("textField: thisRow=" + thisRow);
                                  JTextField textField = (JTextField) componentList.get(indexMap.get(thisRow));
                                  String newValue = textField.getText();
                                  fireEditingStopped();
                                  updateQuoteProductProperty(thisRow, newValue);
                        String text = (String) recordMap.get("quote_product_property.value");
                        textField.setText(text);
              Component component = componentList.get(indexMap.get(thisRow));
              if (component instanceof JComboBox) {
                   JComboBox comboBox = (JComboBox) component;
                   if (value == null) {
                        comboBox.setSelectedIndex(0);
                   } else {
                        comboBox.setSelectedItem(value);
              } else {
                   JTextField textField = (JTextField) component;
                   textField.setText((String) value);
              return component;
         private void updateQuoteProductProperty(
                   int row,
                   String newValue) {
              // Get PK quote_prodcut_property from list
              GenericTableModel genericTableModel = table.getGenericTableModel();
              List<Map> list = genericTableModel.getList();
              Map modelRecordMap = list.get(row);
              String storedValue = (String) modelRecordMap.get("quote_product_property.value");
              // If nothing changed, ready
    //          if (storedValue == null) {
    //               if (newValue == null) {
    //                    return;
    //          } else {
    //               if (storedValue.equals(newValue)){
    //                    return;
              // Update model
              modelRecordMap.put ("quote_product_property.value", newValue);
              Integer quoteProductPropertyID = (Integer) modelRecordMap.get("quote_product_property.quote_product_property_id");
              try {
                   queryHandler.setTable("quote_product_property");
                   queryHandler.setWhere("quote_product_property_id=?", quoteProductPropertyID);
                   Map recordMap = queryHandler.getMap();
                   recordMap.put("value", newValue);
                   recordMap.get("quote_product_property.value");
                   queryHandler.updateRecord("quote_product_property", "quote_product_property_id", recordMap);
              } catch (FinderException fE) {
                   Messager.warning("Cannot find record in quote_product_property\n" + fE.getMessage());
         public void addCellEditorListener(CellEditorListener listener) {
              listenerList.add(CellEditorListener.class, listener);
         public void removeCellEditorListener(CellEditorListener listener) {
              listenerList.remove(CellEditorListener.class, listener);
         public void cancelCellEditing() {
              fireEditingCanceled();
         public boolean stopCellEditing() {
              fireEditingStopped();
              return true;
         public boolean isCellEditable(EventObject event) {
              return true;
         public boolean shouldSelectCell(EventObject event) {
              return true;
         protected void fireEditingStopped() {
              CellEditorListener listener;
              Object[] listeners = listenerList.getListenerList();
              for (int i = 0; i < listeners.length; i++) {
                   if (listeners[i] == CellEditorListener.class) {
                        listener = (CellEditorListener) listeners[i + 1];
                        listener.editingStopped(changeEvent);
         protected void fireEditingCanceled() {
              CellEditorListener listener;
              Object[] listeners = listenerList.getListenerList();
              for (int i = 0; i < listeners.length; i++) {
                   if (listeners[i] == CellEditorListener.class) {
                        listener = (CellEditorListener) listeners[i + 1];
                        listener.editingCanceled(changeEvent);
    }

    The JTextField listens for a FocusLost event to update the database.I don't recommend using a FocusListener. Wouldn't you get a FocusLost event even if the user cancels any changes made to the cell?
    Whenver I want to know if data has changed in the table I use a TableModelListener:
    http://forum.java.sun.com/thread.jspa?threadID=527578&messageID=2533071
    I'm not very good at writing cell editors so I don't. I just override the getCellEditor method to return an appropriate editor. Here's a simple example:
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class TableComboBoxByRow extends JFrame
         ArrayList editors = new ArrayList(3);
         public TableComboBoxByRow()
              // Create the editors to be used for each row
              String[] items1 = { "Red", "Blue", "Green" };
              JComboBox comboBox1 = new JComboBox( items1 );
              DefaultCellEditor dce1 = new DefaultCellEditor( comboBox1 );
              editors.add( dce1 );
              String[] items2 = { "Circle", "Square", "Triangle" };
              JComboBox comboBox2 = new JComboBox( items2 );
              DefaultCellEditor dce2 = new DefaultCellEditor( comboBox2 );
              editors.add( dce2 );
              String[] items3 = { "Apple", "Orange", "Banana" };
              JComboBox comboBox3 = new JComboBox( items3 );
              DefaultCellEditor dce3 = new DefaultCellEditor( comboBox3 );
              editors.add( dce3 );
              //  Create the table with default data
              Object[][] data =
                   {"Color", "Red"},
                   {"Shape", "Square"},
                   {"Fruit", "Banana"},
                   {"Plain", "Text"}
              String[] columnNames = {"Type","Value"};
              DefaultTableModel model = new DefaultTableModel(data, columnNames);
              JTable table = new JTable(model)
                   //  Determine editor to be used by row
                   public TableCellEditor getCellEditor(int row, int column)
                        int modelColumn = convertColumnIndexToModel( column );
                        if (modelColumn == 1 && row < 3)
                             return (TableCellEditor)editors.get(row);
                        else
                             return super.getCellEditor(row, column);
              JScrollPane scrollPane = new JScrollPane( table );
              getContentPane().add( scrollPane );
         public static void main(String[] args)
              TableComboBoxByRow frame = new TableComboBoxByRow();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setVisible(true);
    }

  • How can I put validation for JTextField when gotfocus and lostfocus

    Hi,
    How can I put validation for JTextField when gotfocus and lostfocus ?
    Thanks
    Wilson

    You add a focusListener to the control you wish to monitor. In the focusLost() handler you do whatever, in the focusGained() handler you do whatever.

  • FocusLost event for JTable during cell editing

    When a cell in a JTable is getting edited, how can I get notified of the focusLost event? I added the focus listener using JTable.addFocusListener, but the focusLost of the listener is not called when a cell inside the table is getting edited (it works fine otherwise). I am aware of the client property terminateEditOnFocusLost to solve this problem in 1.4 but I can't use it since I am still on 1.3.1_04.
    Suggestions welcome.

    http://forum.java.sun.com/thread.jsp?forum=57&thread=431440

  • Capture focusLost event

    Hello
    I'm working with a JProgessBar and I would like it to capture focusLost event?
    Is it possible to do this, without having to customize the src.
    Thanx

    JProgressBar my_bar = ...
    my_bar.addFocusListener(new FocusAdapter()
            public void focusLost(FocusEvent e)
                // event code goes here
        });This is possible because...
    JProgressBar is a type of JComponent
    All JComponents extend Container, which extends Component
    All Components have the ability to add focus listeners.
    Did this answer your question? Let me know if I missed something.

  • Validating a JTextField having a float or double value.

    Hello,
    I need help in validating a JTextfield which will accept a float or double value because it the deposit field and it shouldn't be of length more than 7 before the decimal and 2 after the decimal.That is it should be of length 10.I have written the following code for the validation.
    txtDeposit.addKeyListener(new KeyAdapter(){
    //Accept only integer value
              public void keyTyped(KeyEvent e){
              char c = e.getKeyChar();
    if((txtDeposit.getText()).length() == 10)
              if (!(Character.isDigit(c)))
              if(!Character.isISOControl(c))
              getToolkit().beep();
              e.consume();
              });//end of txtDeposit*/
    Please help.

    use javax.swing.InputVerifier
    import java.awt.BorderLayout;
    import java.awt.Toolkit;
    import javax.swing.InputVerifier;
    import javax.swing.JButton;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JTextField;
    public class VerifyInput extends JFrame {
        public VerifyInput(){
            super("Input Verifier");
            this.setSize(200, 200);
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JTextField txt = new JTextField();
            txt.setInputVerifier(new CheckInput());
            this.getContentPane().add(txt, BorderLayout.NORTH);
            JButton btnMoveFocus = new JButton("CLick");
            this.getContentPane().add(btnMoveFocus, BorderLayout.SOUTH);
        public static void main(String[] args) {
            VerifyInput f = new VerifyInput();
            f.setVisible(true);
        class CheckInput extends InputVerifier{
            private int lengthBeforeDot = 7;
            private int lengthAfterDot = 2;
            public CheckInput(){
            public CheckInput(int lengthBeforeDot, int lengthAfterDot){
                this.lengthAfterDot = lengthAfterDot;
                this.lengthBeforeDot = lengthBeforeDot;
            public boolean verify(JComponent input) {
                boolean correct = true;
                try {
                    JTextField tField = (JTextField) input;
                    String text = tField.getText();
                    if(text.length() == 0){
                        return true;
                    if ((correct = isDoubleOrFloat(text))) {
                        correct = isFormatCorrect(text);
                } finally {               
                    if(!correct){
                        Toolkit.getDefaultToolkit().beep();
                        System.out.println("Not Correct");
                    }else{
                        System.out.println("Correct");
                return correct;
            private boolean isDoubleOrFloat(String text){
                try{
                    Double.parseDouble(text);
                }catch(NumberFormatException nfe){
                    return false;
                return true;
            private boolean isFormatCorrect(String text){
                int dotIndex = text.indexOf('.');
                if(dotIndex < 0){
                    return text.length() <= lengthBeforeDot;
                String beforeDecimal = text.substring(0, dotIndex - 1);
                if(beforeDecimal.length() >= lengthBeforeDot){
                    return false;
                String afterDecimal = text.substring(dotIndex + 1);
                if(afterDecimal.length() > lengthAfterDot){
                    return false;
                return true;
    }

  • Input Validator : FocusLost event handling

    I am new to working with FocusListener and I am trying to use it validate the input of a textfield to be an integer.
    This seems like a seemingly simple thing to do, but I am getting errors.
    Here is a portion of the code where I make the textfield and assign it to a focus listener.
    InputValidator i = new InputValidator();
    resolutionlabel = new JLabel("Resolution: ");
    p.add(resolutionlabel);         
    resolutiontextbox = new JTextField("3200");        
    resolutionlabel.setLabelFor(resolutiontextbox);
    resolutiontextbox.addFocusListener(i);
    p.add(resolutiontextbox);Here is the important parts of the focus listener code:
    public class InputValidator extends FocusAdapter
        public InputValidator()
        public void focusLost(FocusEvent event)
         validate((TextField)(event.getSource()));
        private void validate(TextField field)
    }The error I am getting is on the line where I call the validate function and is listed as :
    java.lang.ClassCastException: javax.swing.JTextField

    this might be an alternative way - it won't accept non-digit characters
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.text.*;
    class Testing extends JFrame
      public Testing()
        setLocation(400,300);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        JPanel jp = new JPanel();
        JTextField tf = new JTextField(new NumberLimiter(),"3200",10);
        jp.add(tf);
        getContentPane().add(jp);
        pack();
      class NumberLimiter extends PlainDocument
        public void insertString(int offs, String str, AttributeSet a) throws BadLocationException
          char[] characters = str.toCharArray();
          for(int x = 0, y = characters.length; x < y; x++)
            if(Character.isDigit(characters[x]) == false)
              java.awt.Toolkit.getDefaultToolkit().beep();
              return;
          super.insertString(offs, str, a);
      public static void main(String[] args){new Testing().setVisible(true);}
    }

  • Why windowclosing event occurs before focusLost event of JTextField?

    I have the following code:
    JTextField field = new JTextField();
    *field.addFocusListener(new FocusAdapter(){*
    *public void focusLost(FocusEvent e) {*
    JOptionPane.showMessage(null,"test");
    *window.addWindowListener(new WindowAdapter() {*
    *public void windowClosing(final WindowEvent e) {*
    window.dispose();
    when the focus in field, then I click X button on window, window is closed, but then message dialog shows.
    I want message dialog must show before window closing.
    Help me.
    thanks very much.
    Edited by: phamtrungkien on Sep 24, 2008 2:23 AM

    You could try wrapping the call to dispose() in a SwingUtilities.invokeLater.
    Note that the Swing/AWT event model does not guarantee the order of delivery of events, so the sequence of execution of listener methods is not an accurate indicator of the order in which the events were generated.
    db
    edit What class is your variable reference window?
    If JFrame, what defaultCloseOperation is set?
    Edited by: Darryl.Burke

  • Validation in JTextField

    Hi ,
    I have a JTextField, a JComboBox , a JButton , a JList and a JTable in my Frame. I enter a value in JTextField which has to be validated with a constant. Where do u write the validation ?
    i have written the validation in focus lost of JTextField.
    This causes problem when i click on the jtable or jcombobox. When i click on the combobox after entering a wrong value in the textfield, cursor remains in the jtextfield but i am able selected a value from the jcombobox as well.
    Following is the sample code.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.table.*;
    * Title:
    * Description:
    * Copyright: Copyright (c) 2001
    * Company:
    * @author
    * @version 1.0
    public class EnabledTest extends JFrame implements FocusListener
    JTextField jTextField1 = new JTextField();
    JTextField jTextField2 = new JTextField();
    JComboBox jComboBox1 = new JComboBox();
    JList jList1 = new JList();
    JButton jButton1 = new JButton();
    JTable jTable1 = new JTable();
    public EnabledTest()
    try
    jbInit();
    addListeners();
    catch(Exception e) {
    e.printStackTrace();
    public static void main(String[] args)
    EnabledTest enabledTest1 = new EnabledTest();
    enabledTest1.setVisible(true);
    enabledTest1.setBounds(0,0,400,400);
    public void addListeners()
    jTextField1.addFocusListener(this);
    jTextField2.addFocusListener(this);
    jComboBox1.addFocusListener(this);
    jList1.addFocusListener(this);
    jButton1.addFocusListener(this);
    public void focusGained(FocusEvent e)
    public void focusLost(FocusEvent e)
    if(e.getSource() == jTextField1)
    jTextField1_validationPerformed(e);
    private void jbInit() throws Exception
    jTextField1.setText("jTextField1");
    jTextField1.setBounds(new Rectangle(49, 39, 144, 38));
    this.getContentPane().setLayout(null);
    jTextField2.setBounds(new Rectangle(227, 40, 144, 38));
    jTextField2.setText("jTextField1");
    jComboBox1.setBounds(new Rectangle(52, 115, 141, 34));
    jComboBox1.addItem("one");
    jComboBox1.addItem("two");
    jList1.setBounds(new Rectangle(239, 110, 135, 120));
    jButton1.setText("jButton1");
    jButton1.setBounds(new Rectangle(56, 187, 127, 29));
    jTable1.setBounds(new Rectangle(55, 251, 330, 117));
    jTable1.setModel(new DefaultTableModel(3,3));
    this.getContentPane().add(jTextField1, null);
    this.getContentPane().add(jTextField2, null);
    this.getContentPane().add(jComboBox1, null);
    this.getContentPane().add(jList1, null);
    this.getContentPane().add(jButton1, null);
    this.getContentPane().add(jTable1, null);
    private void jTextField1_validationPerformed(FocusEvent e)
    jTextField1.removeFocusListener(this);
    int intValue = new Integer(jTextField1.getText()).intValue();
    if (intValue > 100)
    JOptionPane.showMessageDialog(this, "Should be < 100");
    jTextField1.requestFocus();
    jTextField1.addFocusListener(this);
    }

    It is fairly easy to validate for a range. I added this kind of validation (attached (*)). At any time you may want to set the validity range of your NumericJTextField. I did it as follows:
    this.numericTextField.setValidityRange(-999, +999);
    I tested and it does work nicely - couldn't fool it.
    (*) Is there any holy way to post files without having to cut and paste them as a whole in this doubly holy tab-eater JTextArea :-(
    package textfieldvalidator;
    * Title: NumericJTextField
    * Description: An example JTextFiled that accepts only digits
    * Copyright: nobody - use it at will
    * Company:
    * @author Antonio Bigazzi - [email protected]
    * @version 1.0 First and last
    import javax.swing.*;
    import javax.swing.text.*;
    import java.awt.*;
    public class ValidatorExample extends JPanel {
    NumericJTextField numericTextField; // accepts only digit
    JTable table;
    public ValidatorExample() {
    this.setLayout(new BorderLayout());
    this.numericTextField = new NumericJTextField("1234X5");
    this.numericTextField.setBackground(Color.black);
    this.numericTextField.setForeground(Color.yellow);
    this.numericTextField.setCaretColor(Color.white);
    this.numericTextField.setFont(new Font("Monospaced", Font.BOLD, 16));
    this.numericTextField.setValidityRange(-999, +999);
    this.table = new JTable(
    new String[][] { {"a1a", "b2b", "c3c"}, {"456", "777", "234"}},
    new String[] {"Col 1", "Col 2", "Col 3"}
    this.add(this.numericTextField, BorderLayout.NORTH);
    this.add(this.table, BorderLayout.CENTER);
    public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setContentPane(new ValidatorExample());
    f.setLocation(300, 75);
    f.pack();
    f.setVisible(true);
    // ===================== the meat ============================
    // the specialized JTextField that uses a restrictive doc model
    class NumericJTextField extends JTextField {
    NumericJTextField() {this("", 0);}
    NumericJTextField(String text) {this(text, 0);}
    NumericJTextField(int columns) {this("", columns);}
    NumericJTextField(String text, int columns) {
    super(new NumericDocument(), text, columns);
    public void setValidityRange(int min, int max) {
    ((NumericDocument)this.getDocument()).setValidityRange(min, max);
    // check what may have been there already (via constructor)
    this.setText(this.getText());
    // the restricted doc model - non-numbers make it beep
    class NumericDocument extends PlainDocument {
    protected int minValue = Integer.MIN_VALUE;
    protected int maxValue = Integer.MAX_VALUE;
    public void setValidityRange(int minValue, int maxValue) {
    this.minValue = minValue;
    this.maxValue = maxValue;
    public void insertString(int offset, String text, AttributeSet a)
    throws BadLocationException {
    // digits only please (or bring your own restriction/validation)
    StringBuffer buf = new StringBuffer(text.length());
    for (int i = 0; i < text.length(); i++) {
         if (Character.isDigit(text.charAt(i))) {
         buf.append(text.charAt(i));
         } else {
         java.awt.Toolkit.getDefaultToolkit().beep();
    super.insertString(offset, buf.toString(), a);
    // get the whole "document" back for range validation
    while(true) {
    String num = this.getText(0, this.getLength());
         if (num.length() == 0) break;
         int value = Integer.parseInt(num);
         if (value >= this.minValue && value <= this.maxValue) {
         break;
         } else {
         // beeep and chop (or whatever reaction for out of range)
         java.awt.Toolkit.getDefaultToolkit().beep();
         this.remove(this.getLength() - 1, 1);
    // Note: in insertString, length is 1 when typing, but it can be anything
    // when the text comes from the constructor, when it is pasted, etc.
    }

  • FocusLost event/navigatedOutColumn to non-DACF controls

    In the textAreaControl source I see:
    // Focus Listener implementation
    * This method is an implementaion side effect
    public void focusLost(FocusEvent event)
    When I do a focus lost event off the property panel in Designer... and add code to simply do a System.out.println("Focus Lost") on the control... nothing happens when I move to another control and the textareacontrol lost focus.
    The correct approach seems to be use the NavigatedOutColumn event which does fire. ( hurrah! )...
    BUT.... as I had a suspicion... if I enter into a DACF control, and then click in a NON-DACF control ( in this case, a secondary plain jtextfield password confirmation field )... neither FocusLost nor NavigatedOutColumn fires.
    It sorta makes sense, because we haven't navigated into a new Column. ( Is this a terminology conflict/level mix problem? It seems to be relating Column to a rowSetInfo AttributeInfo / EO/VO attribute?
    Note that, at least in my case, there are PLENTY of non DACF controls. Particularly JButtons.
    As mentioned before, I avoided ButtonControls because I had no DataItemName to associate with 'em... which seemed to cause grief in other places ( in my memory using 3.O ). I actually went back and changed all the ButtonControls I had to JButtons.
    This puts me into a rather interesting quandary... or is it safe in 3.2/JRE1.3 to use ButtonControls with no property set for the DataItemName()?
    TIA

    You are being tripped up by two things. One is a bug and the other is a difference between the 3.2 and 9i (aka 5.0) versions of the NavigationManager. The ComponentNavigationMonitor is OK though. Both of these can be worked around using the ComponentNavigationManager though the resultant code will not be compatible with the code released in the next version of JDeveloper. The solution is to rewrite the focusGained() method and write the new method _applyEdits(). The rewritten and new methods are below in a new version of the class. Notice the package name change; it is now in a new package called oracle.dacf.unsupported. This way, you can just change the package name when the next version is released:
    <code>
    // oracle/dacf/unsupported/ComponentNavigationMonitor.java
    // Oracle JDeveloper
    // Copyright (c) 2001 by Oracle Corporation
    // All rights reserved.
    package oracle.dacf.unsupported;
    // imports
    import java.awt.Component;
    import java.awt.event.FocusAdapter;
    import java.awt.event.FocusEvent;
    import java.awt.event.FocusListener;
    import javax.swing.SwingUtilities;
    import oracle.dacf.control.ApplyEditsListener;
    import oracle.dacf.control.ApplyEditsValidationException;
    import oracle.dacf.control.Control;
    import oracle.dacf.control.NavigationManager;
    ** The ComponentNavigationMonitor allows a Component, AWT or Swing,
    ** to be used in an application and still have the DAC navigation and
    ** validation event framework generate the proper events at the
    ** appropriate times. Normally, non-Control components can not
    ** participate in the DAC navigation and validation event framework
    ** because they don't have the mechanisms to notify the framework that
    ** the focus has moved.
    ** This class is implemented as a singleton and could be hooked into every
    ** non-Control Component that is displayed on the screen. It should not be
    ** attached to DAC Controls because these classes already contain the
    ** functionality contained in this class. Attaching this class to a DAC
    ** Control will minimally result in double navigation and validation
    ** eventing with the resultant performance degradation. Redundant
    ** navigation and validation could also result in anomalous application
    ** behavior.
    ** The DAC design-time and runtime framework does not automatically
    ** register non-Controls with the ComponentNavigationMonitor because of
    ** the ambiguity surrounding when this should be done. If the components
    ** are constructed using a Factory design pattern, then the factory would
    ** be the optimal place to attach this listener. If your application
    ** doesn't use this approach then you will have to individually hook each
    ** component. (Sorry, but there is no way around this fact.) You might
    ** try something like what the following code fragment illustrates in the
    ** method that instantiates the component:
    ** <blockquote>
    ** <code>
    ** TextField dateWidget =
    ** new TextField((new Date()).toLocaleString());
    ** ComponentNavigationMonitor.observe(dateWidget);
    ** </code>
    ** </blockquote>
    ** For example, if JDeveloper was used to generate code, via either the
    ** DAC wizards or the visual designer, then you would place this code in
    ** the jbInit() method of the panel or frame.
    ** @author Donald King
    public class ComponentNavigationMonitor
    extends FocusAdapter
    private NavigationManager nm;
    private static ComponentNavigationMonitor monitor;
    private static Object observeGate = new Object();
    private static final boolean _DEBUG = true;
    private ComponentNavigationMonitor()
    } // ComponentNavigationMonitor
    ** Responds to the gaining of focus by a component.
    ** This method is responsible for causing validation to be performed and
    ** restoring forcus to the proper control if validation fails.
    public void focusGained(FocusEvent evt)
    Control ctrl;
    if (nm == null)
    nm = NavigationManager.getNavigationManager();
    ctrl = nm.getFocusedControl();
    // the getChangeLevel() parameters are reversed to workaround
    // bug 1678351; fixed for 9i (aka 5.0)
    if (ctrl != null &&
    !_applyEdits(ctrl) &&
    !nm.validateFocusedControl(nm.getChangeLevel(null,ctrl)))
    Component c = ctrl.getComponent();
    // Paranoia is a good thing; the following is expensive, only do
    // it if we must
    if (c != null)
    SwingUtilities.invokeLater(new DelayedFocus(c));
    else
    // move the NavigationManager into the proper state so that it
    // can properly respond to the next control that gains focus
    nm.validateFocusChange(null);
    ** This functionality is embedded in the 9i (aka 5.0) version of
    ** NavigationManager.validateFocusedControl(int changeLevel)
    private boolean _applyEdits(Control ctrl)
    boolean ok = true;
    if (ctrl instanceof ApplyEditsListener)
    try
    ((ApplyEditsListener)ctrl).applyEdits();
    catch(ApplyEditsValidationException aeve)
    ok = false;
    return(ok);
    ** Registers the ComponentNavigationMonitor as a FocusListener.
    public static void observe(Component c)
    synchronized(observeGate)
    if (monitor == null)
    monitor = new ComponentNavigationMonitor();
    c.addFocusListener(monitor);
    ** Unregisters the ComponentNavigationMonitor as a FocusListener.
    public static void unobserve(Component c)
    synchronized(observeGate)
    if (monitor == null)
    monitor = new ComponentNavigationMonitor();
    c.removeFocusListener(monitor);
    private class DelayedFocus
    implements Runnable
    private Component pending;
    DelayedFocus(Component c)
    pending = c;
    public void run()
    if (pending != null)
    pending.requestFocus();
    private void _debug(String s)
    if (_DEBUG)
    System.out.println("ComponentNavigationMonitor: " + s);
    } // _debug
    } // ComponentNavigationMonitor
    // oracle/dacf/unsupported/ComponentNavigationMonitor.java
    // Oracle JDeveloper
    // Copyright (c) 2001 by Oracle Corporation
    // All rights reserved.
    </code>

  • Maintenance view event for validation when changing data

    Hi All,
    I have a maintenance view on a table that should validate some fields during user input.
    I am using event 05 'Creating a new entry' to validate fields when user creates new entry in the table. That works fine.
    I would like to have the same validations happening when the user changes fields of records already existing in the database. I tried to use event 01 'Before saving the data in the database' but the problem with this is that user can change many fields of many records before clicking 'Save'. I would like to have the error raised for incorrect entry already after the change.
    So far I could not find an event to do this but only by changing the code itself. The problem with that is whenever the code is regenerated the custom part is lost.
    Is there an event I can use that would help me achieve this?
    Thanks in advance.

    Hi Abhishek,
    I tried event 21, I`m playing around with that since that`s the only one triggered when I press Enter.
    The problem with this is that
    - the check runs when you press enter, so you can still change many fields of many records (one step maintenance) before the validation runs
    - you can`t raise an error message, because only the key fields will be input ready, the non-key fields will be readonly
    The way I currently handle is I undo the changes in 21 (get previous field values from TOTAL) and raise an information message i/o an error informing user to check the entry.
    What I`m looking for is an event that will raise a message and set focus on the incorrect field (if there`s one such).

  • Break out of event

    Seems kind of simple, but I am wondering how I can exit the execution of an event, like the way I do in Validate (true or false;). Is it exit; or something?

    Depending on what language and the exact code, "break;" will end the execution of a block of code.

  • Why do I not catch the FocusLost Event in the JPasswordField

    I write a subclass of JPasswordField, which does some functions when it loses the focus. But, it dosen't work. How to make it work?
    <The same method work well for JTextField>
    Here is the sample code
    public class MyPasswordField
    extends JPasswordField
    implements FocusListener
    public void focusGain(FocusEvent e){}
    public void focusLost(FocusEvent e)
    // method body
    logger.debug("focus lost - caught!");
    // constructors
    I am wishing the "focus lost - caught!" could be printed out!!
    Thanks

        public class MyPasswordField   extends JPasswordField  implements FocusListener {
            public MyPasswordField(){
                addFocusListener(this);
    // ....

  • Human Task Events's Validation Callback Errored out  while using EJB method

    Hi All,
    We are using weblogic version 10.3.5. and Jdev 11.1.1.5.0
    In our BPM Process we have human tasks,in human task Events,we are using Validation Callback to save and get some information.To save and get information we are ejb.
    1)We have created one BaseTaskValidator.java which implements ITaskValidationCallback.
    2)we have override the validateTaskOperation() method in BaseTaskValidator.java
    3)We have created one more TaskReminderService.java extends BaseTaskValidator
    4)In TaskReminderService.java,when we trying to get information from Database with help of EJB we are getting the below error.
    [2012-10-14T21:05:47.610+05:30] [soa_server1] [ERROR] [] [oracle.soa.services.workflow.task] [tid: [ACTIVE].ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: Amar.Kant] [ecid: 1416ca41dee3590b:5c59d6e4:13a59f6159b:-8000-0000000000021e0b,0] [APP: soa-infra] [composite_name: ARCN] [component_name: CNRequestTask] [component_instance_id: 204583] [composite_instance_id: 1470009] <.> Error in invoking task validation callbacks.[[
    Error in invoking task validation Java callback com.atc.arcn.callbacks.BaseTaskValidator.performCallbacks for task 204583. The task is associated with workflow default/ARCN!1.0/CNRequestTask.
    Make sure that the task validation callback class is specified correctly without any errors. The class name should be fully qualified. Also make sure that the class and its dependencies are available in the classpath.
    ORABPEL-30099
    Error in invoking task validation callbacks.
    Error in invoking task validation Java callback com.atc.arcn.callbacks.BaseTaskValidator.performCallbacks for task 204583. The task is associated with workflow default/ARCN!1.0/CNRequestTask.
    Make sure that the task validation callback class is specified correctly without any errors. The class name should be fully qualified. Also make sure that the class and its dependencies are available in the classpath.
         at oracle.bpel.services.workflow.task.impl.TaskValidationCallbackInvoker.executeJavaCallback(TaskValidationCallbackInvoker.java:195)
         at oracle.bpel.services.workflow.task.impl.TaskValidationCallbackInvoker.performCallbacks(TaskValidationCallbackInvoker.java:104)
         at oracle.bpel.services.workflow.task.impl.TaskService.initiateTask(TaskService.java:1190)
         at oracle.bpel.services.workflow.task.impl.TaskService.initiateTask(TaskService.java:666)
         at oracle.bpel.services.workflow.task.impl.TaskService.initiateTask(TaskService.java:614)
         at sun.reflect.GeneratedMethodAccessor4268.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
         at oracle.bpel.services.workflow.common.WorkflowServiceCacheEventAdvice.invoke(WorkflowServiceCacheEventAdvice.java:91)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at oracle.bpel.services.workflow.test.workflow.ExceptionTestCaseBuilder.invoke(ExceptionTestCaseBuilder.java:155)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at oracle.bpel.services.common.dms.MethodEventAspect.invoke(MethodEventAspect.java:70)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at oracle.bpel.services.common.dms.MethodPhaseEventAspect.invoke(MethodPhaseEventAspect.java:82)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
         at $Proxy250.initiateTask(Unknown Source)
         at oracle.bpel.services.workflow.task.ejb.TaskServiceBean.initiateTask(TaskServiceBean.java:70)
         at sun.reflect.GeneratedMethodAccessor4267.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:37)
         at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54)
         at com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:50)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
         at $Proxy280.createProcessInstanceTask(Unknown Source)
         at oracle.bpm.services.instancemanagement.ejb.InstanceManagementServiceBean_sqa2w0_IInstanceManagementServiceRemoteImpl.__WL_invoke(Unknown Source)
         at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:40)
         at oracle.bpm.services.instancemanagement.ejb.InstanceManagementServiceBean_sqa2w0_IInstanceManagementServiceRemoteImpl.createProcessInstanceTask(Unknown Source)
         at oracle.bpm.services.instancemanagement.ejb.InstanceManagementServiceBean_sqa2w0_IInstanceManagementServiceRemoteImpl_WLSkel.invoke(Unknown Source)
         at weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:174)
         at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:345)
         at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259)
         at oracle.bpm.services.instancemanagement.ejb.InstanceManagementServiceBean_sqa2w0_IInstanceManagementServiceRemoteImpl_1035_WLStub.createProcessInstanceTask(Unknown Source)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:85)
         at $Proxy404.createProcessInstanceTask(Unknown Source)
         at oracle.bpm.papi.ora.util.ApplicationExecution11G.beginExecution(ApplicationExecution11G.java:50)
         at fuego.papi.utils.ApplicationExecution.beginExecution(ApplicationExecution.java:29)
         at oracle.bpm.workspace.model.common.ExecutionBean.handleExternalInstanceExecution(ExecutionBean.java:171)
         at oracle.bpm.workspace.model.application.ApplicationBean.execute(ApplicationBean.java:148)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.el.parser.AstValue.invoke(Unknown Source)
         at com.sun.el.MethodExpressionImpl.invoke(Unknown Source)
         at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:46)
         at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
         at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:190)
         at org.apache.myfaces.trinidad.component.UIXCollection.broadcast(UIXCollection.java:148)
         at org.apache.myfaces.trinidad.component.UIXTable.broadcast(UIXTable.java:279)
         at oracle.adf.view.rich.component.UIXTable.broadcast(UIXTable.java:145)
         at oracle.adf.view.rich.component.rich.data.RichTable.broadcast(RichTable.java:402)
         at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:102)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:92)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:361)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:96)
         at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:96)
         at oracle.adf.view.rich.component.fragment.UIXRegion.broadcast(UIXRegion.java:148)
         at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:102)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:92)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:361)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:96)
         at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:96)
         at oracle.adf.view.rich.component.fragment.UIXRegion.broadcast(UIXRegion.java:148)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:92)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:361)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:96)
         at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:102)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:92)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:361)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:96)
         at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:96)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:92)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:361)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:96)
         at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:102)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:92)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:361)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:96)
         at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:96)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.broadcastEvents(LifecycleImpl.java:902)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:313)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:186)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.help.web.rich.OHWFilter.doFilter(Unknown Source)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:205)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
         at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:271)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:177)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:175)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
         at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
         at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
         at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
         at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
         at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
         at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
    Caused by: java.lang.reflect.InvocationTargetException
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at oracle.bpel.services.workflow.task.impl.TaskValidationCallbackInvoker.executeJavaCallback(TaskValidationCallbackInvoker.java:191)
         ... 344 more
    Caused by: java.lang.NullPointerException
         at com.atc.arcn.util.TaskReminderService.getTaskDetails(TaskReminderService.java:72)
         at com.atc.arcn.util.TaskReminderService.setReminderDuration(TaskReminderService.java:64)
         at com.atc.arcn.util.TaskReminderService.setReminderDuration(TaskReminderService.java:56)
         at com.atc.arcn.callbacks.BaseTaskValidator.processInitiate(BaseTaskValidator.java:96)
         at com.atc.arcn.callbacks.BaseTaskValidator.validateTaskOperation(BaseTaskValidator.java:52)
         ... 349 more
    Please help on this issue.It is little bit urgent for us to resolve.
    Thanks in advanced.

    Thanks for reply Ravi.
    The NullPointerException is beacuse of JNDI problem,we resolved that issue.We are able to create the ejb instance but with that instance when we are trying to call ejb method,we are getting the below error in console and the BPM instance is not getting created.
    We are able to create the instance of the EJB Bean.But when we try to call the method of EJB Bean(getTaskDetailsByTaskName(taskName)),the BPM instance is not getting created from BPM workspace.If we comment the code for the method of EJB Bean(getTaskDetailsByTaskName(taskName)) able to create the instance from BPM workspace.When we checked the log file this error,it is
    Caused by: fuego.papi.exception.CannotCreateInstanceException: Cannot create instance in process 'default/ARCN!1.0*/ARCN'.
         at oracle.bpm.papi.ora.helper.ExceptionHelper.wrapException(ExceptionHelper.java:58)
         at oracle.bpm.papi.ora.util.ApplicationExecution11G.beginExecution(ApplicationExecution11G.java:56)
         at fuego.papi.utils.ApplicationExecution.beginExecution(ApplicationExecution.java:29)
         at oracle.bpm.workspace.model.common.ExecutionBean.handleExternalInstanceExecution(ExecutionBean.java:171)
         ... 102 more
    Caused by: BPM-70204
    Exception
    exception.70204.type: error
    exception.70204.severity: 2
    exception.70204.name: Error creating process instance.
    exception.70204.description: Error creating instance for target process default/ARCN!1.0*/ARCN.
    exception.70204.fix: Verify server log to find the problem cause.
         at weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:205)
         at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:345)
         at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259)
         at oracle.bpm.services.instancemanagement.ejb.InstanceManagementServiceBean_sqa2w0_IInstanceManagementServiceRemoteImpl_1035_WLStub.createProcessInstanceTask(Unknown Source)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:85)
         at $Proxy407.createProcessInstanceTask(Unknown Source)
         at oracle.bpm.papi.ora.util.ApplicationExecution11G.beginExecution(ApplicationExecution11G.java:50)
         ... 104 more
    Could you please suggest me on this issue.
    Thanks,
    Narasimha

Maybe you are looking for