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 8000947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:57:21+00:00 2026-06-04T15:57:21+00:00

The conditional operator works in many attributes like rendered value and others. But it

  • 0

The conditional operator works in many attributes like “rendered” “value” and others.

But it does not work in action? Or am I doing it wrong?

<h:commandLink action="#{true ? bean.methodTrue() : bean.methodFalse()}"/>

Error: javax.el.ELException: Not a Valid Method Expression

(I realized it using primefaces ajax action attribute)

  • 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-04T15:57:23+00:00Added an answer on June 4, 2026 at 3:57 pm

    This is not supported. The action attribute is supposed to be a MethodExpression, but the conditional operator makes it a ValueExpression syntax. I don’t think this will ever be supported for MethodExpressions in EL.

    You have basically 2 options:

    1. Create a single action method which delegates the job.

      <h:commandButton ... action="#{bean.method}" />
      

      with

      public String method() {
          return condition ? methodTrue() : methodFalse();
      }
      

      If necessary, pass it in as method argument by #{bean.method(condition)}.

    2. Or, conditionally render 2 buttons.

      <h:commandButton ... action="#{bean.methodTrue}" rendered="#{bean.condition}" />
      <h:commandButton ... action="#{bean.methodFalse}" rendered="#{not bean.conditon}" />
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Conditional operator assignment with Nullable<value> types? Hi, Why this doesn't work? DateTime?
Possible Duplicates: Nullable types and the ternary operator. Why won’t this work? Conditional operator
Why can't the conditional operator be used as a statement? I would like to
Simple question, simple code. This works: $x = &$_SESSION['foo']; This does not: $x =
I am trying to use the conditional operator, but I am getting hung up
Is it not allowed to have a conditional operator in a lambda expression in
I'm making a simple loading bar and it seems that Facelets does not like
I'm a bit puzzled about the conditional operator. Consider the following two lines: Float
HI, I need to write multiple statements inside a conditional operator. What will be
Is it ok to use conditional operators like a statement like so? (x ==

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.