You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Clément Maignien <c....@edic-syliance.com> on 2005/08/19 10:37:10 UTC

RE : FacesException: Could not get property rows of component...

Hi,

It seems quite clear that the first solution (with the new in the getter) you tried wasn't the good one. The second one looks much better ... Don't know why you get an NPE. However you could try to instanciate your HtmlDataTable (make the new) in your bean default constructor and see what happend in this case.

Hope this will help.

Regards,
Clément

-----Message d'origine-----
De : Koloszko Pawel [mailto:pawel.koloszko@atena.pl] 
Envoyé : vendredi 19 août 2005 10:14
À : 'MyFaces Discussion'
Objet : RE: FacesException: Could not get property rows of component...


There is an example in "JavaServer in Action" where binding HtmlDataTable is shown and I can not find there 'new HtmlDataTable()' call or something like that. 

Let's summarize.

I changed my backing bean code to

private HtmlDataTable jsfDataTable;
public HtmlDataTable getJsfDataTable() {
-->	jsfDataTable = new HtmlDataTable();
	return jsfDataTable;
}
public void setJsfDataTable(HtmlDataTable jsfDataTable) {
	this.jsfDataTable = jsfDataTable;
}

No NPE.

Then I changed to 

--> private HtmlDataTable jsfDataTable = new HtmlDataTable();
public HtmlDataTable getJsfDataTable() {
	return jsfDataTable;
}
public void setJsfDataTable(HtmlDataTable jsfDataTable) {
	this.jsfDataTable = jsfDataTable;
}

NPE still exist.

I debuged my very first code (with no 'new HtmlDataTable()' call) and I can see that: When I open page1.jsp, setJsfDataTable is invoked and I receive nice HtmlDataTable object (so why should I call 'new HtmlDataTable()'?). When I open page2.jsp, setJsfDataTable is invoked again and I receive HtmlDataTable object. When I return to page1.jsp, getJsfDataTable is invoked and I can see that jsfDataTable looks quite nice, getJsfDataTable.getRows() returns a value, everything looks OK. And after that I receive exception.

Maybe I do not know something. So could you explain me how to bind datatable object to backing bean properly?

PK

-----Original Message-----
From: Martin Marinschek [mailto:martin.marinschek@gmail.com] 
Sent: Thursday, August 18, 2005 4:22 PM
To: MyFaces Discussion
Subject: Re: FacesException: Could not get property rows of component...

next question: do you ever call 'new HtmlDataTable()'?

it is your responsibility to initialize the components you use for value binding!

regards,

Martin

On 8/18/05, Kołoszko Paweł <pa...@atena.pl> wrote:
> No, with new HtmlDataTable() I do not get NPE. So what does it mean?
> 
> Ps. My backing bean is session scoped.
> 
> PK
> 
> -----Original Message-----
> From: Martin Marinschek [mailto:martin.marinschek@gmail.com]
> Sent: Thursday, August 18, 2005 3:34 PM
> To: MyFaces Discussion
> Subject: Re: FacesException: Could not get property rows of 
> component...
> 
> What happens if in your getJsfDataTable function you call new
> HtmlDataTable() each time?
> 
> do you still get this NPE?
> 
> regards,
> 
> Martin
> 
> On 8/18/05, Kołoszko Paweł <pa...@atena.pl> wrote:
> > One more thing. When binding="#{listRodzajePism.jsfDataTable}" is
> > removed from x:datatable tag, everyhing works just fine.
> >
> > PK
> >
> > -----Original Message-----
> > From: Kołoszko Paweł
> > Sent: Thursday, August 18, 2005 11:20 AM
> > To: users@myfaces.apache.org
> > Subject: FacesException: Could not get property rows of component...
> >
> > MyFaces 1.0.9
> >
> > I have a following problem:
> >
> > I have page.jsp with datatable and a button:
> >
> > <x:dataTable id="listarodzajepism"
value="#{listRodzajePism.rodzajePism}"
> > var="rodzajPisma" border="0"
> >                 styleClass="standardTable" 
> > headerClass="standardTable_SortHeader"
> > rowClasses="standardTable_Row1,standardTable_Row2"
> > footerClass="standardTable_Footer"
> > sortColumn="#{listRodzajePism.sort}"
> > sortAscending="#{listRodzajePism.ascending}"
> >                 preserveDataModel="true"
> >                 preserveSort="true"
> >                 rows="24" binding="#{listRodzajePism.jsfDataTable}">
> >
> > ... column, column, column ...
> > </x:dataTable>
> > <h:commandButton id="cb" value="NewPage" action="newpage"/>
> >
> > Action "newpage" of commandbutton opens page2.jsp with only one 
> > button:
> >
> > <h:commandButton id="button"
> >                 value="Cancel"
> > action="back"
> > immediate="true"/>
> >
> > Action "back" goes back to page.jsp. And here the problem occurs
> > becuase I receive an error:
> >
> > javax.faces.FacesException: Could not get property rows of component
> > rodzajepismview:listarodzajepism Caused by:
java.lang.NullPointerException
> >         at 
> > org.apache.myfaces.component.html.ext.HtmlDataTable.getRows(HtmlData
> > Ta
> > ble.ja
> > va:547)
> >
> > When I open page.jsp everything is OK, but action page.jsp ->
> > page2.jsp -> page.jsp Cause an error.
> >
> > In my backing bean I have:
> >
> >         private HtmlDataTable jsfDataTable;
> >
> >     public HtmlDataTable getJsfDataTable() {
> >         return jsfDataTable;
> >     }
> >
> >     public void setJsfDataTable(HtmlDataTable jsfDataTable) {
> >         this.jsfDataTable = jsfDataTable;
> >     }
> >
> > What can cause this problem? Is it a bug in MyFaces or my fault
> > somewher in my code?
> >
> > PK
> >
> 
> 
> --
> 
> http://www.irian.at
> Your JSF powerhouse -
> JSF Trainings in English and German
> 


-- 

http://www.irian.at
Your JSF powerhouse -
JSF Trainings in English and German