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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:57:43+00:00 2026-05-28T06:57:43+00:00

When i tried to send some values with h:commandButton… i recieved null value in

  • 0

When i tried to send some values with h:commandButton… i recieved null value in the bean…

my xhtml code is:

  <p:commandButton action="#{favouriteAction.setFavourite}"  value="Add as Favorite" rendered="#{favouriteBean.favouriteButton}">
  <f:setPropertyActionListener target="#{favouriteAction.ngoID}" value="#{InsertDataDaoService.ngo_id}"></f:setPropertyActionListener> 
  </p:commandButton>    

In the backing bean i just tried to print the value which i passed with my command button,but it becomes null…

In favouriteAction.java(My backing Bean)

  public Integer ngoID;

public Integer getNgoID() {
return ngoID;
}


public void setNgoID(Integer ngoID) {
this.ngoID = ngoID;
}

    public String setFavourite(){

      System.out.println("Ngo id: "+ngoID);
   System.out.println("Ngo id: "+getNgoID);

    return "";
}

In console i dint get any exceptions, my o/p is

Ngo id: 0
Ngo id: 0

that is null, and it doesnt get passed..

  • 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-05-28T06:57:43+00:00Added an answer on May 28, 2026 at 6:57 am

    The <f:setPropertyActionListener> is evaluated during the request of the form submit, not during the request of displaying the form. So if its value #{InsertDataDaoService.ngo_id} is not preserved for that request, then it will fail.

    You have basically 2 options:

    1. Ensure that #{InsertDataDaoService.ngo_id} is preserved for the request of the form submit. How exactly do to that depends on the functional requirements which are not clear from the question. But generally, putting the #{InsertDataDaoService} bean in the view scope by @ViewScoped and making sure that you aren’t doing any business job in the getter method should be sufficient.

    2. Replace <f:setPropertyActionListener> by <f:param> with @ManagedProperty.

      <p:commandButton action="#{favouriteAction.setFavourite}" value="Add as Favorite" rendered="#{favouriteBean.favouriteButton}">
          <f:param name="ngoID" value="#{InsertDataDaoService.ngo_id}" />
      </p:commandButton>
      

      with

      @ManagedProperty("#{param.ngoID}")
      private Integer ngoID;
      

      This way the value will be retrieved (and inlined as part of a JavaScript helper function of the commandButton) during the request of displaying the form, not evaluated during the request of submitting the form.

    See also:

    • How can I pass selected row to commandLink inside dataTable?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried this code to send a file and insert the details about
I have tried putting together some code based on some other SO questions and
I tried to send a packet on the socket I use to listen for
I tried to send an email using this class below, but no success, no
I created a simple test with SendKeys, and tried both SendWait and Send. Private
I want to get some values out of TinyMCE textboxes, along with IDs. Then
I am writing an app that ultimately wants to send some XML via email.
I'm having some trouble with SBJsonWriter at the moment. I need to send a
I'm trying to take a URL's hash value, send it through a function, turn
I tried to send an array as part of an ajax request like this:

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.