• Post Reply Bookmark Topic Watch Topic
  • New Topic

Issue generating unique Ids for radio selection

 
Mary Joe
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using JSF1.1, I have got the following components a radio slection group and an input Text in my page,
The radio has the following 6 options,

Divorced
Living with partner
Married
Separated
Single
Widowed


if only Married option is selected then Only the inputText should be enabled, for all other options it should be disabled, that part is working fine.

If Married is selected and an invalid date is entered in the inputText, it raises validation error,
if the user then selects another option it disables the text field with the data entered but the validation error still arise,
I want to clear out the InpuText field when any other option other than Married is selected, so that the validation error doesn't arise.
I am trying to use javascript to identify which option is checked, the issue is individual radio options doesn't seem to generate any Id
for me to identify which one is checked. Can you please identify the reason. Any help would be much appreciated.
<h:selectOneRadio
id="maritalStatus"
value="#{DetailsPage.maritalStatus}"
valueChangeListener="#{DetailsPage.formatOptionChangeListener}"
style="autowidth"
immediate="true"
required="'false'"
layout="pageDirection"
onclick="submit()"
validationLabel="#{pageMsg.maritalStatusLabel}"
disabled="#{DetailsPage.readOnly}">
<f:selectItems id="statusId" value="#{lea:getEnumSelectItems('my.data.enum.MaritalStatusEnum', 'enum', 'false')}" />
<lea:enumConverter enumClass="my.data.enum.MaritalStatusEnum" />
</h:selectOneRadio>

<td colspan="2">
<label for="marriageDate">#{pageMsg.dateOfMarriageLabel}</label> </td>
<td class="#{DetailsPage.formInputClass}">
<h:inputText value="#{DetailsPage.marriageDate}"
id="marriageDateId"
maxlength="10"
size="12"
disabled="#{DetailsPage.dateReadOnly}">
<lea:dateConverter pattern="dd/MM/yyyy" invalidDateMessage="#{pageMsg.invalidMarriage}" />
</h:inputText>
</td>
 
Tim Holloway
Bartender
Posts: 18412
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's a "Code" button on the JaraRanch message editor. You can use that to wrap formatting tags around samples of code, XML, data, and other stuff that you don't want reformatted. It makes things a lot easier to read.

Without doing something so crass as actually looking, I think that the radio button IDs are subscripted, giving names such as "form1:radiobutton:0", "form1:radiobutton:1" and so forth. You should be able to use that.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!