I am trying to get dropdown list value from form and back to form if someone is updating existing record.. I tried to do this way..
public String getOptionDropDownList()
{
if(getOption().compareTo("Y") == 0)
_ddlOpt开发者_运维知识库ion.setSelectedItem("Y");
else {(getOption().compareTo("N") == 0)
_ddlOption.setSelectedItem("N");
}
return _ddlOption.getHTMLString();
}
but i am getting this error..
compile:
[exec] com\jack\example\SampleBean.java:161: not a statement
[exec] else (getOption().compareTo("N") == 0)
[exec] ^
[exec] com\jack\example\SampleBean.java:162: ';' expected
[exec] _ddlOption.setSelectedItem("N");
[exec] ^
[exec] 2 errors
Can somebody explain to me what I am doing wrong, or is there other way to do this?
ddlOption is declared as new Dropdown getOption holds what is in the database
Not else. You should write
else if (getOption().compareTo("N") == 0) {
_ddlOption.setSelectedItem("N");
}
You should write getOption().equals("N")
instead of getOption().compareTo("N") == 0
it's easier to read.
You seem to have missed the "if" after else
I think you meant do have an else if statement like this one:
else if (getOption().compareTo("N") == 0) {
_ddlOption.setSelectedItem("N");
}
精彩评论