0

Radiogroup: problem with radio value="true"

asked 2013-02-12 18:31:57 +0800

this post is marked as community wiki

This post is a wiki. Anyone with karma >100 is welcome to improve it.

updated 2013-02-12 18:31:57 +0800

lramellavotta gravatar image lramellavotta flag of Italy
200 1 8

Hello, I have a simple form with radiogroup

                        <row>
                        Tipo 
                        <hbox>
                            <radiogroup id="chkTipoUtente" selectedItem="@bind(gbD.tipo)">
                                <radio label="Amministratore" value="A"/>
                                <radio label="Utente"         value="U"/>
                            </radiogroup>
                        </hbox>
                    </row>
                    <row>
                        Abilitato
                        <hbox>
                            <radiogroup id="chkUtente_attivo" selectedItem="@bind(gbD.abilitato)">
                                <radio label="Abilitato"     value = "true"   />
                                <radio label="Non abilitato" value = "false"  />
                            </radiogroup>
                            <label value="@load(gbD.abilitato)" />
                        </hbox>
                    </row>

The first radiogroup works fine. The chkUtente_attivo don't work. The value of gbD.abilitato is "true" or "false" (MySQL bit field).

Any idea?

Thanks Luca

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2013-02-13 00:34:14 +0800

spitghost gravatar image spitghost
1

Hey Luca,

By binding a selected item you'll have a variable with the type of the object that is represented by the selected item. Following the example that you placed above for you probably have a String that contains the value, but in your specific case I'm not sure if the bind is made to a boolean. Have you tried to change the value to anything but true/false? Try to create a String variable and bind it, to do the conversion from your binded variable to that boolan value make a Boolean.getValue(<your variable>) ir order to obtain your desired result.

Hope it helps!

link publish delete flag offensive edit
0

answered 2013-02-13 05:48:47 +0800

Matze2 gravatar image Matze2
773 7

updated 2013-02-13 05:49:49 +0800

At least with 6.0.x, the built-in converter does not cast the ViewModel value to String.

You can keep your variable internally as boolean, but your getter/setter methods must mimic String like this:

private boolean abilitato;
...
public String getAbilitato() {
    return String.valueOf(abilitato);
}
public void setAbilitato(String abilitatoStr) {
    this.abilitato = Boolean.parseBoolean(abilitatoStr);
}

Maybe a candidate for a feature request...

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
2 followers

RSS

Stats

Asked: 2013-02-12 18:31:57 +0800

Seen: 66 times

Last updated: Feb 13 '13

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