We help IT Professionals succeed at work.

Retrieve input value from JSF page

ayha1999
ayha1999 asked
on
I am trying to retrive input text of the textboxes from a jsf page but nothing returns. what is wrong with the code?

<h:form id="myForm">
<h:inputText size="10" id="txtName"/>

    public void printValue() {
        HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
        String txtName = request.getParameter("myForm:txtName");
        System.out.println(txtName);
    }

ayha
Comment
Watch Question

In the inputText tag, add  value="#{your_class_name.userInput}

Use the @ManagedBean annotation on your class.