Consider the following fragment of the HtmlBasicRenderer
class:
Map<String, String> requestMap =
context.getExternalContext().getRequestParameterMap();
// Don't overwrite the value unless you have to!
String newValue = requestMap.get(clientId);
if (newValue != null) {
setSubmittedValue(component, newValue);
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE,
"new value after decoding {0}",
newValue);
}
}
The fragment is being appeard within the decode(FacesContext context, UIComponent component)
method which is responsible for extracting request parameters and assigning it to components during the Apply Request Phase.
My question is about how this request parameter are generated? If we have simple html
-form and standard html input
s inside it like that:
<form method="POST">
<input name="name" value="value" />
</form>
we'll get the name=value
parameter pair.
So, the only way for us to specify the request parameter key for a component we're writing is to specify the name
attribute of the element within the encode
method of it's renderer. Once we did that, we can get access to the corresponding parameter from the decode method.
Update: I'm writing a component inherited from UISelectOne
but the selected item may contain more the one input field (two in specifiec). Its declaration will look something like the following (details seemed unimportand were ommited):
<stcomutil:selectOne key="#{myBean.key}" value="#{myBean.value}">
<stcomutil:selectOneItem />
<stcomutil:selectOneItem />
<stcomutil:selectOneItem />
</stcomutil:selectOne>
Where <stcomutil:selectOneItem />
is rendered as two input type="text"
:
^ ^
| |
| |
the key field the value field
So, in fact I will have 3 rows of such inputs and I need to process the only row user type in. Again, I omit the details with disabling inputs and so forth.
What I want to learn: To process additional value input (convert, validate, update, etc) I just need to specify the name attribute for that additional input and then extract it at the Apply request phase, right? Also, at the Update model phase I have to explcitily extract the ValueExpression
object for that binding with the getValueExpression
and assign the value to it with the setValue
method.