0

Combobox custom label and value

asked 2013-02-04 06:49:12 +0800

zeroho gravatar image zeroho
16 2

updated 2013-02-04 08:19:31 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

Hi All,

I have a Table A having the following schema: a-id, a-name

public class A{
int id; //get&set methods
String name; //get&set methods
}

and Table B having the following schema: b-id, a-id {a-id is a foreign-key referring Table A}

public class B{
int id; //get&set methods(Foreign Key)
int idB; //get&set methods

}

I have a SQL statement that create a Model List for being used on the webpage:


select * from A left join B on A.a-id = B.a-id;
  • which generates a-id, name, b-id

(aka C)

I created a grid using model as what (C) looks like. And there are 2 columns in the Grid namely:

B-ID,   Name ( aka D)

I would like to create a combobox for column (D) to update a record in Table B; the combobox should looks like:

Label of a-name but use the value with <a-id>

May I ask how to achieve it; is there any relevant small talks / previous thread that I can refer to?

Thanks a lot.

delete flag offensive retag edit

Comments

Didn't get your question very clearly, is it relates to UI or just your domain logic? maybe you should provide a simple one that relate to UI. and you can do the domain logic in the controller

dennis ( 2013-02-08 03:43:01 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-03-05 08:32:08 +0800

benbai gravatar image benbai
2228 6
http://www.zkoss.org

Yes, you can set both label and value to a comboitem and then you can use Combobox.getSelectedItem().getValue() to replace Combobox.getValue()

sample:

<zk>
    <combobox id="cbx">
        <comboitem label="label one" value="value one" />
        <comboitem label="label two" value="value two" />
    </combobox>
    <button label="test">
        <attribute name="onClick"><![CDATA[
            if (cbx.getSelectedItem() != null) {
                System.out.println(cbx.getSelectedItem().getValue());
            } else {
                System.out.println("");
            }
        ]]></attribute>
    </button>
</zk>
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

Follow
1 follower

RSS

Stats

Asked: 2013-02-04 06:49:12 +0800

Seen: 152 times

Last updated: Mar 05 '13

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