Just do the same as JSF is doing under the covers: grabbing the HTTP request parameter. If you're familiar with basic HTML, you know that every HTML input element sends its name=value
pair as HTTP request parameter.
Given a
<h:form id="formId">
<p:inputText id="userId" /> <!-- Note: no value attribute at all, also no empty string! -->
...
<p:commandButton value="submit" action="#{bean.submit}" />
</h:form>
which generates basically the following HTML
<form id="formId" name="formId">
<input type="text" name="formId:userId" ... />
...
<button type="submit" ...>submit</button>
</form>
you could grab it as follows from ExternalContext#getRequestParameterMap()
:
public void submit() {
ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
String userId = ec.getRequestParameterMap().get("formId:userId");
// ...
}
Don't forget to manually convert and validate it if necessary, like as JSF is doing under the covers. In other words, just repeat the JSF's job by writing additional code so that your code is not DRY :)