Not Going to the Action Method

Hi All,

I was just started learning JSF,as we are going to start a New application in JSF.

i was trying with ListBox.. without the list box.. the ..Action method in the backing bean is getting called.but if include this Listbox its not going into the action method.

its always going into the getCountries() mthod. not to the plant method.

Action Mathod -->{backing_login.plant

JSP Code

<h:selectOneMenu id="selectCountry" value="#{backing_login.currentCountry}">

<f:selectItems value="#{backing_login.countries}" />

</h:selectOneMenu>

</htm:td>

</htm:tr>

<htm:tr>

<htm:td styleClass="dotted bdot" width="20%"><h:commandButton value="hello me" action="#{backing_login.plant}" /></htm:td>

Backing Bean Code

public void setCountries(ArrayList countries) {

this.countries = countries;

}

public ArrayList getCountries()

{

System.out.println("Inside of the getCountries.......--1");

countries = new ArrayList();

countries.add(new SelectItem(new Integer(1), "Select"));

countries.add(new SelectItem(new Integer(2), "USA"));

countries.add(new SelectItem(new Integer(3), "INDIA"));

countries.add(new SelectItem(new Integer(4), "CHINA"));

countries.add(new SelectItem(new Integer(5), "UK"));

return countries;

}

please help me i was really stuck with it not able to go forward.

Thanks in Advance

Susy.

[1509 byte] By [Susy7707a] at [2007-11-27 11:45:51]
# 1

Add <h:messages /> to the code. Big chance that you see a conversion error.

What is the object type of currentCountry? If it is an Integer, then it's OK. But there was a problem with Integers in selectItems in the former versions of JSF. Which version are you using? Upgrade to the most recent version. If I recall correctly this issue was fixed in the _02 builds (1.1_02 and 1.2_02).

By the way, the setCountries() is obsolete. You don't need a setter for non-UIInput values. And you may also populate the countries in a static block instead of on every call of the getter (which is more expensive).

BalusCa at 2007-7-29 18:04:13 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Thanks..a lot..!!!!!my problem got resolved....!!!!!

Susy7707a at 2007-7-29 18:04:13 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

It would be nice if you tell what was the exact cause :)

BalusCa at 2007-7-29 18:04:13 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

Actually..it was the problem.. with the currentcountry i defined it as an String.

Susy7707a at 2007-7-29 18:04:13 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...