Error Rendering View[test.xhtml]
java.lang.NullPointerException
at org.primefaces.component.orderlist.OrderListRenderer.encodeOptions(OrderListRenderer.java:149)
at org.primefaces.component.orderlist.OrderListRenderer.encodeList(OrderListRenderer.java:108)
at org.primefaces.component.orderlist.OrderListRenderer.encodeMarkup(OrderListRenderer.java:79)
at org.primefaces.component.orderlist.OrderListRenderer.encodeEnd(OrderListRenderer.java:49)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:519)
at org.apache.myfaces.shared_impl.renderkit.RendererUtils.renderChild(RendererUtils.java:543)
at org.apache.myfaces.shared_impl.renderkit.html.HtmlGridRendererBase.renderChildren(HtmlGridRendererBase.java:315)
at org.apache.myfaces.shared_impl.renderkit.html.HtmlGridRendererBase.encodeEnd(HtmlGridRendererBase.java:150)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:519)
at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:60)
at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:44)
at org.primefaces.component.dialog.DialogRenderer.encodeContent(DialogRenderer.java:174)
at org.primefaces.component.dialog.DialogRenderer.encodeMarkup(DialogRenderer.java:103)
at org.primefaces.component.dialog.DialogRenderer.encodeEnd(DialogRenderer.java:41)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:519)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:626)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:622)
at org.primefaces.component.accordionpanel.AccordionPanelRenderer.encodeEnd(AccordionPanelRenderer.java:60)
@FacesConverter( “contactConverter”) public class ContactConverter实现Converter {
@Override
public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2)
throws ConverterException {
// TODO Auto-generated method stub
TestBean tb= new TestBean();
tb.setName(arg2);
return tb;
}
@Override
public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2)
throws ConverterException {
// TODO Auto-generated method stub
return arg2.toString();
}
我正在使用primefaces orderlist示例。但我面临这个空指针异常。谷歌搜索后我发现这个问题与转换器有关,但我不确定。任何人都可以通过转换器帮助我使用简单的primeface orderlist。
答案 0 :(得分:2)
java.lang.NullPointerException
at org.primefaces.component.orderlist.OrderListRenderer.encodeOptions(OrderListRenderer.java:149)
at org.primefaces.component.orderlist.OrderListRenderer.encodeList(OrderListRenderer.java:108)
来自PrimeFaces 3.4 OrderListRenderer
源代码:
90 protected void encodeList(FacesContext context, OrderList ol) throws IOException {
...
108 encodeOptions(context, ol, (List) ol.getValue());
...
115 }
...
143 @SuppressWarnings("unchecked")
144 protected void encodeOptions(FacesContext context, OrderList old, List model) throws IOException {
145 ResponseWriter writer = context.getResponseWriter();
146 String var = old.getVar();
147 Converter converter = old.getConverter();
148
149 for(Iterator it = model.iterator(); it.hasNext();) {
因此,model
为null
,因此<p:orderList value>
为null
时会发生此异常,因此#{testBean.contacts}
已返回null
。确保它不是null
。请注意,如果在范围内找不到#{testBean}
,也会发生这种情况。