Getting request parameters in JSF

Here is the way, how we get request parameters from a JSP page (which is JSF enabled) in a HTTP request object.

import javax.faces.context.FacesContext;
//…your code
HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
String controlName = request.getParameter("formId:controlId");

Where formName is refer to the id of your form and controlId is referred to the id of your control.

You May Also Like

5 Comments

  1. Hi,
    and thank you very much!
    This works really fine! Just to mention, each control on the form is a container for inside controls; this means:
    if you have some checkboxes inside a table column, you’ll have to point to the first Checkbox as:
    form1:dataTable1:0:Select
    and so forth…

    Thanks again!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.