Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

f:param is not working for me! What am I doing wrong?

rrugemaliraApr 1 2014 — edited Apr 4 2014

I have attached f:parameter tag to component h:commandButton as follows:

<h:commandButton id="commandBtn" value="Reserve" action="#{avlbleTrucksBean.storeData}">

   <f:param name="currentId" value="#{String.valueOf(truck.theIndex)}"></f:param>

</h:commandButton>

Yes, truck.theIndex is an integer.

I desire to get the value of param and use it in the managed bean, but I am not able to get the value!

The managed bean is as follows:

@ManagedBean

@SessionScoped

@Named("avlbleTrucksBean")

public class AvlbleTrucksBean implements Serializable {

  private int currentId;

  // getter and setter methods

  public int getCurrentId() {

      return currentId;

  }

  public void setCurrentId(int currentId) {

      this.currentId = currentId;

  }

  public String storeData() {

      FacesContext fContext = FacesContext.getCurrentInstance();

      this.currentId = Integer.parseInt(getCurrentIdParam(fContext));

      System.out.println("currentId is: " + currentId); // This doesn't print the value! Why?

  } 

 

  // Get value from "f:param"

  public String getCurrentIdParam(FacesContext fc){

      Map<String,String> param = fc.getExternalContext().getRequestParameterMap();

      return  param.get("currentId");

  }

}

This post has been answered by rrugemalira on Apr 3 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 2 2014
Added on Apr 1 2014
6 comments
4,993 views