1
votes

I need your help .

i am developing a simple project with jsf2.0 and primefaces 3.2.

I have 2 pages first is the page1.xhtml whci contains :

        <p:column>
            <p:panel header="#{ct.coTypeName}" >
                <h:panelGrid columns="1" width="100" height="100">
                    <h:outputText value="#{ct.coTypeId}" />




                    <p:commandLink       action="distributer/distributersList.xhtml">
                        <h:graphicImage  url="/resources/images/homePagecartoonBusinessMan.jpg" width="100" height="100"/>
                        <f:param name="bt" value="dist" />
                        <f:param name="ti" value="#{ct.coTypeId}" />
                    </p:commandLink>

                </h:panelGrid>
            </p:panel>

        </p:column>

    </p:dataGrid>

When i press The command link it forwarded me to another page "distributer/distributersList.xhtml" which have a selectOneMenu which doesn't show its items until i refresh the page manually that happens only with IE "i am using internet explorer 8" but this issue doesn't happen with chrome or firefox .

i get javascript error ..Webpage error details

Message: Object expected
Line: 19
Char: 1
Code: 0
URI: http://localhost:8089/pro/



Message: Object doesn't support this property or method
Line: 1
Char: 5500
Code: 0
URI: http://localhost:8089/pro/faces/javax.faces.resource/primefaces.js?          ln=primefaces&v=3.2

the selectonemenucode is :

<p:selectOneMenu value="#{bussinessOwnersViewerMB.selectedCity}" effect="fold" immediate="true"> 

            <f:selectItems value="#{bussinessOwnersViewerMB.cities}" var="city" itemLabel="#{city.cityName}" itemValue="#{city.cityId}"/>  


         </p:selectOneMenu>

the getter for the cities arraylist is :

public ArrayList<CityDto> getCities() {
    cities = cb.laodAllCities();
    System.out.println(">>>>"+cities.size());
        return cities;
}

and the system.out.. give me the message with the arraylist size correctly but the dropdownList items doesn't appear until i refresh the page !

2

2 Answers

0
votes

If you used f:selectItems tag, you don't need itemLabel and itemValue tags. These tags will need when you use f:selectItem without 's'.Try this sample

     <f:selectItems value="#{bussinessOwnersViewerMB.cityList}" var="city">

Here is the sample method for getting cities

     List<SelectItem> cityList = new ArrayList<SelectItem>();
        for (City city : cities) {
            SelectItem item = new SelectItem();
            item.setLabel(city.getCityName());
            item.setValue(city.getCityId());
            cityList.add(item);
     }

Bind you f:selectItems value with cityList(check the above)that changed original cities list.

0
votes

elgohary do one thing dear take one boolean variable like isLoaded and put below code in Lode method

`

    if (isLoaded)
    {
        return;
    }
    isLoaded = true;

` and where you need to refresh page int that operation please do below

isLoaded=false;