I have a pretty complex JSF page (we use JSF2 with facelet) in which I have to “plug-in” a pure html form section (it represents a WYSIWYG template for an document that will be created as Pdf later).
Very simplified the page looks like
<h:form id="formEditDoc">
<p:commandButton styleClass="commandButton" value="Save"
actionListener="#{myBean.myAction}" update="masterForm:msg">
</p:commandButton>
<!-- some jsf controls here -->
....
<!-- this is my dynamic section -->
<input id="ft2" type="text" value="foo"/>
</h:form>
In the managed bean myBean (request scoped) I have the action listener in which I try to get the “foo” string in this way:
String text1 = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("ft2");
But I can’t get the value. Text1 is always null. I even tried to set ajax=false to the commandButton, but nothing changed.
Any idea about what I am doing wrong?
It’s the input’s
name=valuepair which get sent as request parametername=value, not theid=value. You need to set thenameattribute instead.Unrelated to the concrete problem, I suggest to use
@ManagedPropertyinstead to set the value: