preselect a radio button based on a value
Vijay Balakrishnan <[email protected]>
| Newsgroups | gmane.comp.java.enhydra.barracuda.general |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I am trying to preselect a radio button based on a value.
<input type="radio" value="A" checked name="allocate">
<input type="radio" name="allocate" value="H">
I always get the the value 'A' even though I have set the value for the node
to H.
Here is how I am setting the BToggleButton in the handleViewEvent:
String allocate = (String)session.getAttribute("allocate");
if (allocate == null) {
allocateSelected = 0;
} else if (allocate.equalsIgnoreCase("H")) {
allocateSelected = 1;
} else {
allocateSelected = 0;
}
Node allocateNode =
allocateNodeList.item(allocateSelected);<==== this has the value of "H" in
it
TemplateView allocateView = new
DefaultTemplateView(allocateNode,"name",
new MapStateMap(modelProps));
bodyTemplate.setView(allocateView);
bodyTemplate.render(new DefaultViewContext(context));
new DefaultDOMWriter().write(page,context.getResponse());
I also have a getItem(String key) : <=== never seems to get in here
if (key.equals("allocate")) {
boolean selA = false;
boolean selH = false;
BToggleButton btbComp = null;
char type = poolDTO.getType();
String typeStr = new Character(type).toString();
if (typeStr != null && typeStr.equalsIgnoreCase("A")) {
selA = true;
} else if (typeStr != null && typeStr.equalsIgnoreCase("H")) {
selH = true;
}
btbComp = new BToggleButton(BInput.RADIO,"allocate","A",selA);
btbComp = new BToggleButton(BInput.RADIO,"allocate","H",selH);
return btbComp;
}
Any help is appreciated or any example on pre-selecting a radio button based
on an input value would be great.
Thanks,
Vijay