Jsf 如何将ajax事件附加到非ClientBehaviorHolder组件
在一个表单中,我有一个Jsf 如何将ajax事件附加到非ClientBehaviorHolder组件,jsf,primefaces,Jsf,Primefaces,在一个表单中,我有一个p:inputText和一个p:colorpocker,如下所示: <h:outputText value="#{messages.titre}" /> <p:inputText value="#{beanPlanningRessource.equipe.typeRessource.titre}"> </p:inputText> <h:outputText value="#{messages.couleur}" /> <
p:inputText
和一个p:colorpocker
,如下所示:
<h:outputText value="#{messages.titre}" />
<p:inputText value="#{beanPlanningRessource.equipe.typeRessource.titre}">
</p:inputText>
<h:outputText value="#{messages.couleur}" />
<p:colorPicker value="#{beanPlanningRessource.equipe.typeRessource.couleur}">
</p:colorPicker>
<p:commandButton widgetVar="ajouter_equipe"
style="visibility: hidden;"
actionListener="#{beanPlanningRessource.ajouterEquipe()}" process="@this"
update=":#{p:component('dataTableEquipe')}, :#{p:component('formEquipe')}, :msgs" >
</p:commandButton>
这里的问题是p:inputText
和p:colorPicker
中的值在托管bean中始终为空,因此在p:inputText
中我添加了这一行:
<p:ajax event="change" process="@this" />
现在,beanplanningresource.equipe.typeresource.titre
用p:inputText
中的值更新
我仍然存在的问题是,p:colorPicker
是一个非ClientBehaviorHolder组件,因此我不能将p:ajax
附加到它,也不能附加到f:ajax',因此附加到p:colorPicker:
(beanplanningresource.equipe.typeresource.couleur`)的值始终为空
如何解决这个问题?除了jquery,您还可以使用valueChangeListener
html:
使用客户端javascript(jquery事件)和remoteCommand…这不是ajax事件。。。完全不同的事情
<p:colorPicker valueChangeListener="#{beanPlanningRessource.colorChanged}" value="#{beanPlanningRessource.equipe.typeRessource.couleur}"/>
colorChanged(ValueChangeEvent event){
String newColor = event.getNewValue();
//do whatever you want with the new value
}