1

This is a related (and or follow up) issue to :

Event Function called before Setter

So Given i have :

<Td>
<h:selectOneMenu id="combocarList" 
value="#{customerBean.selectedcar}"
styleClass="comboStyle"
valueChangeListener="#{customerBean.loadothercombos}"
onchange="document.forms[0].submit()"
>
<f:selectItem
    itemLabel="-----------Select--------------"
    itemValue="None" />
<f:selectItems value="#{customerBean.carsList}" />
</h:selectOneMenu>
</Td>

the event is called when user selects an item from dropdown list and the backbean does the processing to retrieve values of other dropdown list which works ok , BUT i also have a h:datatable which is the problem. The values won't show.

the datatable is defined as:

<h:dataTable
    id="calDetails" rowClasses="oddrow,evenrow"
    headerClass="thHeading" var="car"
    value="#{cardetails.allinfo}">
    <h:column>
        <f:facet name="header">
            <h:outputText id="lblCode" value="Code"></h:outputText>
        </f:facet>
        <h:inputHidden value="#{car.code}"></h:inputHidden>
        <h:outputText id="carcodeid"
            value="#{car.code}"></h:outputText>
    </h:column>
    <h:column>
        <f:facet name="header">
            <h:outputText id="lblCode" value="Sold"></h:outputText>
        </f:facet>
        <h:inputHidden value="#{car.sales}"></h:inputHidden>
        <h:outputText id="carsalesid"
            value="#{car.sales}"></h:outputText>
    </h:column>
</h:dataTable>

i have setter and getters for cardetails.allinfo and i know when document.forms[0].submit() is called cardetails.allinfo is not null since as i tested it using

 <h:outputText value="#{cardetails.allinfo eq null}" />

which returned false. I've been starring at it for hours and can't see my fault. would appreciate any input. Thanks

Community
  • 1
  • 1
ke3pup
  • 1,835
  • 4
  • 36
  • 66

1 Answers1

2

Apparently the list is just empty. A better debug is

<h:outputText value="#{not empty cardetails.allinfo}" />

This will show true whenever the allinfo is not null and not empty. You could also do

<h:outputText value="#{cardetails.allinfo}" />

to see all list items in plain text as represented by ArrayList#toString(). If you see [] then it's indeed empty. Otherwise if you see [com.example.Car@1234,com.example.Car@5678], then it has 2 Car items (assuming that you didn't override its toString() method to return a more human readable String representation as many starters do ;) ).

In case of an empty list, you'd need to debug and fix your list loading logic from the DB.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thanks for the reply. I tried what you suggested and put `` which prints true so all good there, as well as `` which prints a few of `[com.example.Car@1234,com.example.Car@xxxx]` and i also put in `` which print the first code correctly so the ArrayList that containts all the values is good. but when in the `h:datatable` no data is shown! – ke3pup Oct 11 '11 at 22:51
  • I also tried putting `` under the first `h:column` removing all other columns to see if that'll show something and nothing still. Any suggestions? – ke3pup Oct 11 '11 at 22:51
  • Even if i put some dummy value like ` ` i don't see the TEST under the column! :( – ke3pup Oct 11 '11 at 22:56
  • Rightclick page in browser, *View Source*, what do you see in place where you expect the ``? Nothing? Or a table with empty rows and/or cells?
    – BalusC Oct 11 '11 at 23:26
  • I recreated the h:datatable and now i'm able to see the values as expected. Thanks for your support BalusC – ke3pup Oct 12 '11 at 02:19