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

  • Home
  • SEARCH
  • 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 8410797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:16:22+00:00 2026-06-10T00:16:22+00:00

I have built a custom component button, but somehow the action is not invoked.

  • 0

I have built a custom component button, but somehow the action is not invoked. When debugging the getAction-Method within the component and invoking the supplied MethodeExpression the Bean-Method is called as expected. But due to some reason, the Expression is not invoked when pressing the button in the browser.

Is there some kind of additional Interface necessary to pass the action to the embedded button-component?

Any help is very appreciated since I am stuck at this issue for some days now

MyClass:

public class MyClass extends UIPanel implements SystemEventListener
{

private UIForm              form;
private HtmlCommandButton   buttonOk;

public MyClass()
{
    FacesContext context = getFacesContext();
    UIViewRoot root = context.getViewRoot();
    root.subscribeToViewEvent(PostAddToViewEvent.class, this);
}


@Override
public void processEvent(SystemEvent event)
{
    this.form = new UIForm();
    this.buttonOk = new HtmlCommandButton();
    this.buttonOk.setId("okButtonId");
    this.buttonOk.setActionExpression(getAction());
    this.buttonOk.setValue("OK");
    this.form.getChildren().add(this.buttonOk);
    getChildren().add(this.form);
}


private enum PropertyKeys
{
    action, text, titel
}


public MethodExpression getAction()
{
    return (MethodExpression) getStateHelper().eval(PropertyKeys.action);
}


public void setAction(MethodExpression actionExpression)
{
    getStateHelper().put(PropertyKeys.action, actionExpression);
}


public String getText()
{
    return (String) getStateHelper().eval(PropertyKeys.text);
}


public void setText(String text)
{
    getStateHelper().put(PropertyKeys.text, text);
}


public String getTitel()
{
    return (String) getStateHelper().eval(PropertyKeys.titel);
}


public void setTitel(String titel)
{
    getStateHelper().put(PropertyKeys.titel, titel);
}


@Override
public void encodeAll(FacesContext context) throws IOException
{
    ResponseWriter writer = context.getResponseWriter();
    writer.startElement(HTML.DIV_ELEM, this);
    writer.writeText(getText(), null);
    this.form.encodeAll(context);
    writer.endElement(HTML.DIV_ELEM);
}


@Override
public void encodeChildren(FacesContext context) throws IOException
{

}


@Override
public boolean isListenerForSource(Object source)
{
    return (source instanceof MyClass);
}

}

MyClassHandler:

public class MyClassHandler extends ComponentHandler
{

public MyClassHandler(ComponentConfig config)
{
    super(config);
}


@SuppressWarnings("rawtypes")
@Override
protected MetaRuleset createMetaRuleset(Class type)
{
    return super.createMetaRuleset(type).addRule(new MethodRule("action", String.class, new Class[] { ActionEvent.class }));
}

}

myView Method:

...
public String myMethod()
{
    System.err.println("myMethod");
    return "/some/path/yadayada.xhtml";
}
...

MyView.xhtml

<myTag action="#{myView.myMethod}" id="id1" titel="bla" text="bleh" />
  • 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-10T00:16:23+00:00Added an answer on June 10, 2026 at 12:16 am

    Exdending UICommand is enough, since you only want one action to be executed.

    You have to provide two additional MethodExpressions via the tag-attributes and within the decode-method you can check which button has been pressed and redirect the particular MethodExpression to the standard-action provided by UICommand. This way, you dont have to worry about the legacy-interface ActionSource, or how Events are broadcasted.

    public void decode(FacesContext contex)
    {
        Map<String,String> map = context.getExternalContext.getRequestParameterMap();
        // your rendered buttons need a name you check for
        final boolean okPressed = map.containsKey( getClientId + ":ok" ); 
        final boolean cancelPressed = map.containsKey( getClientId + ":cancel" );
        if(okPressed || cancelPressed)
        {
            MethodExpression exp = null;
            if(okPressed)
            {
                exp = getActionOk();
            }
            else
            {
                exp = getActionCancel();
            }
            // redirect to standard action
            setActionExpression(exp);
            queueEvent(new ActionEvent(this));
        }
    }
    

    In order to make use of of this you need two attributes (actionOk and actionCancel) which use Method Expressions (setter and getter). Those have to be configured by a ComponentHandler as you did for the action-attribute.

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

Sidebar

Related Questions

I am moving away from MXML and have built a custom component control within
I have built a custom component using some containers and a TileList. Now when
I have a custom component built for a Joomla 2.5 website. It is working
I have built a custom view component that displays a timeline of events. The
I have a custom built sign up component that I would like to enhance.
it's my first question. I have built a custom component: a RelativeLayout with a
I have just built a custom autocomplete component using jquery. My problem is that
I have built a custom component that shows only a line. The line is
I have built a custom HTML component in extJS by specifying the html value
I have built a Custom MaskedTextBox , changing the values of BeepOnError and AsciiOnly

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.