У меня есть таблица HTML
на моей странице, и я пытаюсь заполнить ее некоторыми данными из моего управляемого компонента, моя страница xhtml
выглядит следующим образом:
<ice:panelGrid columns="2">
<ice:panelGrid>
<ice:outputText value="Properties:" style="text-align:left;font-size:20px;"></ice:outputText>
<ice:selectManyListbox id="CriteriaListbox" style="width: 200px; height: 250px; " partialSubmit="true">
<p:selectItem value="#{beanInfo.properties}"/>
</ice:selectManyListbox>
</ice:panelGrid>
</ice:panelGrid>
Мой управляемый компонент выглядит следующим образом:
public ArrayList<String> getProperties()
{
return properties;
}
и в конструкторе я заполняю properties
как показано:
public BeanInfo(){
createProperties();
}
createProperties(){
ArrayList<String> properties = new ArrayList<String>();
properties.add("roi");
properties.add("val");
}
Я новичок в jsf
и icefaces
и поэтому не уверен, в чем здесь проблема.Есть предложения?
Обновление
Так что в моей таблице ничего нет, но я получаю java.util.ArrayList cannot be cast to javaax.faces.model.SelectItem
исключение.
Обновление 2
Это исключение, которое я получаю после подхода Никиты и обновляю мою JSF
версию с Mojarra-2.0.3
до Mojarra-2.1.7
, какие-либо предложения.
Error Rendering View[/admin/Template.xhtml]: java.lang.ClassCastException: java.lang.String cannot be cast to javax.faces.model.SelectItem
at com.icesoft.faces.renderkit.dom_html_basic.MenuRenderer.countSelectOptionsRecursive(MenuRenderer.java:440) [:]
at com.icesoft.faces.renderkit.dom_html_basic.MenuRenderer.renderSelect(MenuRenderer.java:366) [:]
at com.icesoft.faces.renderkit.dom_html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:108) [:]
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875) [:2.1.7-SNAPSHOT]
at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:359) [:]
at com.icesoft.faces.renderkit.dom_html_basic.GridRenderer.encodeChildren(GridRenderer.java:197) [:]
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845) [:2.1.7-SNAPSHOT]
at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:347) [:]
at com.icesoft.faces.renderkit.dom_html_basic.GridRenderer.encodeChildren(GridRenderer.java:197) [:]
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845) [:2.1.7-SNAPSHOT]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779) [:2.1.7-SNAPSHOT]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782) [:2.1.7-SNAPSHOT]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782) [:2.1.7-SNAPSHOT]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782) [:2.1.7-SNAPSHOT]
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402) [:2.1.7-SNAPSHOT]
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125) [:2.1.7-SNAPSHOT]
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121) [:2.1.7-SNAPSHOT]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [:2.1.7-SNAPSHOT]
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [:2.1.7-SNAPSHOT]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) [:2.1.7-SNAPSHOT]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324) [:6.0.0.Final]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]
Обновление 3: текущий xhtml
<ice:panelGrid columns="2">
<ice:panelGrid>
<ice:outputText value="Properties:" style="text-align:left;font-size:20px;"></ice:outputText>
<ice:selectManyListbox id="CriteriaListbox" style="width: 200px; height: 250px; " partialSubmit="true">
<p:selectItems value="#{bookBeanInfo.properties}"
var="property"
itemValue="#{property}"
itemLabel="#{property}"/>
</ice:selectManyListbox>
</ice:panelGrid>
<ice:panelGrid>
<ice:outputText value="Name:" style="text-align:left;font-size:20px;" id="bookName"></ice:outputText>
</ice:panelGrid>
<ice:panelGrid>
<ice:inputText id="NameInputText" style="width: 195px;" value="#{bookBeanInfo.bookName}"></ice:inputText>
</ice:panelGrid>
Обновление 4: объявление пространства имен
html xmlns="http://www.w3.org/1999/xhtml"
xmlns:icecore="http://www.icefaces.org/icefaces/core"
xmlns:ice="http://www.icesoft.com/icefaces/component"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:ace="http://www.icefaces.org/icefaces/components"
xmlns:p="http://java.sun.com/jsf/core"
xmlns:ice-cc="http://www.icesoft.com/icefaces-composite-comps">
Update5
Мне удалось исправить исключение, используя список массивов типов SelectItem, а не String, поэтому в моем bean-компоненте:
createProperties(){
ArrayList<SelectItem> properties = new ArrayList<SelectItem>();
properties.add(new SelectItem("roi", "roi"));
properties.add(new SelectItem("val"."val"));
}
и на моей xhtml
странице я должен использовать selectItems
вместо selectItem
, так как на моей странице xhtml я ожидаю сбора, поэтому необходимо использовать selectItems
для их перебора:
<ice:panelGrid columns="2">
<ice:panelGrid>
<ice:outputText value="Properties:" style="text-align:left;font-size:20px;"></ice:outputText>
<ice:selectManyListbox id="CriteriaListbox" style="width: 200px; height: 250px; " partialSubmit="true">
<p:selectItems value="#{beanInfo.properties}"/>
</ice:selectManyListbox>
</ice:panelGrid>
</ice:panelGrid>