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});

Similar Messages

  • 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

  • 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 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

  • 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");
    }

  • Is sql functions or trigger possible for adf button component

    while developing project using ADF BC and JSF, is possible to invoke sql functions or trigger for an adf button component. plz reply

    For this you define a method in the application module which you expose to the client. Then you can drag this method onto the button. The method is call when you click the button.
    Inside the method you can call pl/sql functions. Read chapter "37.5 Invoking Stored Procedures and Functions" here http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/bcadvgen.htm#sm0297
    Timo

  • 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.

  • Listener for cancel button of dialog

    Hi
         What shud i add as listener for the dialog , so that when i press cancel button the listener shud get executed?. Alos is there any listener to know if the user has pressed the close(x) mark of the dialog and closed the dialog. Any help wud be appreciable
    Thanks
    Veena

    try beforesubmit handler
    Ref:
    http://dev.day.com/docs/en/cq/current/widgets-api/index.html?class=CQ.Dialog

  • Dynamic-actions/expressions for Radio button in VC

    Hi,
    I would like to know whether dynamic actions for radio-buttons are possible in VC??
    I have a situation where, i have to display/hide an input-field according to the radio-button that i select.
    Is this possible in VC??
    Because, i do not find any place where i can write expressions for a radio-button so that it can take actions accordingly.

    Actually its possible.
    Here is the sample code for this.
    tables : kna1.
    parameters : chk1 radiobutton group g1 user-command abc,
                 chk2 radiobutton group g1.
    parameters : chk3 type kunnr.
    at selection-screen output.
    loop at screen.
      if chk1 = 'x' and screen-name = chk3.
          chk3-active = '0'.
      endif.
    endloop.
    In this way you can hide a input-field on the screen.

  • Action listener for struts html tag

    hi i am doing a project using sturts. I have used struts HTML Select tag with a collection of values in select box. now i want to write an actionlistner for that select...ie if i select any value from the select list it should do some action like take me to different page...can anyone tell me how can i do that...
    Thanks

    Soultech, I think you're being a bit harsh. Struts is a valid topic on this forum as it is a java framework related to JSP.
    However having said that, the question does show a basic misunderstanding of JSP technology.
    JSP = Java SERVER Pages. Java code only runs on the server.
    All that gets sent to the client (browser) is an HTML file.
    You can not write java action listeners to run and respond to events on the client.
    For any client side interaction you will have to use javascript (which is NOT java) - probably an onclick/onchange event - the same as any other web page.
    However you can only run javascript code from such events.
    To run java again you have to submit a request to a server - normally done by submitting a form.

  • How to get the command button component id  in bean class?

    Hi All,
    I'm using adf 11g.
    I'm having three command button , which have some similar code to use on fire of these buttons.
    if it possible to catch the component id in bean , i can use the code with little parameter passing .

    Hi,
    You can get the command button from the actionEvent (if you are writing a generic actionListener) and from it, you can get the Text of the command button. Using which, you can process accordingly.
    If the text also same, then set some client attribute for the command button (check out [url http://docs.oracle.com/cd/E21764_01/apirefs.1111/e12419/tagdoc/af_clientAttribute.html]af:clientAttribute), and from the actionListener, get the client attribute using getClientAttribute method and process accordingly.
    -Arun

  • How do I get the Manged bean and Taskflow logic for Disable button in User details Modify page

    Hi,
    I have a requirement where I have to add to custom buttons like "Terminate" and "Reinstate" in the users detail page. Terminate is closely modeled with "Disable" button of user details page. Before I develop the custom beans and register the task flow for the custom button, I just want to understand the logic written in the managed bean for "Disable" button and understand what is there in its associated task flow. Am trying to get these details from OIM. Not sure where exactly I can get the code for this and customize as per my requirement.
    Please suggest the exact location?
    Raghu

    Thanks for the information - I still was hoping that the article Mario mentioned above was accessible (perhaps just moved)?  Somewhere on the BC system?  Just so I can add it to my BC help folder - as well as even share it with clients who want to try things on their own (best to give them some help in that direction so they don't fumble through things).
    I have the checkout form populating information, if they have purchased in the past it will populate their address - but I am also trying to get their "account page" to do the same  (basically show them what their current information in the system is - then allow them to update whatever might be wrong or need changes).  We have a login page, for people to sign up without having "bought" something - so the CRM won't have their billing/shipping info in the system yet.  Trying to capture that without a purchasing being made.

  • Best approach for building dialogs based on Java Beans

    I have a large amount of Java Beans with several properties each. These represent all the "data" in our system. We will now build a new GUI for the system and I intend to reuse the beans as far as possible. My idea is to automatically generate the configuration dialogs for each bean using the java.beans package.
    What is the best approach for achieving this? Should I use PropertyEditors or should I make my own dialog-generator using the Introspetor class or are there any other suitable solutions?
    All suggestions and tips are very welcome.
    Thanks!
    Erik

    Definitely, it is better for you to use JTable. Why not try it?

  • How to listen for actionContent button click event in View

    Hello,
    Doing this:
    FlexGlobals.topLevelApplication.addEventListener('actionContentClick',showOptions);
    Results in calling showOptions() as many times as the view was showed. The handler sticks and each time I enter a view in the creationComplete hander for it I add the same listener over and over again.
    How should this be done?
    1. FlexGlobals.topLevelApplication is the right object to listen to?
    2. I can remove the listener on view deactivate, but I am not sure if that will be called each time the view goes away.
    3. Can I check if an object already has a listener and which is it?
    Thank you.

    Thank you, Tom.
    I was complicating things for myself by exposing methods in the main MXML file to add and remove and listen to click events on a button placed in the actionContent, instead of declaring it in MXML for each and adding a listener to it. Views had different actionContent buttons or rather icons for them.
    In regards to hasEvenListener, can I also get the method(s) attached to that? Probably not though.

  • How to Call action Listener from Mouse Listener event

    One class (class 1)implements mouse listener and responds to a mouse events.
    As part of that response it needs to call a variable set method in another class (class 2)and also have that setMethod call it's own ActionPerformed.
    Seems the problem is I don't have aaction event to pass
    I only have a mouse event. As follows:
    class 1
    public void mousePressed(MouseEvent e) {
    int y1=Math.abs(e.getY()-y);
    this.sourceReference.setVar(y1);
    repaint();
    class 2
    int var;
    public void setVar(int y)
    var=y;
    this.ActionPerformed(?? ); //This is what I want to do
    Same question slightly different.
    From class 1 I scould first call the setVar method
    and then issue a call to class 2's ActionPerformed.
    But again I don't seem to have the proper action event e to pass it.
    Thanks

    Do you need any information from an ActionEvent that you'd be calling from the MouseEvent (ie the action command, or somethig) or can you just have the actionPerformed method just call a different method that doesn't need an ActionEvent?
    public void actionPerformed(ActionEvent e) {
    this.doActionStuff();
    public void doActionStuff() {
    // does what you want the action event to do
    Then from the mousePressed method you can just call the doActionStuff method.
    I'm not sure if this helps or not, hope it does.
    Scott

Maybe you are looking for

  • Acrobat 9 - Comment toolbar drops off in browser window

    Hello, We use a browser environment to comment on PDF documents and sometimes (about 5% of the time) with Acrobat 9 the "Comment" toolbar option does not appear (this does not happen with earlier versions of Acrobat). If I close the browser and Acrob

  • I've just bought a new laptop. It is only syncing purchased music

    I've just bought a new laptop. It is only syncing purchased music. I have loads of music on my iphone, what can I do to get it synced and saved onto my new laptop? Thanks!

  • SQL Azure server instance

    I want to find out is how many SQL bulk operations can reliably be done at once on a SQL Azure server instance? Is there any capacity restrictions such as # of simultaneous bulk inserts, total # of rows per bulk operation, etc.? How should we handle

  • Images not printing

    My program only seems to print out the last card in my JFrame, even though I do have a "for" loop. I really do not get why it doesn't print the others. public class Image extends Component { BufferedImage[] img = new BufferedImage[6]; public void pai

  • What method will be called when an javabean terminates?

    Hi, I am using a java bean in my jsp application with scope "application". I know that this java bean will be terminated only when the server stops or shuts down. I need to cleanup something manually when the server shuts down. Can anyone tell me wha