PickList in POJO

UI Components for JSF
Post Reply
Sunil
Posts: 47
Joined: 23 Jun 2011, 09:15

10 Sep 2011, 13:22

Hi All,

Can any one help me in solving this problem.

Am using pick list for listing lots which are in DB. when i try to do that it's returning the null pointer Exception or Servlet Exception.
Xhtml:

Code: Select all

<h:body>
      
            <h:form prependId="false" styleClass="panelviewTourneRamassage">
                 <div id="footer1" align="center">
                     <h4> <h:outputText value="#{bundle.CreateRamassagePlanning}"/> </h4>
                 </div>
                <div id="CollectResult_Panel" align="center">
                    <p:panel header="Planning Ramassage" styleClass="Paneldesign_Ramessage">
                        <h:panelGrid columns="2" styleClass="panelview11">
                                <h:outputLabel value="Date de Ramassage" for="currentDate"/>
                                <p:calendar id="currentDate" value="#{simulatorController.currentDate}" pattern="dd/MM/yyyy"
                                            locale="fr" mode="popup" onSelectUpdate="table" immediate="true"/>
                        </h:panelGrid>
                        <p:commandButton update="table" value="Commencer" action="#{simulatorController.getLeslotsCollection}" />
                    </p:panel>
                </div>
                </h:form>
                <br />
                <br />
                <h:form>
                
                <p:pickList value="#{simulatorController.leslotsCollection}" var="leslots" iconOnly="true" effect="bounce"  
                            itemLabel="#{leslots.idLots}"  
                            itemValue="#{leslots}" converter="leslots" 
                    showSourceControls="true" showTargetControls="true">  
        <f:facet name="sourceCaption">Available</f:facet>  
        <f:facet name="targetCaption">Starting</f:facet>  
    </p:pickList>  
          <p:commandButton value="Submit" update="displayLeslots" />
  
        </h:form>
    </h:body>
Error:

Code: Select all

SEVERE: Error Rendering View[/Home.xhtml]
java.lang.NullPointerException
	at org.primefaces.component.picklist.PickListRenderer.encodeMarkup(PickListRenderer.java:90)
	at org.primefaces.component.picklist.PickListRenderer.encodeEnd(PickListRenderer.java:51)
	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1763)
	at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
	at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
	at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:55)
	at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:43)
	at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:57)
	at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:43)
	at org.primefaces.component.outputpanel.OutputPanelRenderer.encodeEnd(OutputPanelRenderer.java:44)
	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1763)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759)
	at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:401)
	at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
	at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:410)
	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1534)
	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 com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
	at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:170)
	at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
	at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
	at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
	at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
	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)
Thanks in Advance

Sunil :|

younes
Posts: 4
Joined: 31 Dec 2010, 23:38

10 Sep 2011, 17:05

Sunil,

Most likely, 'simulatorController.leslotsCollection' is null. Make sure that you allocated a space for it and have initialized it properly.

Cheers.

Younes Ouadi

Sunil
Posts: 47
Joined: 23 Jun 2011, 09:15

13 Sep 2011, 07:14

Younes,

Thanks for your reply, It works normally in ui, but when it comes to pick list it doesn't :(

younes
Posts: 4
Joined: 31 Dec 2010, 23:38

14 Sep 2011, 13:42

Sunil,

Can you give more details? Can you post the Java code?

Cheers

Younes OUadi

Sunil
Posts: 47
Joined: 23 Jun 2011, 09:15

14 Sep 2011, 13:49

Younes,

Sure ! here it is.

Logic:
Main logic of my application is :
1. When i enter a date
2. lots should be listed in picklist by the date as given in input.

Code: Select all

private DualListModel<Leslots> leslotsCollections;

    public SimulatorController() {

        List<Leslots> source = new ArrayList<Leslots>();
        List<Leslots> target = new ArrayList<Leslots>();
        
if(currentDate!=null)
        {
    

       source= leslotsFacade.getLeslotsCollection(currentDate);
}

        leslotsCollections = new DualListModel<Leslots>(source, target);

    }

    public DualListModel<Leslots> getLeslotsCollections() {
        
        return leslotsCollections;
    }

    public void setLeslotsCollections(DualListModel<Leslots> leslotsCollections) {
        this.leslotsCollections = leslotsCollections;
    }

Sunil

faisalgeek
Posts: 29
Joined: 28 Mar 2010, 14:45

16 Sep 2011, 08:28

You should make the default initialization at your first java code line..... just like

private DualListModel<Leslots> leslotsCollections = new new DualListModel<Leslots>(null, null);

OR

private DualListModel<Leslots> leslotsCollections = new new DualListModel<Leslots>(new ArrayList(), new ArrayList());

whichever works for you. I have worked with simple collection(s) where similar problem comes, so solution is to only initialize the collection like
List<String> list = new ArrayList<String>(0);
MyEclipse for Spring 9.0 , Tomcat 6.0, Jboss 6.0, PrimeFaces 3.0.RC2 , Mojarra 2.1.4 (JSF 2.1) - http://www.javaplex.com

Sunil
Posts: 47
Joined: 23 Jun 2011, 09:15

16 Sep 2011, 08:35

Faisal,

I tried like this:

Code: Select all

private DualListModel<Leslots> leslotsCollections = new new DualListModel<Leslots>(new ArrayList(), new ArrayList());
[img]
http://imageshack.us/photo/my-images/20/pick1.png/
[/img]

It remains same. :cry:

Sunil

faisalgeek
Posts: 29
Joined: 28 Mar 2010, 14:45

16 Sep 2011, 23:06

Sunil, please can you paste the full stacktrace... it always help to figure out something.
MyEclipse for Spring 9.0 , Tomcat 6.0, Jboss 6.0, PrimeFaces 3.0.RC2 , Mojarra 2.1.4 (JSF 2.1) - http://www.javaplex.com

yapfa
Posts: 22
Joined: 18 Oct 2011, 11:49

29 Nov 2011, 11:34

Make sure you have both var and itemValue set. This is not entirely clear from the documentation, neither does it mention what itemValue actually is. I consider this to be a serious flaw!

Code: Select all

<p:pickList value="#{foo.bars}" var="bar" itemValue="#{bar}">
..
Only setting var causes above mentioned NullPointerException for me as well.

porthos
Posts: 122
Joined: 09 May 2011, 03:17

29 Nov 2011, 14:39

Sunil may have a different problem. His code at the top has both var and itemValue set.
-------
PrimeFaces 3.4, Glassfish 3.1.2, Mojarra 2.1.6

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 50 guests