Reputation: 4003
I've got the same code on two different machines. One is working the other isn't! The code is here... Anything you could spot that I missed?
public void urlParameters() {
FacesContext context = FacesContext.getCurrentInstance();
Map<String, String> paramMap = context.getExternalContext().getRequestParameterMap();
requestID = paramMap.get("id");
if (requestID.equals("1")) {
message = "right!!";
} else {
message = "Wrong!";
}
}
and I access it with this link:
http://localhost:8080/SMDRepair/faces/review.xhtml?id=1
Upvotes: 0
Views: 537
Reputation: 4003
After long long long research, I found the simplest mean of getting URL parameter in JSF Bean:
@ManagedProperty(value="#{param.id}")
Just make sure you import:
import javax.faces.bean.ManagedProperty;
Hope this helps in future
Upvotes: 1