I spent some time debugging and here are the results:

Exception is thrown in getRows() method of
org.apache.myfaces.component.html.ext.HtmlDataTable when command 

return ((_SerializableDataModel)_dataModel).getRows();

is invoked. Cause of exception: _dataModel is null. This line is invoked
only when _isDataModelRestored = true. I checked that when I open page2.jsp
_dataModel is created and _isDataModelRestored is set to true. But when I
return to page1.jsp from page2.jsp, setValueBinding method is invoked and
_dataModel is set to null. But _isDataModelRestored is still true. JIRA?

PK

-----Original Message-----
From: Kołoszko Paweł 
Sent: Friday, August 19, 2005 10:14 AM
To: 'MyFaces Discussion'
Subject: 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:[EMAIL PROTECTED]
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ł <[EMAIL PROTECTED]> 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:[EMAIL PROTECTED]
> 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ł <[EMAIL PROTECTED]> 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: [email protected]
> > 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

Reply via email to