0

I have the following bean class

@ManagedBean
@ViewScoped
@SuppressWarnings("serial")
public class AsrTabBean implements Serializable{

    public void save() {
        String value = FacesContext.getCurrentInstance().
                getExternalContext().getRequestParameterMap().get("name");

        System.out.println("name is: " + value);
    }
    //Getters and Setters
}

My jsf consist of a page with tabs and each tab I am using an include tag to insert each page with its correspondant form.

However, I am trying to test out getting the input value from the input tag and it keeps returning null

<h:form>
        <p:panel id="panel" header="Asr Form" style="margin-bottom:10px;">
            <p:messages id="messages" />
            <h:panelGrid columns="2" cellpadding="5">
                <h:outputLabel  value="name" />
                <p:inputText id="name" />
            </h:panelGrid>
        </p:panel>
        <p:commandButton value="Submit" action="#{asrTabBean.save}" />
    </h:form>

result of stdo

name is: null
Beto
  • 806
  • 3
  • 12
  • 33
  • Which jsf tutorial are you using? Please go to https://jsf.zeef.com and pick one there. Looks like you try to use jsf like in php or cgi. – Kukeltje Jul 26 '16 at 21:27
  • http://stackoverflow.com/questions/19002570/retrieving-value-of-jsf-input-field-without-managed-bean-property Tried from there. Already tried with formId and changing names. I just need to get the values without binding bc I will have alot of input tags. – Beto Jul 26 '16 at 21:36
  • Then use a hashmap of strings... `value="#{myBean.myFields['name']}"` http://stackoverflow.com/questions/17884028/make-jsf-access-a-mapstring-values-from-an-el-instead-of-a-bean-fields – Kukeltje Jul 26 '16 at 21:41
  • And that could also be `value="#{myBean.myFields.name}"` – Kukeltje Jul 26 '16 at 23:11
  • So you haven't checked what's all inside `getRequestParameterMap()`? Nonetheless, this is indeed fishy. Just collect all those input values in a map or list instead of attempting to manually take over JSF's job. Perhaps this answers your XY-problem: http://stackoverflow.com/q/3409053 – BalusC Jul 27 '16 at 06:17

0 Answers0