它没有更新管理器中的列表模型的芯片组件使用下一个教程chips u我正在尝试更新ap:chips组件的模型,我正在使用Apache tomcat 9和primefaces 6.2,我使用PostConstruct在此列表中添加了一些数据,数据列表显示在组件中,但是当在视图中添加一些项目时,在模型管理bean中没有修改任何项目,在看到记录器后items.size()保持不变,视图中的组件行为会按预期进行响应。在Windows机器上,它按预期工作。
我的xhtml
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:cmp="http://xmlns.jcp.org/jsf/composite/cmp">
<h:form id="formChips">
<p:outputLabel for="items" value="Items: " /><br/>
<p:chips id="items" value="#{beanChipsViewer.items}" inmediate="true" >
<p:ajax event="itemSelect" listener="#{beanChipsViewer.chipsSelect}" update=":itemList chips"/>
<p:ajax event="itemUnselect" listener="#{beanChipsViewer.chipsDeselect}" update=":itemList chips"/>
<p:ajax event="change" process="@this" update="chips" delay="300" />
<p:ajax event="valueChange" process="@this" update="chips" delay="300" />
<p:ajax event="click" process="@this" update="chips" delay="300" listener="#{beanChipsViewer.mostrar}" />
<p:ajax event="mousedown" process="@this" update="chips" delay="300" />
<p:ajax event="mouseup" process="@this" update="chips" delay="300" />
</p:chips>
<br/>
<p:commandButton value="Save" icon="ui-icon-check" update=":itemList" action="#{beanChipsViewer.agregar()}"
actionListener="#{beanChipsViewer.mostrar}"
/>
<br/>
</h:form>
<br/>
<p:outputPanel id="itemList">
<p:repeat value="#{beanChipsViewer.items}" var="item">
<h:outputText value="#{item}"/>
<br/>
</p:repeat>
</p:outputPanel>
<h:panelGroup id="chips">
<h:outputText value="#{beanChipsViewer.items}" />
</h:panelGroup>
<br/>
这是托管bean编码:
@Named
@ViewScoped
public class BeanChipsViewer implements Serializable {
private String itemSelected;
private String itemUnselected;
private static final Logger logger = LoggerFactory.getLogger(BeanChipsViewer.class);
@PostConstruct
public void init(){
for(int i=0;i<20;i++)
items.add("etiqueta "+i);
}
private List<String> items = new ArrayList<String>();
public List<String> getItems() {
return items;
}
public void setItems(List<String> items) {
this.items = items;
}
public void agregar(){
logger.info("Entra " +items.size());
items.add("nitro");
logger.info("zize after intro" +items.size());
UtilsPrimefaces.executeUpdatePF("itemList");
}
public void mostrar(){
logger.info("Entra mostrar");
for(String m:items){
logger.info("chipItem "+ m);
}
}
public void chipsSelect(SelectEvent e){
logger.info("chip seleted"+e.getObject().toString());
this.setItemSelected(e.getObject().toString());
items.add(e.getObject().toString());
logger.info("items size afteR chipselected "+ items.size());
}
public void chipsDeselect(UnselectEvent e){
logger.info("chip deselect"+e.getObject().toString()+" "+items.size());
this.setItemUnselected(e.getObject().toString());
}
public void phaseListener(PhaseEvent e){
List<FacesMessage> messages = e.getFacesContext().getMessageList();
System.out.println(messages.size());
}
我必须使用下一个导入
import javax.faces.view.ViewScoped;
import javax.inject.Named;
我正在将@ManageBean与CDI混合