问题
It seems to me that p:inputText does not support sending parameters via f:param. Is this true?
If yes, how could I pass the parameters?
In more details
I have a list of inputText fields generated via:
<p:dataTable value="#{EncryptionBean.epList}" var="item">
<p:column>
...
<p:inputText value="#{item.APID}" valueChangeListener="#{EncryptionBean.listenerApid}">
<f:param value="#{item.presetName}" name="whoLaunched"/>
<p:inputText>
</p:column>
<(p:dataTable>
When I catch the value change listener, I need to know which of the EncryptionBean.epList does the inputText belong to. I usualy do this with:
ExternalContext ec;
...
String value = (String)ec.getRequestParameterMap().get("whoLaunched");
...but it does not work for inputText (as it worked for commandLink for example).
Basically, how do I pass item.presetName together with itemText value (item.APID) to the listener? I need to save those 2 in the map.
回答1:
This worked:
xhtml:
<p:inputText value="#{item.APID}">
<p:ajax listener="#{EncryptionBean.listenerApid( item.presetName, item.APID )}"/>
</p:inputText>
java bean:
public void listenerApid( String presetName, String typedAPID )
{
// Do something with values.
}
Ubelievable how easy it is to pass those values, just use ajax listener with arguments instead of valueChangeListener.
来源:https://stackoverflow.com/questions/13975026/possible-to-pass-pinputtext-parameters-via-fparam