Thread in action listener

Anyway, back to something that matters.....
public void StartSqueezing()
NozzleReady=false;
NozzleInUse=true;
NozzleNotInUse=false;
Runnable run1 = new Runnable() { public void run()
do{
LitresDispensedPerTransaction =+ 0.10;
try { Thread.sleep(200);}
catch(InterruptedException ex) {}
while (NozzleInUse == true );
Thread thrd1 = new Thread(run1);
thrd1.start();
I have put this is the action listener of a button and it wont work....any ideas???
Edward

Quit multi-posting. You already have a posting on the topic.
Not only that you haven't listened to any advice given in that topic so don't expect any further help.
a) still no "Code" tags
b) variable name still don't follow standards
If you want us to read you code then make an effor to make it readable.
You've already been given a link to the Swing tutorial, I suggest you take the time to read the section on "How to use Action Listeners".
This posting is now closed.

Similar Messages

  • I need a code example for an action listener for a jcheckbox using matisse

    I am trying to make it so that when some body clicks a jcheckbox it will put a figure into a jtextfield. Because I am using matisse I need to know the code for the action listener and I need to know quickly as well so I don't have time to look it up with searches etc.
    Can anbody provide me with some example code please.

    I thought that as you are all more experienced than I am that you would know where to look and as you would have already been to all of the sites you would have been able to save me a lot of time looking for the best one. I didn't mean to insult you sorry, I knew that I would be looking for a long time and hoped that some one could help speed that up for me.
    Any way I have obviously annoyed you in that thread earlier this week. I know that you are all pee'd at me and don't believe me and that is fine. I have learnt every thing that I need to learn and would like to thank you for your help although I think that your language in your last post was not very pleasant, but that is ok.
    I don't want to continue posting any more. But thank you for your help.

  • Add action listener to table cell

    The topic of my previous thread was:
    How can I get characters, which user inputs into table cell?
    I've added lisateners to table:
    table.addKeyListener(new java.awt.event.KeyAdapter() {
                public void keyPressed(java.awt.event.KeyEvent evt){
                    System.out.println("keyPressed");
                public void keyReleased(java.awt.event.KeyEvent evt){
                    System.out.println("keyReleased");
                public void keyTyped(java.awt.event.KeyEvent evt) {
                    System.out.println("keyTyped");
            });But it's not exactly what I need.
    I need to do the same, but with table cell.
    I want to see user input char by char and set color font for user input string.
    How can I add action listener to tble cell?

    This is my newly created JTextField which I will use as CellEditor for My JTable
    JTextField textField = new JTextField(); //creating Component
            textField.addKeyListener(new java.awt.event.KeyAdapter(){ //adding KeyListener
                public void keyReleased(java.awt.event.KeyEvent evt){
                    System.out.println("keyReleased" + ((JTextField)evt.getSource()).getText() + "column = " +table.getSelectedColumn());//test functionality
                    if ( isColumnHasSameValue(table.getSelectedRow(),table.getSelectedColumn(), ((JTextField)evt.getSource()).getText() ) ){//test column for equal values
                        ((JTextField)evt.getSource()).setForeground(Color.RED); //if there is equal value set Color.RED for JTextField text
                    else{ //else set Color.BLACK
                        ((JTextField)evt.getSource()).setForeground(Color.BLACK);
            table.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(textField)); //set custom CellEditor
    private boolean isColumnHasSameValue(int row, int column, String testVal){
            testVal = testVal.trim().toLowerCase(); //put away UpperCase and empty spaces
            for(int i=0;i<model.getRowCount();i++){
               if(i == row){
                   continue;//skip selected row where user inputs text
               if(model.getValueAt(i,column).toString().trim().toLowerCase().startsWith(testVal)){
                    return true; //if test passed
            return false; //if there are no mathes
        }I have a question:
    It seems to me, I did not use optimal solution for JTable values testing.
    What can ty else?
    Maybe, It is better to use
    tableModel.getDataVector();And then use Pattern and Matcher ?
    Am I right?

  • How can i disable an Action listener temporary?

    hi folks,
    I have a GUI with many Jcomboxes. Each one of them has an actionlistener.
    The idea was: when one of those comboboxes is selected, then the selected value will appear on ALL the comboboxes (by using setSelectedIndex(int index)).
    The problem is when i select a value on ONE of those comboboxes and set it on the others, the actionListener thinks that i selcted a value on the other comboboxes and starts setting the values again... I other words if i select one combobox i obtain an endless loop...
    Is it possible to disable the action listener temporary when setting the selectd values on the other comboboxes?

    Just use removeActionListener and then addActionListener
    Noah

  • Property on Backing Bean is Not set when Action Listener is Fired

    Why is it that when my action listener is invoked, the property for my other component on the page has not been reflected in model yet?
    Here is what I have:
    My JSP has the following two components:
    <h:inputText value="#{manageQuestionBean.newStory}"></h:inputText>
    <h:commandButton value="add" actionListener="#{manageQuestionBean.onAddStory}"></h:commandButton> My Java code has the following:
    public void onAddStory(ActionEvent event) {
           //This always prints out 'null'
           System.out.println("The value of 'newStory' is: " + newStory);
          //TO DO: this is where the logic would go for creating a new story object.
        } When I put logging statements inside my setter for the newStory property, I see that it is being set to the right value, but then it being reset to empty string. Why is that? During what phase do the action listeners get invoked?

    Which JSF implementation/version are you using?
    mczauz wrote:
    When I put logging statements inside my setter for the newStory property, I see that it is being set to the right value, but then it being reset to empty string. Why is that? When exactly happens when exactly?
    During what phase do the action listeners get invoked?The invoke application phase, after the update model values phase.
    You may find this article useful to learn about phases and how to add a 'phase debugger' yourselfl: [http://balusc.blogspot.com/2006/09/debug-jsf-lifecycle.html].

  • Transaction Posting Confirmation Message and Action Listener behaviour

    Hi, I have a scenario that a user is Posting a Transaction and when he press the “Post” Button a, confirmation dialog box should popup asking “Do you really want to Post the record ?”. If the user press “Yes” the record is further process and If the user press “No” then the transaction should not proceed.
    I have implemented the main screen(PostTransaction.java) and the popup confirmation window(ConfirmationWindow.java)
    Question 1 ) Why the code is not stoping in the Post Button Action listener as in JOptionPane, then how do i know that the user has selected "Yes" or "No" ?
    Question 2) Do I have to write the code for posting of a Transaction(postTransaction() method) in the “ConfirmationWindow”? or it should be in “PostTransaction”.
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.application.Application;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.Label;
    import javafx.scene.control.TextField;
    import javafx.scene.layout.GridPane;
    import javafx.stage.Stage;
    public class PostTransaction extends Application{
           public void start(final Stage stage) throws Exception {
                  Group root = new Group();
                  Scene scene = new Scene(root, 300,300);
                  stage.setScene(scene);
                  stage.setTitle("Transaction Post Screen");
                  GridPane gp = new GridPane();
                  Label lblName = new Label("Name");
                  Label lblAmount = new Label("Amount");
                  TextField txtName = new TextField();
                  TextField txtAmount = new TextField();
                  Button btnPost = new Button("Post Record");
                  gp.add(lblName, 1, 1);
                  gp.add(lblAmount, 1, 2);
                  gp.add(txtName, 2, 1);
                  gp.add(txtAmount, 2, 2);
                  gp.add(btnPost, 2, 3);
                  btnPost.setOnAction(new EventHandler<ActionEvent>() {
                        @Override
                        public void handle(ActionEvent arg0) {
                             //The code does not stop here as in JOptionPane, then how do i know that the user has selected "Yes" or "No" ??
                             boolean popupResult = ConfirmationWindow.confirmTranactionPosting(stage, "Please Confirm");
                             if(popupResult==true){
                                  //This line is printed before the user selects yes or no
                                  System.out.println("Proceeding with Tranaction Posting");
                                  //postTransaction();
                             if(popupResult==false){
                                  //This line is printed before the user selects yes or no
                                  System.out.println("Do not Proceed with Tranaction Posting");
                 root.getChildren().add(gp);
                stage.show();
                public static void main(String[] args) {
                  launch(args);
              private void postTransaction(){
                   //write the code for posting here
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.Label;
    import javafx.scene.layout.BorderPane;
    import javafx.scene.layout.HBox;
    import javafx.stage.Modality;
    import javafx.stage.Stage;
    import javafx.stage.StageStyle;
    public class ConfirmationWindow extends Stage {
         Stage owner;
         Stage stage;
         BorderPane root;
         static boolean postStatus = false;
      public ConfirmationWindow( Stage owner, String title){
        root = new BorderPane();
        stage = this;
        this.owner = owner;
        initModality( Modality.APPLICATION_MODAL );
        initOwner( owner );
        initStyle( StageStyle.UTILITY );
        setTitle( title );
        setContents();
      public void setContents(){
        Scene scene = new Scene(root,250,150);
        setScene(scene);
        Group groupInDialog = new Group();
        groupInDialog.getChildren().add( new Label("Do you really want to Post this record ?") );
        root.setCenter( groupInDialog );
        Button yes = new Button( "Yes" );
        yes.setOnAction(new EventHandler<ActionEvent>() {
              @Override
              public void handle(ActionEvent e) {
                   postStatus =true;
                   stage.close(); // Close the pop up. Transfer control to PostTransaction.java and execute the PostTransaction() method.
        Button no  = new Button( "No" );
        no.setOnAction(new EventHandler<ActionEvent>() {
              @Override
              public void handle(ActionEvent e) {
                   postStatus =false;
                   stage.close(); // Close the pop up only
        HBox buttonPane = new HBox();
        buttonPane.setSpacing(10);
        buttonPane.getChildren().addAll(yes,no);
        root.setBottom(buttonPane);
        stage.show();
      public static boolean confirmTranactionPosting(Stage owner, String title) {
           new ConfirmationWindow(owner, title);
           return postStatus;
    }

    The MII Message listener is a queue. But when I understand you correctly, you do not want to process the messages immediately after arriving in the Listener.
    Maybe the categorization of messages is an option for you (see [Sap Help: Processing Rule Editor - Category|http://help.sap.com/saphelp_mii121/helpdata/en/43/e80b59ad40719ae10000000a1553f6/frameset.htm]. You can enter a category for the control recipe messages. The messages will then be placed in the Listener queue. You can use the [Message Services|http://help.sap.com/saphelp_mii121/helpdata/en/43/e80b59ad40719ae10000000a1553f6/frameset.htm] actions to read the categorized messages and process them as you need.
    In addition to Manoj, you may also use the [Queueing actions|http://help.sap.com/saphelp_mii121/helpdata/en/43/e80b59ad40719ae10000000a1553f6/frameset.htm] of MII, where you can queue xml contents.
    Hope this helps.
    Michael

  • Issue with setting an Action Listener for a Command Button

    Hi all,
    I'm trying to set an action listener for a CoreCommanButton in a backing bean. Here's my code:
         CoreCommandButton editBtn = new CoreCommandButton();
              MethodBinding mb = FacesContext.getCurrentInstance().getApplication().createMethodBinding("#{backBean.doButtonAct}",null);
              editBtn.setActionListener(mb);
    //Action listener method
         public void doButtonAct(ActionEvent actionEvent)
    I keep getting a javax.faces.el.MethodNotFoundException error. However when I remove the ActionEvent parameter in doButtonAct(), I get a wrong number of arguments error.
    So i'm guessing there is something wrong with the parameters i accept in my action listener method. what can be causing this issue?
    Cheers.

    I figured this out.
    Since doButtonAct() requires an ActionEvent object as a parameter, i needed to define the parameter type when I create the method binding.
    Solution:
         Class argsString[] = new Class[] { ActionEvent.class };
              MethodBinding mb = FacesContext.getCurrentInstance().getApplication().createMethodBinding("#{backBean.doButtonAct}",argsString);

  • Calling action listener for a BUTTON component in java bean page

    Hi,
    I have made it like this.
    public void handleButtonPressed(ActionEvent event){
    System.out.println("success!!!!!");
    //code for calling actionlistener
    FacesContext fctx = FacesContext.getCurrentInstance();
    ELContext elctx = fctx.getELContext();
    Application application = fctx.getApplication();
    ExpressionFactory exprFactory = application.getExpressionFactory();
    MethodExpression methodExpr = null;
    methodExpr = exprFactory.createMethodExpression(elctx, "#{exbean.handleButtonPressed}",null,new Class[] { ActionEvent.class });
    MethodExpressionActionListener actionListener = null;
    actionListener = new MethodExpressionActionListener(methodExpr);
    button.addActionListener(actionListener);
    Even after making the listener Function as Void wHen i click the button i m getting the error saying."ARGUMENTS MISMATCH,ADF_FACES60097"??
    can you help me out?
    and in the msg log i m getting this
    "SkinFactoryImpl> <getSkin> Cannot find a skin that matches family portal and version v1.1. We will use the skin portal.desktop.
    <MethodExpressionActionListener> <processAction> Received 'javax.el.PropertyNotFoundException' when invoking action listener '#{exbean.handleButtonPressed}' for component 'null'
    <MethodExpressionActionListener> <processAction> javax.el.PropertyNotFoundException: Target Unreachable, identifier 'custombean' resolved to null"
    I Have tried with this giving Void TYPE as an argument
    methodExpr = exprFactory.createMethodExpression(elctx, "#{exbean.handleButtonPressed},Void.TYPE,new Class[] { ActionEvent.class });
    I M getting the same error.
    Edited by: chaya on Dec 22, 2011 2:47 PM

    yeah but i m creating button itself dynamically by java code....
    //code
    UIComponent button;
    button = findComponentInRoot("cb1");
    RichPanelGroupLayout pgl;
    pgl = (RichPanelGroupLayout)button.getParent();
    List<UIComponent> children;
    children = pgl.getChildren();
    RichPanelGroupLayout pgll;
    pgll = new RichPanelGroupLayout();
    RichInputText it;
    it = new RichInputText();
    it.setLabel("New textbox " + (children.size()));
    RichCommandButton but = new RichCommandButton();
    but.setPartialSubmit(true);
    but.setText("Delete");
    /*calling actionevent*/
    FacesContext fctx = FacesContext.getCurrentInstance();
    ELContext elctx = fctx.getELContext();
    Application application = fctx.getApplication();
    ExpressionFactory exprFactory = application.getExpressionFactory();
    MethodExpression methodExpr = null;
    methodExpr = exprFactory.createMethodExpression( elctx,"#{inbean.actionPerformed}",null, new Class[] {ActionEvent.class});
    MethodExpressionActionListener actionListener = null;
    actionListener = new MethodExpressionActionListener(methodExpr);
    but.addActionListener(actionListener);
    /*end of call*/
    children.add(pgll);
    children.add(it);
    children.add(but);
    AdfFacesContext.getCurrentInstance().addPartialTarget(pgl);
    //code to call method
    public void actionPerformed(ActionEvent event) {
    System.out.println("entered sec bean");
    return " ";}
    this way i m trying to create a button programatically and tryin to add actionlistener which is not working.
    the actionlistener is throwing error.... with the line
    methodExpr = exprFactory.createMethodExpression( elctx,"#{inbean.actionPerformed}",null, new Class[] {ActionEvent.class});

  • Problem with action listener

    hello
    the problem in my code is that i defined
    actionlistener for a button but it does not
    do what it should do . it throws an error in the console
    and i think my code is 100% correct what is the problem
    please help me this is the codewith
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    class Library extends JFrame implements ActionListener     {
         private JMenuBar jmb      = new JMenuBar();
         private JMenu books      = new JMenu("Books",true);
         private JMenu members      = new JMenu("Members",true);
         private JMenu loans      = new JMenu("Loans",true);
         private JMenuItem addNb = new JMenuItem("Add New Book");
         private JMenuItem listB = new JMenuItem("List All Books");
         private JMenuItem listAb = new JMenuItem("List Available Books");
         private JMenuItem listBb = new JMenuItem("List Borrowed Books");
         private JMenuItem addNm = new JMenuItem("Add New Member");
         private JMenuItem removeM = new JMenuItem("Remove a Member");
         private JMenuItem listAm = new JMenuItem("List All Members");
         private JMenuItem loanB = new JMenuItem("Loan A Book");
         private JMenuItem returnB = new JMenuItem("Return A Book");
         private JTextField bNumber = new JTextField(14);
         private JTextField bAuthor = new JTextField(14);
         private JTextField bTitle = new JTextField(14);
         private JTextField mId = new JTextField(14);
         private JTextField mName = new JTextField(14);
         private JTextField idB = new JTextField(14);
         private JTextField nBToB = new JTextField(14);
         private JTextField nBTor = new JTextField(14);
         private JTextArea dispaly = new JTextArea();
         private JButton oKb1 = new JButton("OK");
         private JButton okb2 = new JButton("OK");
         private JButton cloaseb = new JButton("Close");
         private JButton oKm1 = new JButton("OK");
         private JButton oKm2 = new JButton("OK");
         private JButton cancelM = new JButton("Cancel");
         private JButton oKm3 = new JButton("OK");
         private JButton oKm4 = new JButton("OK");
         private JButton cancelM2 = new JButton("Cancel");
         private JButton oKl = new JButton("OK");
         private JButton oKr = new JButton("OK");
         private JButton yes = new JButton("Yes");
         private JButton no = new JButton("No");     
         private JLabel bN = new JLabel("Book Number");
         private JLabel bA = new JLabel("Book Author");
         private JLabel bT = new JLabel("Book Title");
         private JLabel iN          = new JLabel("ID Number");
         private JLabel mN          = new JLabel("Member's Name");
         private JLabel     iNb          = new JLabel("ID number of the borrower");
         private JLabel nBb          = new JLabel("Number of the books to borrow");
         private JLabel nBr          = new JLabel("Number of the books to return");
         private JLabel mIdl     = new JLabel("ID number of the stuednt");
         private JPanel tempoIPanel= new JPanel(new FlowLayout());
         Container cp;
         JFrame mainFrame;
         JInternalFrame tempoI;
    Library()     {
         //LibraryClass lClass = new LibraryClass();/*
         mainFrame = new JFrame();
         mainFrame.setJMenuBar(jmb);
         mainFrame.setSize(800,550);
         mainFrame.getContentPane().setLayout(new FlowLayout());
         jmb.add(books);
         jmb.add(members);
         jmb.add(loans);
         books.add(addNb);
         addNb.addActionListener(this);
         books.add(listB);
         listB.addActionListener(this);
         books.add(listAb);
         listAb.addActionListener(this);
         books.add(listBb);
         listBb.addActionListener(this);
         members.add(addNm);
         addNm.addActionListener(this);
         members.add(removeM);
         removeM.addActionListener(this);
         members.add(listAm);
         listAm.addActionListener(this);
         loans.add(loanB);
         loanB.addActionListener(this);
         loans.add(returnB);
         returnB.addActionListener(this);
         //actions listeners
         oKb1.addActionListener(this);
         mainFrame.setVisible(true);
    public void actionPerformed(ActionEvent ae)     {
         if(ae.getSource() == addNb)     {
              tempoI = new JInternalFrame("Add new Book",true,true);
              mainFrame.getContentPane().add(tempoI);
              tempoI.getContentPane().setLayout(new FlowLayout());
              tempoI.getContentPane().add(bN);
              tempoI.getContentPane().add(bNumber);
              tempoI.getContentPane().add(bA);
              tempoI.getContentPane().add(bAuthor);
              tempoI.getContentPane().add(bT);
              tempoI.getContentPane().add(bTitle);
              tempoI.getContentPane().add(oKb1);//add action listener here
              tempoI.setVisible(true);
         if(ae.getSource() == listB)     {
              //LibraryClass.listBooks();
         if(ae.getSource() == listAb){}
         if(ae.getSource() == listBb){}
         if(ae.getSource() == addNm)     {
              tempoI = new JInternalFrame("Add new Member",true,true);
              mainFrame.getContentPane().add(tempoI);
              tempoI.getContentPane().setLayout(new FlowLayout());
              tempoI.getContentPane().add(iN);
              tempoI.getContentPane().add(mId);
              tempoI.getContentPane().add(mN);
              tempoI.getContentPane().add(mName);
              tempoI.getContentPane().add(oKm1);//add action listener
              tempoI.getContentPane().setSize(300,400);
              tempoI.setVisible(true);
         if(ae.getSource() == removeM)     {
              tempoI = new JInternalFrame("Rmove member",true,true);
              mainFrame.getContentPane().add(tempoI);
              tempoI.getContentPane().setLayout(new FlowLayout());
              tempoI.getContentPane().add(mIdl);
              tempoI.getContentPane().add(mId);
              tempoI.getContentPane().add(oKm2);//add action listener
              //LibraryClass.removeM(Double.parseDouble(mId.getText()));
              tempoI.getContentPane().setSize(300,400);
              tempoI.setVisible(true);
         if(ae.getSource() == listAm)     {
              //LibraryClass.listMembers();
         if(ae.getSource() == loanB)     {
              tempoI = new JInternalFrame("Loan book",true,true);
              mainFrame.getContentPane().add(tempoI);
              tempoI.getContentPane().setLayout(new FlowLayout());
              tempoI.getContentPane().add(iNb);
              tempoI.getContentPane().add(idB);
              tempoI.getContentPane().add(nBb);
              tempoI.getContentPane().add(nBToB);
              tempoI.getContentPane().add(oKl);
              //LibraryClass.borrowBook(Book bk,Member m);
              tempoI.getContentPane().setSize(300,400);
              tempoI.setVisible(true);
         if(ae.getSource() == returnB)     {
              tempoI = new JInternalFrame("Return Book",true,true);
              mainFrame.getContentPane().add(tempoI);
              tempoI.getContentPane().setLayout(new FlowLayout());
              tempoI.getContentPane().add(iNb);
              tempoI.getContentPane().add(idB);
              tempoI.getContentPane().add(nBr);
              tempoI.getContentPane().add(nBTor);
              tempoI.getContentPane().add(oKr);
              tempoI.getContentPane().setSize(400,300);
              tempoI.setVisible(true);
              //Book.addBook(bNumber.getText(),bAuthor.getText(),bTitle.getText());
    class ClubLibrarySystem     {
         public static void main(String[] args)     {
         new Library();
    }

    hello
    the problem in my code is that i defined
    actionlistener for a button but it does not
    do what it should do . it throws an error in the
    consoleWhat error?
    and i think my code is 100% correct what is theWell, but it isn't.
    Have you tried using a debugger?
    problem
    please help me this is the codewith
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    class Library extends JFrame implements
    ActionListener     {
         private JMenuBar jmb      = new JMenuBar();
         private JMenu books      = new JMenu("Books",true);
    private JMenu members      = new
    JMenu("Members",true);
    private JMenu loans      = new
    JMenu("Loans",true);
    private JMenuItem addNb = new JMenuItem("Add New
    Book");
    private JMenuItem listB = new JMenuItem("List All
    Books");
    private JMenuItem listAb = new JMenuItem("List
    Available Books");
    private JMenuItem listBb = new JMenuItem("List
    Borrowed Books");
    private JMenuItem addNm = new JMenuItem("Add New
    Member");
    private JMenuItem removeM = new JMenuItem("Remove a
    Member");
    private JMenuItem listAm = new JMenuItem("List All
    Members");
    private JMenuItem loanB = new JMenuItem("Loan A
    Book");
    private JMenuItem returnB = new JMenuItem("Return A
    Book");
         private JTextField bNumber = new JTextField(14);
         private JTextField bAuthor = new JTextField(14);
         private JTextField bTitle = new JTextField(14);
         private JTextField mId = new JTextField(14);
         private JTextField mName = new JTextField(14);
         private JTextField idB = new JTextField(14);
         private JTextField nBToB = new JTextField(14);
         private JTextField nBTor = new JTextField(14);
         private JTextArea dispaly = new JTextArea();
         private JButton oKb1 = new JButton("OK");
         private JButton okb2 = new JButton("OK");
         private JButton cloaseb = new JButton("Close");
         private JButton oKm1 = new JButton("OK");
         private JButton oKm2 = new JButton("OK");
         private JButton cancelM = new JButton("Cancel");
         private JButton oKm3 = new JButton("OK");
         private JButton oKm4 = new JButton("OK");
         private JButton cancelM2 = new JButton("Cancel");
         private JButton oKl = new JButton("OK");
         private JButton oKr = new JButton("OK");
         private JButton yes = new JButton("Yes");
         private JButton no = new JButton("No");     
    private JLabel bN = new JLabel("Book
    Number");
    private JLabel bA = new JLabel("Book
    Author");
    private JLabel bT = new JLabel("Book
    Title");
         private JLabel iN          = new JLabel("ID Number");
    private JLabel mN          = new JLabel("Member's
    Name");
    private JLabel     iNb          = new JLabel("ID number of the
    borrower");
    private JLabel nBb          = new JLabel("Number of the
    books to borrow");
    private JLabel nBr          = new JLabel("Number of the
    books to return");
    private JLabel mIdl     = new JLabel("ID number of
    the stuednt");
    private JPanel tempoIPanel= new JPanel(new
    FlowLayout());
         Container cp;
         JFrame mainFrame;
         JInternalFrame tempoI;
    Library()     {
         //LibraryClass lClass = new LibraryClass();/*
         mainFrame = new JFrame();
         mainFrame.setJMenuBar(jmb);
         mainFrame.setSize(800,550);
    mainFrame.getContentPane().setLayout(new
    FlowLayout());
         jmb.add(books);
         jmb.add(members);
         jmb.add(loans);
         books.add(addNb);
         addNb.addActionListener(this);
         books.add(listB);
         listB.addActionListener(this);
         books.add(listAb);
         listAb.addActionListener(this);
         books.add(listBb);
         listBb.addActionListener(this);
         members.add(addNm);
         addNm.addActionListener(this);
         members.add(removeM);
         removeM.addActionListener(this);
         members.add(listAm);
         listAm.addActionListener(this);
         loans.add(loanB);
         loanB.addActionListener(this);
         loans.add(returnB);
         returnB.addActionListener(this);
         //actions listeners
         oKb1.addActionListener(this);
         mainFrame.setVisible(true);
    public void actionPerformed(ActionEvent ae)     {
         if(ae.getSource() == addNb)     {
    tempoI = new JInternalFrame("Add new
    w Book",true,true);
              mainFrame.getContentPane().add(tempoI);
    tempoI.getContentPane().setLayout(new
    w FlowLayout());
              tempoI.getContentPane().add(bN);
              tempoI.getContentPane().add(bNumber);
              tempoI.getContentPane().add(bA);
              tempoI.getContentPane().add(bAuthor);
              tempoI.getContentPane().add(bT);
              tempoI.getContentPane().add(bTitle);
    tempoI.getContentPane().add(oKb1);//add action
    n listener here
              tempoI.setVisible(true);
         if(ae.getSource() == listB)     {
              //LibraryClass.listBooks();
         if(ae.getSource() == listAb){}
         if(ae.getSource() == listBb){}
         if(ae.getSource() == addNm)     {
    tempoI = new JInternalFrame("Add new
    w Member",true,true);
              mainFrame.getContentPane().add(tempoI);
    tempoI.getContentPane().setLayout(new
    w FlowLayout());
              tempoI.getContentPane().add(iN);
              tempoI.getContentPane().add(mId);
              tempoI.getContentPane().add(mN);
              tempoI.getContentPane().add(mName);
    tempoI.getContentPane().add(oKm1);//add action
    n listener
              tempoI.getContentPane().setSize(300,400);
              tempoI.setVisible(true);
         if(ae.getSource() == removeM)     {
    tempoI = new JInternalFrame("Rmove
    e member",true,true);
              mainFrame.getContentPane().add(tempoI);
    tempoI.getContentPane().setLayout(new
    w FlowLayout());
              tempoI.getContentPane().add(mIdl);
              tempoI.getContentPane().add(mId);
    tempoI.getContentPane().add(oKm2);//add action
    n listener
              //LibraryClass.removeM(Double.parseDouble(mId.getText
              tempoI.getContentPane().setSize(300,400);
              tempoI.setVisible(true);
         if(ae.getSource() == listAm)     {
              //LibraryClass.listMembers();
         if(ae.getSource() == loanB)     {
              tempoI = new JInternalFrame("Loan book",true,true);
              mainFrame.getContentPane().add(tempoI);
    tempoI.getContentPane().setLayout(new
    w FlowLayout());
              tempoI.getContentPane().add(iNb);
              tempoI.getContentPane().add(idB);
              tempoI.getContentPane().add(nBb);
              tempoI.getContentPane().add(nBToB);
              tempoI.getContentPane().add(oKl);
              //LibraryClass.borrowBook(Book bk,Member m);
              tempoI.getContentPane().setSize(300,400);
              tempoI.setVisible(true);
         if(ae.getSource() == returnB)     {
    tempoI = new JInternalFrame("Return
    n Book",true,true);
              mainFrame.getContentPane().add(tempoI);
    tempoI.getContentPane().setLayout(new
    w FlowLayout());
              tempoI.getContentPane().add(iNb);
              tempoI.getContentPane().add(idB);
              tempoI.getContentPane().add(nBr);
              tempoI.getContentPane().add(nBTor);
              tempoI.getContentPane().add(oKr);
              tempoI.getContentPane().setSize(400,300);
              tempoI.setVisible(true);
              //Book.addBook(bNumber.getText(),bAuthor.getText(),bT
    tle.getText());
    class ClubLibrarySystem     {
         public static void main(String[] args)     {
         new Library();

  • Calling Action listener in Custom component

    Hello,
    I am currently developing my own component containing an hyper-link and I am stuck with the Renderer. What should I put in the href of my "a" tag (<a href="???">) in order to call an Action listener ? I would like my renderer to do something similar to <h:commandLink actionListener="#{myBean.myActionListener}".
    Could you help me?
    Gerald.</a>

    Hello,
    Did you achieve this??? I'm also planing to put very similar to your thought. If you have a solution on your requirement, pls mail me to [email protected]
    Thanks in Advance.
    regards,
    Ram

  • Is there a way to have the same action listener for few buttons?

    guys, lets say i have button1, button2 and button3
    how do i add the same action listener for 3 of them. doing 3 different action listener is very tedius! my assignment have almots 100 buttons but I need their action listener to be the same.

    Hi,
    Your class needs an action listener, so add implements ActionListener to you class creation string.
    Then on each button set an action command;
    button1.setActionCommand(BUTTON1);Now add an listener;
    buttons1.addActionListener(this);Finally create a method to perform a task
    public void actionPerformed(ActionEvent e)
       if (e.getActionCommand().equals(BUTTON1))
           xxxx   
      }This should do the trick.
    adelebt

  • Action Listener Method called multiple times

    I have a page (fragment .jsff), containing a simple input text and a button called "search". When I click on "Search" the action listener is triggered multiple times. (The results are displayed in a table inside a panel collection).
    The results are actually coming back ok.
    When I debug the code, I can see the action listener method called twice.
    Do you know why is that?
    What should I be taking care of?
    This is my code :
    *** Fragment ****
    <af:commandButton text="#{identityBundle.search_label}" id="cb1"
    actionListener="#{UserDetailsBean.searchUsersListener}"
    disabled="#{!bindings.searchUsers.enabled}"/>
    *** Managed bean ***
    public void searchUsersListener(ActionEvent actionEvent) {
    // Add event code here...
    DCBindingContainer bindings = (DCBindingContainer)getBindings();
    DCIteratorBinding iter = bindings.findIteratorBinding("userIterator");
    DCDataRow row = (DCDataRow)iter.getCurrentRow();
    User user = (User)row.getDataProvider();
    boolean isSearchCriteriaPresent = false;
    if(user != null){
    String fn = user.getFirstname();
    if(fn != null && !fn.trim().equals("")){
    isSearchCriteriaPresent = true;
    user.setLastname(fn);
    user.setNonMTUserLogin(fn);
    try {
    Map <Object, Object> userMap = PropertyUtils.describe(user);
    for(Map.Entry<Object, Object> entry: userMap.entrySet()){
    if(entry.getKey() != null && entry.getValue() != null && !entry.getKey().toString().equalsIgnoreCase("class")){
    isSearchCriteriaPresent = true;
    break;
    } catch (IllegalAccessException e) {
    e.printStackTrace();
    } catch (InvocationTargetException e) {
    e.printStackTrace();
    } catch (NoSuchMethodException e) {
    e.printStackTrace();
    if(!isSearchCriteriaPresent){
    user.setFirstname("*");
    OperationBinding opBinding = (OperationBinding)bindings.getOperationBinding("searchUsers");
    opBinding.getParamsMap().put("user", user);
    opBinding.execute();
    AdfFacesContext adfFacesCtx = AdfFacesContext.getCurrentInstance();
    Map<String, Object> scopePageFlowScopeVar= adfFacesCtx.getPageFlowScope();
    scopePageFlowScopeVar.put("userSearchCriteria", user);
    ADFContext adfCtx = ADFContext.getCurrent();
    Map sessionScope = adfCtx.getSessionScope();
    sessionScope.put("userSearchCriteria", user);
    setUserSearchCriteria(user);
    if(selectedUserID != null){
    selectedUserID.setValue(null);
    RichTable table = getUserResultsTable();
    DCIteratorBinding searchUsersIterator = (DCIteratorBinding)bindings.get("searchUsersIterator");
    Row[] rows = searchUsersIterator.getAllRowsInRange();
    if(rows.length > 0){
    RowKeySetImpl rks = new RowKeySetImpl();
    ArrayList keyList = new ArrayList();
    keyList.add(rows[0].getKey());
    rks.add(keyList);
    table.setSelectedRowKeys(rks);
    table.setDisplayRowKey(keyList);
    refreshState(table);
    if(!isSearchCriteriaPresent){
    user.setFirstname(null);
    else{
    deleteUserButton.setDisabled(true);
    resetPasswordButton.setDisabled(true);
    enableUserButton.setDisabled(true);
    disableUserButton.setDisabled(true);
    Thanks in advance for your help

    Hi,
    Can you try this?
    1. set partialSubmit=true for the "search" button
    2. set "search" button id as partialTrigger in your result table
    -Prasad

  • How to create a single action listener for a group of buttons

    hi there.. i am new at java and i have a problem with my applet..
    i am doing a virtual ticket programme..
    i have a tab that says books seats.. in the tab, i am suppose to create 50 buttons.
    i have done that already by using for (int i=1; i<=10;i++) 5 times for 50 buttons.
    but i do not know how to set an actionlistener in the for loop for each of these buttons..
    For example, if the user were to chose seat "no3" , a text area(already created) below will show something like "no3" and so on..
    how do i bind these buttons into one single action listener so i do not have to create 50 actionlisteners and buttons individually..
    appreciate the help..

    You're killing me.
    class MyFrame extends JFrame implements ActionListener
         JTextArea myTextArea = new JTextArea();
         JButton myButton = new JButton("My Button");
         JButton otherButton = new JButton("Other Button");
         MyFrame()
              super();
              myButton.addActionListener(this);
              otherButton.addActionListener(this);
              setLayout(new FlowLayout());
              add(myButton);
              add(otherButton);
              add(myTextArea);
         public void actionPerformed(ActionEvent e)
              Object source = e.getSource();
              if(source == myButton)
                   myTextArea.append("My Button Pressed\n");
              else if(source == otherButton)
                   myTextArea.append("Other Button Pressed\n");
    }

  • Best way to implement an Action Listener

    I have multiple anonymous classes for each button in my particular JPanel, this seems very... large and I am sure it is using a large amount of memory. Is there a better way to implement several action listeners to all these buttons so that they will still do their origional function but cut down on all the anonymous classes.

    Actually nothing of the sort. There is too much information to be able to be placed nicely on the Panel, so I have many buttons that open dialog boxes where the information is placed, buttons that perform specified tasks (adding, updating, loading, deleting, clearing all fields) on the database, and others, there is also action listeners on the jspinners comboboxes and others.
    Actually, I take back hundred, I recently extended JPanel to do my editing panels to go into my JTabbedPane cutting down on the line count in the FrameMain class (over 8K lines before the conversion) So there is only about 20 to 25 total action listeners per extended JPanel, instead of 150 or so declared in one frame.
    The biggest concern here is memory usage, as of right now it uses a ton, and by searching and reading, I belive its all the action listeners (which at the time I thought you had to have a brand new one every time you wanted it to do something different).
    Going back to the one action listener with the if/else statements obviously performace may be lost, but what is the ratio to performance lost to memory gain. Will the speed increase be negligable compared to the amount of memory usage that will go down?

  • Custom button with action listener - will not invoke action listener

    Hi
    For whatever reason, I cannot find a concise example of a simple custom component that can invoke an action listener. The tutorials I've read so far either ignore this fundamental topic or only make the slightest make reference to it.
    The best I have come up with - in terms of a simple prototype is below... but, the action listener is never invoked.... Can someone tell me what I am missing (full code below). Hopefully, what is missing or incorrect will be obvious to you JSF experts out there.
    Thanks for any help!!
    -f
    tld
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
    <taglib>
      <tlib-version>0.01</tlib-version>
      <jsp-version>1.2</jsp-version>
      <short-name>jsfcustomcomponent</short-name>
      <uri>http://jsfcustomcomponent/</uri>
      <description><![CDATA[jsf custom component tags]]>  </description>
      <tag>
        <name>specialBtnTag</name>
        <tag-class>jsfcustomcomponent.SpecialBtnTag</tag-class>
        <attribute>
          <name>value</name>
          <required>true</required>
          <rtexprvalue>true</rtexprvalue>
          <description><![CDATA[button value]]></description>
        </attribute>
        <attribute>
          <name>actionListener</name>
          <required>true</required>
          <rtexprvalue>true</rtexprvalue>
          <description><![CDATA[action listener]]> </description>
        </attribute>
      </tag>
    </taglib>
    SpecialBtnComponent
    package jsfcustomcomponent;
    import javax.faces.component.*;
    import javax.faces.context.*;
    import javax.faces.el.*;
    import javax.faces.event.*;
    public class SpecialBtnComponent
        extends UIComponentBase implements ActionSource
        public static final String COMPONENT_TYPE = "SpecialBtnComponent";
        public static final String RENDERER_TYPE = "SpecialBtnRenderer";
        public String getFamily()
            return COMPONENT_TYPE;
        public SpecialBtnComponent()
            super();
            setRendererType(SpecialBtnComponent.RENDERER_TYPE);
        private String value;
        public void setValue(String value, FacesContext facesContext)
            this.value = value;
        public String getValue()
            if (null != value)
                return value;
            ValueBinding _vb = getValueBinding("value");
            if (_vb != null)
                return (String) _vb.getValue(getFacesContext());
            else
                return null;
        private MethodBinding action = null;
        public MethodBinding getAction()
            return action;
        public void setAction(MethodBinding methodBinding)
            this.action = action;
        private MethodBinding actionListener = null;
        public MethodBinding getActionListener()
            return (this.actionListener);
        public void setActionListener(MethodBinding methodBinding)
            this.actionListener = actionListener;
        public boolean isImmediate()
            return false;
        public void setImmediate(boolean _boolean)
            //this.immediate = immediate;
        public void addActionListener(ActionListener actionListener)
            addFacesListener(actionListener);
        public ActionListener[] getActionListeners()
            return (ActionListener[]) getFacesListeners(ActionListener.class);
        public void removeActionListener(ActionListener actionListener)
            removeFacesListener(actionListener);
        public Object saveState(FacesContext context)
            Object values[] = new Object[5];
            values[0] = super.saveState(context);
            values[1] = value;
            values[2] = saveAttachedState(context, action);
            values[3] = saveAttachedState(context, actionListener);
            return ( (Object) (values));
        public void restoreState(FacesContext context, Object state)
            Object values[] = (Object[]) state;
            super.restoreState(context, values[0]);
            value = (String) values[1];
            action = (MethodBinding) restoreAttachedState(context, values[2]);
            actionListener = (MethodBinding) restoreAttachedState(context, values[3]);
        public void broadcast(FacesEvent event) throws AbortProcessingException
            super.broadcast(event);
            if (event instanceof ActionEvent)
                FacesContext context = getFacesContext();
                MethodBinding mb = getActionListener();
                if (mb != null)
                    mb.invoke(context, new Object[]
                              {event});
                ActionListener listener = context.getApplication().getActionListener();
                if (listener != null)
                    listener.processAction( (ActionEvent) event);
        public void queueEvent(FacesEvent e)
            if (e instanceof ActionEvent)
                if (isImmediate())
                    e.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
                else
                    e.setPhaseId(PhaseId.INVOKE_APPLICATION);
            super.queueEvent(e);
    SpecialBtnRenderer
    package jsfcustomcomponent;
    import java.util.*;
    import javax.faces.component.*;
    import javax.faces.context.*;
    import javax.faces.event.*;
    import javax.faces.render.*;
    public class SpecialBtnRenderer
        extends Renderer
        String value;
        public SpecialBtnRenderer()
        public void decode(FacesContext context, UIComponent component)
            Map requestMap = context.getExternalContext().getRequestParameterMap();
            String clientId = component.getClientId(context);
            SpecialBtnComponent specialBtnComponent = (SpecialBtnComponent) component;
            String value = (String) requestMap.get(clientId);
            if (null != value)
                specialBtnComponent.setValue(value, context);
            ActionEvent actionEvent = new ActionEvent(specialBtnComponent);
            specialBtnComponent.queueEvent(actionEvent);
        public void encodeEnd(FacesContext context, UIComponent component) throws java.io.IOException
            SpecialBtnComponent specialBtnComponent = (SpecialBtnComponent) component;
            ResponseWriter writer = context.getResponseWriter();
            String clientId = component.getClientId(context);
            value = (String) component.getAttributes().get("value");
            if (value == null)
                value = "defaultValue";
            buildSpecialBtn(writer, value, clientId, specialBtnComponent);
        private void buildSpecialBtn(ResponseWriter writer, String value, String clientId, SpecialBtnComponent component) throws java.io.IOException
            writer.startElement("table", component);
            writer.startElement("tbody", component);
            writer.startElement("tr", component);
            writer.startElement("td", component);
            value = String.valueOf(value);
            writer.startElement("input", component);
            writer.writeAttribute("type", "submit", null);
            writer.writeAttribute("name", clientId, "clientId");
            writer.writeAttribute("value", value, null);
            writer.endElement("input");
            writer.endElement("td");
            writer.endElement("tr");
            writer.endElement("tbody");
            writer.endElement("table");
    SpecialBtnTag
    package jsfcustomcomponent;
    import javax.faces.component.*;
    import javax.faces.el.*;
    import javax.faces.webapp.*;
    import com.sun.faces.util.*;
    public class SpecialBtnTag
        extends UIComponentTag
        public String value = null;
        public String actionListener = null;
        public String getComponentType()
            return SpecialBtnComponent.COMPONENT_TYPE;
        public String getRendererType()
            return SpecialBtnComponent.RENDERER_TYPE;
        protected void setProperties(UIComponent component)
            super.setProperties(component);
            if (! (component instanceof SpecialBtnComponent))
                throw new IllegalStateException("Component " + component.toString() +
                                                " not expected type.  Expected: jsfcustomcomponent.SpecialBtnComponent.  Perhaps you�re missing a tag?");
            SpecialBtnComponent specialBtnComponent = (SpecialBtnComponent) component;
            if (value != null)
                if (isValueReference(value))
                    ValueBinding vb = Util.getValueBinding(value);
                    specialBtnComponent.setValueBinding("value", vb);
                else
                    throw new IllegalStateException("The value for �value� must be a ValueBinding.");
            if (actionListener != null)
                if (isValueReference(actionListener))
                    ValueBinding vb = Util.getValueBinding(actionListener);
                    specialBtnComponent.setValueBinding("actionListener", vb);
                else
                    throw new IllegalStateException("The value for �actionListener� must be a ValueBinding.");
        public void release()
            super.release();
            value = null;
            actionListener = null;
        public void setValue(String value)
            this.value = value;
        public String getValue()
            return this.value;
        public void setActionListener(String actionListener)
            this.actionListener = actionListener;
        public String getActionListener()
            return this.actionListener;
    jsp1.jsp
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@taglib uri="http://jsfcustomcomponent/" prefix="j"%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
    <link rel="stylesheet" type="text/css" href="./stylesheet.css" title="Style">
    </head>
    <body>
    <f:view>
      <h:form id="form01">
        <h:outputText value="test special button with action listener"/>
        <j:specialBtnTag value="#{specialBtnBacking.specialBtnValue}" actionListener="#{specialBtnBacking.specialBtnActionListener}"/>
        <h:messages/>
        <h:outputText value="#{specialBtnBacking.outcome}"/>
      </h:form>
    </f:view>
    </body>
    </html>
    SpecialBtnBacking
    package specialbtn;
    import javax.faces.context.*;
    import javax.faces.event.*;
    public class SpecialBtnBacking
        private FacesContext context;
        public SpecialBtnBacking()
            this.setSpecialBtnValue("Special Button with action listener");
        private String specialBtnValue;
        public String getSpecialBtnValue()
            return this.specialBtnValue;
        public void setSpecialBtnValue(String specialBtnValue)
            this.specialBtnValue = specialBtnValue;
        private String outcome="actionlistener NOT invoked: click specialBtn above to test";
        public String getOutcome()
            return outcome;
        public void setOutcome(String outcome)
            this.outcome = outcome;
        public void specialBtnActionListener(ActionEvent evt)
            System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Jsp1Backing/specialBtnActionListener()!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
            this.outcome="***action listener invoked!!!***";
    faces-config.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
    <faces-config>
      <managed-bean>
        <managed-bean-name>specialBtnBacking</managed-bean-name>
        <managed-bean-class>specialbtn.SpecialBtnBacking</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
      </managed-bean>
      <component>
        <component-type>SpecialBtnComponent</component-type>
        <component-class>jsfcustomcomponent.SpecialBtnComponent</component-class>
        <component-extension>
          <renderer-type>SpecialBtnRenderer</renderer-type>
        </component-extension>
      </component>
      <render-kit>
        <renderer>
          <component-family>SpecialBtnComponent</component-family>
          <renderer-type>SpecialBtnRenderer</renderer-type>
          <renderer-class>jsfcustomcomponent.SpecialBtnRenderer</renderer-class>
        </renderer>
      </render-kit>
    </faces-config>
    web.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
      <display-name>pagerWEB</display-name>
      <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
      </servlet>
      <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.faces</url-pattern>
      </servlet-mapping>
      <jsp-config>
        <taglib>
          <taglib-uri>http://jsfcustomcomponent/</taglib-uri>
          <taglib-location>/WEB-INF/jsfcustomcomponent.tld</taglib-location>
        </taglib>
      </jsp-config>
      <servlet>
        <description>Added by JBuilder to compile JSPs with debug info</description>
        <servlet-name>debugjsp</servlet-name>
        <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
        <init-param>
          <param-name>classdebuginfo</param-name>
          <param-value>true</param-value>
        </init-param>
        <load-on-startup>3</load-on-startup>
      </servlet>
      <servlet-mapping>
        <servlet-name>debugjsp</servlet-name>
        <url-pattern>*.jsp</url-pattern>
      </servlet-mapping>
    </web-app>

    got it working....
    The changes were:
    in "SpecialBtnRenderer"...
    --new--
                        mb.invoke(context, new Object[1]);
    --old--
                        mb.invoke(context, new Object[0]);
    in "SpecialBtnTag"...
    --new--
    import javax.faces.event.ActionEvent;
    --new--
                    MethodBinding mb = FacesContext.getCurrentInstance().getApplication().createMethodBinding(specialBtnListener, new Class[]{ActionEvent.class});
    --old--
                    MethodBinding mb = FacesContext.getCurrentInstance().getApplication().createMethodBinding(specialBtnListener, null);
    -Below is the entire application, again -- for those (like myself) who need concrete examples...
    I hope this helps someone else! --f
    jsp1.jsp
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@taglib uri="http://jsfcustomcomponent/" prefix="j"%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
    <link rel="stylesheet" type="text/css" href="./stylesheet.css" title="Style">
    </head>
    <body>
    <f:view>
        <h:messages/>
      <h:form id="form01">
        <h:outputText value="test special button with action listener"/>
        <j:specialBtnTag value="#{specialBtnBacking.specialBtnValue}" specialBtnListener="#{specialBtnBacking.specialBtnActionListener}"/>
        <h:outputText value="#{specialBtnBacking.outcome}"/>
      </h:form>
    </f:view>
    </body>
    </html>
    SpecialBtnBacking
    package specialbtn;
    import javax.faces.context.*;
    import javax.faces.event.*;
    public class SpecialBtnBacking
        private FacesContext context;
        public SpecialBtnBacking()
            this.setSpecialBtnValue("Special Button with action listener");
        private String specialBtnValue;
        public String getSpecialBtnValue()
            return this.specialBtnValue;
        public void setSpecialBtnValue(String specialBtnValue)
            this.specialBtnValue = specialBtnValue;
        private String outcome = "actionlistener NOT invoked: click specialBtn above to test";
        public String getOutcome()
            return outcome;
        public void setOutcome(String outcome)
            this.outcome = outcome;
        public void specialBtnActionListener(ActionEvent evt)
            System.out.println("\n\n");
            System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Jsp1Backing/specialBtnActionListener()!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
            System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Jsp1Backing/specialBtnActionListener()!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
            System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Jsp1Backing/specialBtnActionListener()!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
            System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Jsp1Backing/specialBtnActionListener()!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
            System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Jsp1Backing/specialBtnActionListener()!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n");
            this.outcome = "***action listener invoked!!!***";
    jsfcustomcomponent.tld
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
    <taglib>
      <tlib-version>0.01</tlib-version>
      <jsp-version>1.2</jsp-version>
      <short-name>jsfcustomcomponent</short-name>
      <uri>http://jsfcustomcomponent/</uri>
      <description><![CDATA[jsf custom component tags]]>  </description>
      <tag>
        <name>specialBtnTag</name>
        <tag-class>jsfcustomcomponent.SpecialBtnTag</tag-class>
        <attribute>
          <name>value</name>
          <required>true</required>
          <rtexprvalue>true</rtexprvalue>
          <description><![CDATA[button value]]></description>
        </attribute>
        <attribute>
          <name>specialBtnListener</name>
          <required>true</required>
          <rtexprvalue>true</rtexprvalue>
          <description><![CDATA[action listener]]> </description>
        </attribute>
      </tag>
    </taglib>
    faces-config.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
    <faces-config>
      <managed-bean>
        <managed-bean-name>specialBtnBacking</managed-bean-name>
        <managed-bean-class>specialbtn.SpecialBtnBacking</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
      </managed-bean>
      <component>
        <component-type>SpecialBtnComponent</component-type>
        <component-class>jsfcustomcomponent.SpecialBtnComponent</component-class>
        <component-extension>
          <renderer-type>SpecialBtnRenderer</renderer-type>
        </component-extension>
      </component>
      <render-kit>
        <renderer>
          <component-family>SpecialBtnComponent</component-family>
          <renderer-type>SpecialBtnRenderer</renderer-type>
          <renderer-class>jsfcustomcomponent.SpecialBtnRenderer</renderer-class>
        </renderer>
      </render-kit>
    </faces-config>
    SpecialBtnComponent.java
    package jsfcustomcomponent;
    import javax.faces.component.*;
    import javax.faces.context.*;
    import javax.faces.el.*;
    import javax.faces.event.*;
    public class SpecialBtnComponent
        extends UIComponentBase implements ActionSource
        public static final String COMPONENT_TYPE = "SpecialBtnComponent";
        public static final String RENDERER_TYPE = "SpecialBtnRenderer";
        public String getFamily()
            return COMPONENT_TYPE;
        public SpecialBtnComponent()
            super();
            setRendererType(SpecialBtnComponent.RENDERER_TYPE);
        private String value;
        public void setValue(String value, FacesContext facesContext)
            this.value = value;
        public String getValue()
            if (null != this.value)
                return this.value;
            ValueBinding _vb = getValueBinding("value");
            if (_vb != null)
                return (String) _vb.getValue(getFacesContext());
            else
                return null;
        private MethodBinding specialBtnListener = null;
        public MethodBinding getActionListener()
            return (this.specialBtnListener);
        public void setActionListener(MethodBinding actionListener)
            this.specialBtnListener = actionListener;
        public Object saveState(FacesContext context)
            Object values[] = new Object[3];
            values[0] = super.saveState(context);
            values[1] = saveAttachedState(context, this.specialBtnListener);
            values[2] = this.value;
            return (values);
        public void restoreState(FacesContext context, Object state)
            Object values[] = (Object[]) state;
            super.restoreState(context, values[0]);
            this.specialBtnListener = (MethodBinding) restoreAttachedState(context, values[1]);
            this.value = (String) restoreAttachedState(context, values[2]);
        public void broadcast(FacesEvent event) throws AbortProcessingException
            super.broadcast(event);
            if (event instanceof ActionEvent)
                FacesContext context = getFacesContext();
                MethodBinding mb = this.getActionListener();
                if (mb != null)
                    try
                        mb.invoke(context, new Object[]
                                  {event});
                    catch (EvaluationException ex)
                        System.out.println("SpecialBtnComponent/broadcast(FacesEvent event)...EvaluationException encountered - ex.getMessage()=" + ex.getMessage());
                        ex.printStackTrace();
                ActionListener actionListener = context.getApplication().getActionListener();
                if (actionListener != null)
                    actionListener.processAction( (ActionEvent) event);
        public void queueEvent(FacesEvent e)
            if (e instanceof ActionEvent)
                e.setPhaseId(PhaseId.INVOKE_APPLICATION);
            super.queueEvent(e);
        public MethodBinding getAction()
            return null;
        public void setAction(MethodBinding methodBinding)
        public boolean isImmediate()
            return false;
        public void setImmediate(boolean _boolean)
        public void addActionListener(ActionListener actionListener)
            addFacesListener(actionListener);
        public ActionListener[] getActionListeners()
            return (ActionListener[]) getFacesListeners(ActionListener.class);
        public void removeActionListener(ActionListener actionListener)
            removeFacesListener(actionListener);
    SpecialBtnTag.java
    package jsfcustomcomponent;
    import javax.faces.component.*;
    import javax.faces.el.*;
    import javax.faces.webapp.*;
    import com.sun.faces.util.*;
    import javax.faces.context.FacesContext;
    import javax.faces.event.ActionEvent;
    public class SpecialBtnTag
        extends UIComponentTag
        public String value = null;
        public String specialBtnListener = null;
        private SpecialBtnComponent specialBtnComponent;
        public SpecialBtnTag()
            super();
        public String getComponentType()
            return SpecialBtnComponent.COMPONENT_TYPE;
        public String getRendererType()
            return SpecialBtnComponent.RENDERER_TYPE;
        protected void setProperties(UIComponent component)
            super.setProperties(component);
            if (! (component instanceof SpecialBtnComponent))
                throw new IllegalStateException("Component " + component.toString() +
                                                " not expected type.  Expected: jsfcustomcomponent.SpecialBtnComponent.  Perhaps you�re missing a tag?");
            specialBtnComponent = (SpecialBtnComponent) component;
            if (value != null)
                if (isValueReference(value))
                    ValueBinding vb = Util.getValueBinding(value);
                    specialBtnComponent.setValueBinding("value", vb);
                else
                    throw new IllegalStateException("The value for �value� must be a ValueBinding.");
            if (specialBtnListener != null)
                if (isValueReference(specialBtnListener))
                    MethodBinding mb = FacesContext.getCurrentInstance().getApplication().createMethodBinding(specialBtnListener, new Class[]{ActionEvent.class});
                    ( (SpecialBtnComponent) component).setActionListener(mb);
                else
                    MethodBinding mb = Util.createConstantMethodBinding(specialBtnListener);
                    ( (SpecialBtnComponent) component).setActionListener(mb);
        public void release()
            super.release();
            value = null;
            specialBtnListener = null;
        public void setValue(String value)
            this.value = value;
        public String getValue()
            return this.value;
        public void setSpecialBtnListener(String specialBtnListener)
            this.specialBtnListener = specialBtnListener;
        public String getSpecialBtnListener()
            return this.specialBtnListener;
    SpecialBtnRenderer
    package jsfcustomcomponent;
    import java.util.*;
    import javax.faces.component.*;
    import javax.faces.context.*;
    import javax.faces.event.*;
    import javax.faces.render.*;
    import javax.faces.el.MethodBinding;
    import javax.faces.el.*;
    public class SpecialBtnRenderer
        extends Renderer
        String value;
        public SpecialBtnRenderer()
            super();
        public void decode(FacesContext context, UIComponent component)
            try
                Map requestMap = context.getExternalContext().getRequestParameterMap();
                String clientId = component.getClientId(context);
                SpecialBtnComponent specialBtnComponent = (SpecialBtnComponent) component;
                String value = (String) requestMap.get(clientId);
                if (null != value)
                    specialBtnComponent.setValue(value, context);
                    MethodBinding mb = specialBtnComponent.getActionListener();
                    if (mb != null)
                        System.out.println("SpecialBtnRenderer/decode...mb.getExpressionString()=" + mb.getExpressionString());
                        //mb.invoke(context, new Object[0]);
                        mb.invoke(context, new Object[1]);
                    ActionEvent actionEvent = new ActionEvent(specialBtnComponent);
                    specialBtnComponent.queueEvent(actionEvent);
            catch (EvaluationException ex)
                ex.printStackTrace();
        public void encodeEnd(FacesContext context, UIComponent component) throws java.io.IOException
            SpecialBtnComponent specialBtnComponent = (SpecialBtnComponent) component;
            ResponseWriter writer = context.getResponseWriter();
            String clientId = component.getClientId(context);
            value = (String) component.getAttributes().get("value");
            if (value == null)
                value = "defaultValue";
            buildSpecialBtn(writer, value, clientId, specialBtnComponent);
        private void buildSpecialBtn(ResponseWriter writer, String value, String clientId, SpecialBtnComponent component) throws java.io.IOException
            writer.startElement("table", component);
            writer.startElement("tbody", component);
            writer.startElement("tr", component);
            writer.startElement("td", component);
            value = String.valueOf(value);
            writer.startElement("input", component);
            writer.writeAttribute("type", "submit", null);
            writer.writeAttribute("name", clientId, "clientId");
            writer.writeAttribute("value", value, null);
            writer.endElement("input");
            writer.endElement("td");
            writer.endElement("tr");
            writer.endElement("tbody");
            writer.endElement("table");
    web.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
      <display-name>pagerWEB</display-name>
      <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
      </servlet>
      <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.faces</url-pattern>
      </servlet-mapping>
      <jsp-config>
        <taglib>
          <taglib-uri>http://jsfcustomcomponent/</taglib-uri>
          <taglib-location>/WEB-INF/jsfcustomcomponent.tld</taglib-location>
        </taglib>
      </jsp-config>
    </web-app>

Maybe you are looking for

  • Etrecheck report - please advise

    Can you please let me know how to fix the items in red? thanks! EtreCheck version: 2.1.8 (121) Report generated 9 April 2015 9:45:34 pm GMT+2 Download EtreCheck from http://etresoft.com/etrecheck Click the [Click for support] links for help with non-

  • Why can't I see any of my synced apps on 5s?

    I've updated all apps, updated iTunes, arranged everything as I want, and synced my 5s.  I cannot see any of my downloaded apps. I download a new app...I can watch it download onto my screen, and them it disappears.  My Settings say the apps are ON t

  • Can I make a form that could be emailed filled out and returned

    I'd like to create a form that I can email my students and that they could fill out and return. Is there a site or video that could help me learn this? Perhaps create a template?

  • Uploading Photos from database.

    I want to upload employees photos saveed in database as blob. Now I want see them in my reports and forms. I want to see the photos in attendance form. I mean when some body gives its id. Its photo should be fetched and displayed on the screen. How t

  • New Adobe update does not accept Sony NEX .MTS file format - help?!

    I've seen some 'solutions' to this problem but none apply to me. I do not have older versions of Premiere to work with these files and then import into the new Adobe CC 2014. I also tried renaming the file folder with the video files but that does no