Search code examples
jsf-2primefacesprimefaces-extensions

Trouble Using Dynaform of primefaces extensions - jSF


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?


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>