Question

I am getting following error while integrating primefaces-extensions dynaform

java.lang.NullPointerException
        at org.primefaces.extensions.component.dynaform.DynaFormRenderer.preRenderLabel(DynaFormRenderer.java:280)
 at org.primefaces.extensions.component.dynaform.DynaFormRenderer.encodeMarkup(DynaFormRenderer.java:99)
        at org.primefaces.extensions.component.dynaform.DynaFormRenderer.encodeEnd(DynaFormRenderer.java:78)
        at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:878)

I have following libraries included in my classpath, as described here

primefaces-3.3.1.jar

primefaces-extensions-0.5.1.jar

commons-lang.jar

Xhtml looks like

<ui:composition template="WEB-INF/templates/base.xhtml"
 xmlns="http://www.w3.org/1999/xhtml"
 xmlns:f="http://java.sun.com/jsf/core"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:ui="http://java.sun.com/jsf/facelets"
 xmlns:p="http://primefaces.org/ui"
 xmlns:pe="http://primefaces.org/ui/extensions">

 <ui:define name="content">
  <pe:dynaForm id="dynaForm" >
  </pe:dynaForm>
 </ui:define>
</ui:composition>

UPDATE:

getting below error after updating some code:

javax.servlet.ServletException: Cannot find component with identifier "_mainForm_dynaFormGroup" referenced from "j_idt7:dynaForm:j_idt14".

what am i missing?

Was it helpful?

Solution

getting below error after updating some code:

javax.servlet.ServletException: Cannot find component with identifier "_mainForm_dynaFormGroup" referenced from "j_idt7:dynaForm:j_idt14".

what am i missing?

As the message states you're referencing an element with the id _mainForm_dynaFormGroup. This element can not be found. A common cause for this problem is that this element is in a form or some other container which prefixes the element id with the id of the container.

For example having this JSF:

<h:form id="form">
    <div id="div" ...
</h:form>

Will generate this HTML:

<form id="form">
    <div id="form:div" ...
</form>

When referencing elements in another container you need to start referencing at the root using a : as a prefix.

<h:form id="buttonForm">
    <p:button id="button" ...
</h:form>
<h:form>
    <p:button update=":buttonForm:button" ...
</h:form>

OTHER TIPS

You have to add the following into your web.xml to use _ instead of default : for widget matching:

  <context-param>
      <param-name>javax.faces.SEPARATOR_CHAR</param-name>
      <param-value>_</param-value>
  </context-param>

also you have to make sure that widget you are doing lookup for reside inside given form name.

Here is a straight forward answer which beginners may find it easy. according to your exception "javax.servlet.ServletException: Cannot find component with identifier "_mainForm_dynaFormGroup" referenced from "j_idt7:dynaForm:j_idt14"" you are referring _mainForm_dynaFormGroup from dynaForm instead of dynaFormGroup because your dynaform is not inside any container.

Here is one more example Cannot find component with identifier "_mainForm_dynaFormGroup" referenced from "A4759:projectTab:dynaForm:j_idt581". Here I am referring _mainForm_dynaFormGroup from _projectTab_dynaForm insted of _mainForm_dynaForm it has to be _projectTab_dynaFormGroup. Reason behind this is well explained above by @siebz0r.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top