Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7850683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:56:34+00:00 2026-06-02T18:56:34+00:00

first, please forgive my ignorance and inability so use the search engine (i swear

  • 0

first, please forgive my ignorance and inability so use the search engine (i swear i have searched long and often but did not find any satisfying answer to this problem).

I have a bean implementing a action-listener compatible method:

@ManagedBean(name = "myBean")
@ViewScoped
class Bean{
    public String myAction(ActionEvent event){
        ... = event.getComponent().getAttributes().get("something");
    }
}

Then, i have a jsf component like this:

<composite:interface>
    <composite:attribute name="actionBean" required="true"/>
    <composite:attribute name="actionMethod" method-signature="void myAction(javax.faces.event.ActionEvent)" />
</composite:interface>
<composite:implementation>
        <h:form>
            <p:commandButton actionListener="#{cc.attrs.actionBean[cc.attrs.actionMethod]}">
                <f:attribute name="something" value="somevalue" />
            </p:commandButton>
        </h:form>
</composite:implementation>

It is called something like this:

<namespace:myComponent actionBean="#{myBean}" actionMethod="myAction" />

I know that this call is not working, and i wonder how to do it right!

My main intention is that i want to have a relatively generic jsf-component (would be nice to have it reusable later), that contains a button. On click to this button i want to pass an object (no simple string! in case of string i would just use action="..." and pass it via f:param). With the actionListener method i take the object via event.getComponent().getAttributes().get("something").

I think the signature void myAction(javax.faces.event.ActionEvent) is the problem that breaks passing the related method to the component, isnt it? Is it in general possible to pass method with any argument to jsf components (and if yes, how)?

So, i hope there is a possible solution to solve the general problem with altering the above strategy or maybe use something nice and different (in general i prefer not to use any hacks or workarounds, but like to use what is intended by the framework).

Thanks if somebody would find the time to point me the way! In case this question already exists, would be nice to get to the related post and have this deleted.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T18:56:35+00:00Added an answer on June 2, 2026 at 6:56 pm

    Try following:

    <namespace:myComponent myAction="#{myBean.myAction}"/>
    

    And composite component:

    <composite:interface>
        <composite:attribute name="myAction" 
                             required="true" 
                             method-signature="void myAction(javax.faces.event.ActionEvent)"
                             targetAttributeName="actionListener"/>
    </composite:interface>
    <composite:implementation>
        <h:form>
            <p:commandButton id="myAction">
                <f:attribute name="something" value="somevalue" />
            </p:commandButton>
        </h:form>
    </composite:implementation>
    

    Check composite:attribute documentation. It has several options to pass listeners to composite component. I used targetAttributeName for this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, please forgive my bad english ;) I want to use the windows function
First, please forgive and point out if I am to use some other protocol
First off, please forgive the stupidness of this question but Im not from a
First, please forgive me for my approximative English. I have 2 tables, one (tb_facture)
First of all, please forgive my ignorance in both Java and Hibernate, I'm studying
First time Stack Overflow poster. Please bear with me! :) I have a set
I am a brand new programming student, so please forgive my ignorance. My assignment
This is my first post, and first please forgive me for my poor english.
[please forgive formatting errors-- first post here and I tried earnestly to do it
This is my first post, so please forgive me if this question has been

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.