[英]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);
}
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.