简体   繁体   English

javax.faces.FacesException:目标模型Type不是Collection或Array

[英]javax.faces.FacesException: Target model Type is no a Collection or Array

When submitting a JSF form, I'm getting the below exception: 提交JSF表单时,我收到以下异常:

Caused by: javax.faces.FacesException: Target model Type is no a Collection or Array 
    at com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectManyValuesForModel(MenuRenderer.java:388) [:2.0.3-] 
    at com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectManyValue(MenuRenderer.java:125) [:2.0.3-] 
    at com.sun.faces.renderkit.html_basic.MenuRenderer.getConvertedValue(MenuRenderer.java:311) [:2.0.3-] 
    at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1023) [:2.0.3-]     at javax.faces.component.UIInput.validate(UIInput.java:953) [:2.0.3-] 
    at javax.faces.component.UIInput.executeValidate(UIInput.java:1204) [:2.0.3-] 
    at javax.faces.component.UIInput.processValidators(UIInput.java:693) [:2.0.3-] 
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1081) [:2.0.3-] 
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1081) [:2.0.3-] 
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1081) [:2.0.3-] 
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1081) [:2.0.3-] 
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1081) [:2.0.3-] 
    at javax.faces.component.UIForm.processValidators(UIForm.java:240) [:2.0.3-] 
    at org.ajax4jsf.component.AjaxViewRoot$3.invokeContextCallback(AjaxViewRoot.java:439) [:3.3.1.GA] 
    at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:238) [:3.3.1.GA] 
    at org.ajax4jsf.component.AjaxViewRoot.processValidators(AjaxViewRoot.java:455) [:3.3.1.GA] 
    at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:72) [:2.0.3-]   at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97) [:2.0.3-] 
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114) [:2.0.3-] 
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308) [:2.0.3-]
    ... 42 more

How is this caused and how can I solve it? 这是怎么造成的,我该如何解决?

javax.faces.FacesException: Target model Type is no a Collection or Array
    at com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectManyValuesForModel(MenuRenderer.java:388)

This exception indicates that you've an UISelectMany component in the view such as <h:selectManyMenu> or <h:selectManyListbox> whose value is not been bound to a collection or array. 此异常表示您在视图中有一个UISelectMany组件,例如<h:selectManyMenu><h:selectManyListbox>其值绑定到集合或数组。 This is not right. 这个不对。 Its value must be bound to a collection (like List<Entity> ) or array (like Entity[] ), because the component can retrieve multiple submitted values. 它的值必须绑定到集合(如List<Entity> )或数组(如Entity[] ),因为组件可以检索多个提交的值。

Here's a kickoff example of how a proper <h:selectManyMenu> look like, assuming that you're using String typed items: 这是一个启动示例,说明正确的<h:selectManyMenu>如何,假设您正在使用String类型的项:

<h:selectManyMenu value="#{bean.selectedItems}">
    <f:selectItems value="#{bean.availableItems}" />
</h:selectManyMenu>
<h:commandButton value="submit" action="#{bean.submit}" />

with

private List<String> selectedItems; // Note: List<String> and thus NOT String!
private List<String> availableItems;

@PostConstruct
public void init() {
    availableItems = Arrays.asList("one", "two", "three", "four", "five");
}

public void submit() {
    System.out.println("Selected items: " + selectedItems);
}

See also: 也可以看看:

My solution was: I removed the attribute "dtSubItem" from the tag process of the <p:commandButton> tag and all works normally. 我的解决方案是:我从<p:commandButton>标签的标签process中删除了属性“dtSubItem”,并且一切正常。 The command button was submitting the datatable on the submit event. 命令按钮是在提交事件上提交数据表。

Worked on the first request, but at the second the error emerged, when datatable was populated. 处理了第一个请求,但是在第二个错误出现时,填充了数据表。

 <div class="ui-g-12 ui-md-6 ui-lg-2"> <div class="espacoCampo"> <p:outputLabel value="" /> <p:commandButton actionListener="#{managedBean.adicionarSubItemPanel(item)}" update="dtSubItem" title="Clique aqui para adicionar SubItem" icon="fa fa-plus" value="Adicionar" process="@this dtSubItem cadSubItens" iconPos="right" > </p:commandButton> </div> </div> <p:dataTable var="subItem" id="dtSubItem" emptyMessage="Sem registros adicionados" value="#{item.btpResolucaoItemSubitemList}"> ... </p:dataTable> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 javax.faces.FacesException:断言失败 - javax.faces.FacesException: Assertion Failed javax.faces.FacesException:找不到滑块目标组件&#39;txt6; txt7&#39;检视 - javax.faces.FacesException: Cannot find slider target component 'txt6; txt7' in view javax.faces.FacesException:启用选择时,DataModel必须实现org.primefaces.model.SelectableDataModel - javax.faces.FacesException: DataModel must implement org.primefaces.model.SelectableDataModel when selection is enabled javax.faces.FacesException:表达式错误:命名对象:找不到播放器 - javax.faces.FacesException: Expression Error: Named Object: player not found javax.faces.FacesException。 属于Spring Security 3.x的一个例外 - javax.faces.FacesException . It is a exception belongs to Spring Security 3.x javax.faces.FacesException,当用户点击返回时 - javax.faces.FacesException, when user hits return jsf 1.2到jsf 2.2的迁移原因:javax.faces.FacesException - jsf 1.2 to jsf 2.2 migration causes: javax.faces.FacesException javax.faces.FacesException:执行值转换时出错 - javax.faces.FacesException: Error performing conversion of value javax.faces.FacesException:启用选择或定义rowKey属性时,DataModel必须实现org.primefaces.model.SelectableDataModel - javax.faces.FacesException: DataModel must implement org.primefaces.model.SelectableDataModel when selection is enabled or define rowKey attribute javax.faces.FacesException:不能两次添加相同的组件:javascript_runner - javax.faces.FacesException: Cannot add the same component twice: javascript_runner
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM