How to set 'selectedItem' on comboBox as Integer?

asked 2021-10-26 17:15:45 +0800

daniapesteguia gravatar image daniapesteguia
7 2

Hi, I'm having a lot of problems fixing a Integer as value of my selected items. Example:

<combobox id="tipoRestringido" readonly="true" selecteditem="@bind(fx.accessType)"> <comboitem value="0" label="${labels.public}"/> <comboitem value="1" label="${labels.private}"/> </combobox>

I want to have Integer as value for my comboitem but ZK only seems to accept String. I tried making a accessTypeStr setter method and parse to Integer but didn't work since I have to create the attribute, ZK doesn't accept just a Setter apparently. ¿Anyone had to deal with this already with a solution?

delete flag offensive retag edit

2 Answers

Sort by » oldest newest most voted

answered 2021-10-27 11:06:49 +0800

hawk gravatar image hawk
3185 1 5
http://hawkphoenix.blogsp... ZK Team

updated 2021-10-27 11:12:05 +0800

If you check comboitem javadoc, it supports setValue() with an object.

Since you set value with a string : <comboitem value="0"/> ZK will call setValue(String).

You can set a value with an Integer with tag library if you just need to set a fixed integer:

<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
<combobox id="box" onSelect="print()">
    <comboitem value='${c:int(1)}' label="1"/>
    <comboitem value='${c:int(2)}' label="2"/>
public void print(){


<comboitem value='${c:new1("java.lang.Integer", 2)}' label="2"/>


If you use data binding, you can just bind an integer on it

<comboitem value='@init(vm.myInteger)' label="myinteger"/>
link publish delete flag offensive edit


Hi, thanks a lot for your answer, seems to be working properly. ¿With booleans do you think I can do the same? I'm trying to but receiving an error during binding value='${c:new1("java.lang.Boolean", true)}'

daniapesteguia ( 2021-10-27 14:51:29 +0800 )edit
link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools




Asked: 2021-10-26 17:15:45 +0800

Seen: 9 times

Last updated: Oct 28 '21

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More