-
FEATURED COMPONENTS
First time here? Check out the FAQ!
asked 2013-02-12 18:31:57 +0800
This post is a wiki. Anyone with karma >100 is welcome to improve it.
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
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!
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...
Asked: 2013-02-12 18:31:57 +0800
Seen: 66 times
Last updated: Feb 13 '13