cancel
Showing results for 
Search instead for 
Did you mean: 

check box

Former Member
0 Kudos

hiii,

I have a jdbc query from where i get the value of a field called IS_CHARGEABLE.

The logic is , if the value is "Y", the checkbox shud b ticked, if "N",then unticked, if null, then also unticked.

In the 'checked' property of checkbox i have bound it to the value attribute ischargeable.

my code is :

while(group_rs.next())

{

is_Chargeable =group_rs.getString(1);

}

boolean ischargeable=false;

if(is_Chargeable.equalsIgnoreCase("Y"))

{

ischargeable=true;

wdComponentAPI.getMessageManager().reportSuccess("Y");

}

else if(is_Chargeable.equalsIgnoreCase("N"))

{

ischargeable=false;

}

else if(is_Chargeable.equalsIgnoreCase(null))

else

{

ischargeable=false;

}

goElement.setIsChargeable(ischargeable);

NB : group_rs--> IS the resultset

goElement-->the element of the concerned node.

But in the output i get the check-box unticked under all circumstances....Please do suggest.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

just make sure that is_Chargeable is not null before checking

it into if condition add the below loop.

before ur condition.


if(is_Chargeable!=null)

regards

Surender Dahiya

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi

Just make sure that u have properly bound IsChargeable to ur

checkbox.

regards

Surender Dahiya

Former Member
0 Kudos

Hi ,

Check if you have binded the checked property of the check box to IsChargeable attribute.

you can simplify your coding also .. as your logic is if the value is "Y" checked and if "N" or null unchecked

boolean ischargeable=false;

if(is_Chargeable.equalsIgnoreCase("Y"))

{

ischargeable=true;

wdComponentAPI.getMessageManager().reportSuccess("Y");

}

else

{

ischargeable=false;

}

Regards,

Sunitha Hari

Former Member
0 Kudos

Hi

I see an error in ur code as highlighted below :

else if(is_Chargeable.equalsIgnoreCase(null))

else

{

//code

}

Check if the second else is required.

Regards,

Sudeep

Former Member
0 Kudos

Hi Sudeep,

Else is not required as the value is initialiazed to false.

only if stmt will do .

Thanks,

Sunitha Hari

Former Member
0 Kudos

Hi Sunitha

I was refering Parama's code when I mentioned the changes.

Her code has a unnecessary 'else' mentioned which may be resulting in the error in logic.

thnx,

Sudeep