multiple conditional expression for a textfield

Hi:

I want to have a text field expression like

"if ($V{cars}.equals(new String("BLACK")))
$V{carName}
else if ($V{cars}.equals(new String("RED")))
$V{carMake}"

You can one conditional expression but how can you have multiple conditional expressions for a text field expression.

Thanks,

Sulalith
sulalith's picture
117
Joined: Feb 9 2007 - 12:15am
Last seen: 16 years 7 months ago

4 Answers:

Use nested ternary expressions:

($V{cars}.equals(new String("BLACK")) ? $V{carName} : ($V{cars}.equals(new String("RED")) ?
$V{carMake} : ($V{cars}.equals("blue") ? $V{carModel}) : etc, etc, etc...)
codyjasperForge's picture
Joined: Jun 6 2007 - 3:44am
Last seen: 6 years 5 months ago
Or make three textfiels on the same place and for the first textfield the print when expression:
new Boolean($V{cars}.stringValue == new String("BLACK"))
for the second texftield print when:
new Boolean($V{cars}.stringValue == new String("RED"))
.....
But codyjasperforge his solution is nicer I think :)
mine is easier to understand (I think?)
Post edited by: giroe, at: 2007/07/27 07:15
giroe's picture
999
Joined: Feb 12 2007 - 5:03pm
Last seen: 16 years 7 months ago
Hi:

Thanks. Both solutions works.

Sulalith
sulalith's picture
117
Joined: Feb 9 2007 - 12:15am
Last seen: 16 years 7 months ago
Hi:

Thanks. Both solutions works.

Sulalith
sulalith's picture
117
Joined: Feb 9 2007 - 12:15am
Last seen: 16 years 7 months ago
Feedback
randomness