JSF と Primesfaces に問題があります。次のようなリストを含むフォームがあります。
<h:form>
<h:outputText value="Filtrer par client" for="filtreClient" />
<p:selectOneMenu id="filtreClient" value="#{actionBean.action.codeClient}" effect="fade">
<f:selectItem itemLabel="Sélectionnez" itemValue="" />
<f:selectItems value="#{clientDao.listeClient}" />
</p:selectOneMenu>
</h:form>
これを返しますerror ==>SEVERE: javax.faces.FacesException: Erreur d’argument : le paramètre «text» est null.
(これは、パラメータ「テキスト」がnullであることを意味します)。私が理解していないのは、アプリケーションにパラメーターテキストがなく、どのパラメーターですか? メソッドからのパラメータ?からhttpRequest
?
そのようなエラーを見たことがありますか?
ここに私のスタックトレースがあります:
SEVERE: javax.faces.FacesException: Erreur d’argument : le paramètre «text» est null.
javax.faces.FacesException: Erreur d’argument : le paramètre «text» est null.
at com.sun.faces.context.ExceptionHandlerImpl.handle(ExceptionHandlerImpl.java:142)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:809)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:671)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:505)
at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:476)
at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:355)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:305)
at servlet.Login.doPost(Login.java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NullPointerException: Erreur d’argument : le paramètre «text» est null.
at com.sun.faces.renderkit.html_basic.HtmlResponseWriter.writeText(HtmlResponseWriter.java:877)
at org.primefaces.component.selectonemenu.SelectOneMenuRenderer.encodeOption(SelectOneMenuRenderer.java:368)
at org.primefaces.component.selectonemenu.SelectOneMenuRenderer.encodeSelectItems(SelectOneMenuRenderer.java:333)
at org.primefaces.component.selectonemenu.SelectOneMenuRenderer.encodeInput(SelectOneMenuRenderer.java:114)
at org.primefaces.component.selectonemenu.SelectOneMenuRenderer.encodeMarkup(SelectOneMenuRenderer.java:91)
at org.primefaces.component.selectonemenu.SelectOneMenuRenderer.encodeEnd(SelectOneMenuRenderer.java:65)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1757)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
... 36 more
更新:ClientDao
リストを作成するのは次のとおりです。
public class ClientDao implements IClient, Serializable {
/**
*
*/
private static final long serialVersionUID = 1951697664353493098L;
public static String GET_ALL_CLIENT = "SELECT c.codeClient, c.nom , c.prenom FROM Client c ORDER BY c.name ASC ";
@PersistenceContext(unitName = "dev")
EntityManager em;
private List<SelectItem> listeClient;
private List<Client> resListeClient;
private SelectItem selectItem;
public List<SelectItem> getListeClient() {
try {
EntityManagerFactory emf = null;
emf = Persistence.createEntityManagerFactory("dev");
em = emf.createEntityManager();
Query requete = em.createQuery("SELECT c FROM Client c ORDER BY c.nom ASC");
resListeClient = requete.getResultList();
listeClient = new ArrayList<SelectItem>();
for (Client c : resListeClient) {
if (c.getNom() != null) {
selectItem = new SelectItem();
selectItem.setValue(c.getCodeClient());
selectItem.setLabel(c.getNom() + " " + c.getPrenom());
listeClient.add(selectItem);
}
}
} catch (NoResultException e) {
System.out.println("Aucun client trouvé" + e.getMessage()
+ e.getCause());
} finally {
if (em != null) {
em.close();
}
}
return listeClient;
// return null;
}