i am aware that this has been discussed before, but the example that i created does not work.
bean:
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.*;
import java.io.Serializable;
import java.util.Map;
@ManagedBean
@SessionScoped
public class HelloBean implements Serializable {
private static final long serialVersionUID = 1L;
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String submit() {
FacesContext fc = FacesContext.getCurrentInstance();
Map<String,String> params =
fc.getExternalContext().getRequestParameterMap();
System.out.println("params" + params);
String country = params.get("country");
System.out.println("country:" + country);
return "welcome";
}
}
and this is the page:
</h:head>
<h:body>
<h:outputScript library="js" name="common.js" />
<!-- <h:outputScript library="js" name="websocket.js" /> -->
<h3>JSF 2.0 Hello World Example - hello.xhtml</h3>
<h:form>
<h:inputText value="#{helloBean.name}"></h:inputText>
<h:commandButton value="Welcome Me" action="#{helloBean.submit}"> </h:commandButton>
</h:form>
</h:body>
</html>
when i call the page like this: localhost:8080/JavaServerFaces2/hello.xhtml?country=123
and press the button i would expect that the submit method prints the country value in the console. but it prints:
2018-05-13T17:06:48.872+0200|Info: params{j_idt7=j_idt7, j_idt7:j_idt8=, j_idt7:j_idt9=Welcome Me, javax.faces.ViewState=- 4186994023180961740:1040096002697043710}
2018-05-13T17:06:48.872+0200|Info: country:null
why?
p.s. im eagerly awaiting the new feature to paste code, im sure it will be great.