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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:51:18+00:00 2026-06-09T13:51:18+00:00

Here is an quote from Oracle JavaEE 6 tutorial docs for passing parameter in

  • 0

Here is an quote from Oracle JavaEE 6 tutorial docs for passing parameter in value expression and method expression in JSF 2.

Parameters are supported for both value expressions and method expressions. In the following example, which is a modified tag from guessNumber application, a random number is provided as an argument rather than from user input to the method call:

<h:inputText value="#{userNumberBean.userNumber('5')}"> 

The above example uses a value expression.

And this is the default one:

<h:inputText value="#{userNumberBean.userNumber}">

Bean class –

import java.util.Random;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped; 

@ManagedBean
@SessionScoped
public class UserNumberBean {

    Integer randomInt = null;
    Integer userNumber = null;

    public UserNumberBean() {
        Random randomGR = new Random();
        randomInt = new Integer(randomGR.nextInt(10));
        System.out.println("Duke's number: " + randomInt);
    } 

    public void setUserNumber(Integer user_number) {
        userNumber = user_number;
    }

    public Integer getUserNumber() {
        return userNumber;
    }

}

The following expression is not passing 5 as a parameter to the inputText:

<h:inputText value="#{userNumberBean.userNumber('5')}">

It actually causes an error at run-time.

My question: How do I achieve this ??

  • 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-09T13:51:19+00:00Added an answer on June 9, 2026 at 1:51 pm

    You don’t need to pass a parameter in the example you’ve provided.

    In this situation getters and setters are invoked automatically on your backing bean.

    The following code will invoke getUserNumber and/or setUserNumber to retrieve and/or modify the value of the inputText component:

    <h:inputText value="#{userNumberBean.userNumber}">

    The form value entered by the user will be passed to setUserNumber as a parameter.


    To pass a parameter to a backing bean method, you might do something like this:

    <h:commandButton  action="#{userNumberBean.displayAlert('Hey')}"    value="Say Hey"/>
    <h:commandButton  action="#{userNumberBean.displayAlert('Later')}"  value="Say Bye"/>
    

    This would invoke a method that looks like this:

    public String displayAlert(String someText)


    As Bhesh Gurung’s answer suggests, you can set userNumber to 5 by default in the constructor.

    You could also use one of the methods suggested here to apply a default value.

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

Sidebar

Related Questions

Here's the line from App.Config: <add key=CheckFileFormatString value=P{0}\t&quot;{1}, {2}&quot;\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}/> Here's the code that puts
Here's a quote from Android's Dev Guide: A central feature of Android is that
Here is a quote from a textbook I'm reading at the moment: That is,
I'm trying to come up with a search/replace expression that will convert from Oracle
Here are the details: I installed the oracle instant client 11.2.0.2.0 from the OTN
Here is a quote from the book Introduction to Assembly language about RISC (vs
Check out this quote from here , towards the bottom of the page. (I
I am trying to retrieve a stock quote from Yahoo! finance using Flex. I
Here's an example of the sort of query I would like to prevent from
So I would like to execute an oracle plsql script from Visual Studio. I

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.