[jsf] Populate property of type 'int' with <f:selectItem> tag

C

Christoph Dahlen

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hi,

I cannot figure out how to populate a managed bean's property of type
int with a <f:selectItem> tag inside a <h:selectOneListbox>. Here's some
code:

Managed-Bean:

package test;
public class Bean {
private int value;
public void setValue(int value) {
this.value = value;
}
public int getValue() {
return this.value;
}
}

faces-config:

<managed-bean>
<managed-bean-name>bean</managed-bean-name>
<managed-bean-class>test.Bean</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
</managed-bean>

JSF:

<h:selectOneListbox value="#{bean.value}" size="1">
<f:selectItem itemValue="2" itemLabel="2" />
<f:selectItem itemValue="3" itemLabel="3" />
<f:selectItem itemValue="4" itemLabel="4" />
</h:selectOneListbox>

Result: "Validierungs-Fehler: Wert nicht göltig." (reads: Validation
error, invalid value).

Where is my mistake or is it just impossible to populate none-String
properties using static selectItem elements?

Cheers,

Christoph
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFDn0fX94TMRoWcFYRAmc8AJ9Mon/tuYg+7ZWAPibEt5cPI/u7qgCgtDhv
NCkJkhXoa7ajr4d0+MHGLak=
=IK/Z
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top