FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("compId")
returns null for outputLable
and outputText
, but not for inputText
and inputHidden
.
Why is that and how do I get the value for outputLabel or outputText?
That's just how HTML works. Only form elements send their name=value
pairs as HTTP request parameters, because their value can be controlled by the enduser.
For output labels and output texts this would not happen. It would not make any sense, because their value are usually not controlled by the enduser. Those values are usually already controlled by the webdeveloper. There's no point of sending a copy of them back if the server side already knows about them. If you're however allowing the enduser to change them in the client side by JavaScript means, then you should be adding a hidden input element (<input type="hidden">
) and setting the changed value over there. Hidden inputs do also send their name=value
pair as HTTP request parameter.