が返されます。リストを返すマネージドBeanメソッドを呼び出すと、なぜNPEを取得するのですか?私は私のビューでprimefacesウィザードコンポーネントを使用しています。マネージドBeanメソッドを呼び出すと、NPE
動作しません:
public List<RequiredParam> getRequiredFields() {
if(!this.sdeCommand.getActions().isEmpty() &&this.action!=null &&!this.action.equals("")){
for(CommandAction act:this.sdeCommand.getCommandActions()){
if(act.getActionName().equalsIgnoreCase(this.action)){
this.requiredFields.addAll(act.getFields());
}
}
}
return this.requiredFields;
}
しかし、この作品:
public List<RequiredParam> getRequiredFields() {
return this.requiredFields;
}
ビュー:
<c:forEach items="${gdsiGeodataBean.requiredFields}" var="reqs">
<h:outputLabel for="#{reqs.name}" value="#{reqs.name}:* " />
</c:forEach>
エラーメッセージを例えばsometoneは、これら二つの違いが私に語ったことができます:
java.lang.NullPointerException
com.tsystems.appbeans.GdsiGeodataBean.getRequiredFields(GdsiGeodataBean.java:103)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
org.apache.el.parser.AstValue.getValue(AstValue.java:118)
...
私の見解:getActions()
リターンがnullの場合
明らかに、あなたのbeanのプロパティのいくつかは 'null'です。 'List'プロパティが正しくインスタンス化されているかどうかを慎重にチェックしてください。 –
@ Mr.J4mes、プロパティの中の1つがnullでした。私はウィザードを使用しています。以前のタブでプロパティをバインドしました。どういうわけかその物件は価値を失った。 – algone