Assign values dynamically to radio button

I am creating an online test. I will need to display answer choices from the table. I created radio buttons for these answer choices and I could put the labels dynamically by using      
Set_Radio_Button_Property('block_name.radio_group_name', 'radio_button1',LABEL,cursor_name.field_name);
Now I have problem to set radio button values dynamically. Should I use when_radio_changed event?
Any help would be appreciated.

I really appreciate your help.
My intention is to display the test on the screen.
That means I need to display all questions and answer
choices for each one dynamically. Based on the answer
choice type (radio button or checkbox or drop down
etc) I will need to assign the values to them and
display on the screen. So far I could display
questions and answer choices on the screen and set
the label property for each radio button.
Do you know what is the syntax to assign value to
each radio button? First I will need to store user's
answers in a table. For that I need to know what
answer they selected. I wasn't sure how to do that.
ThanksAs I said, the values cannot be assigned dynamically. Thus you will store the answers in code (perhaps in an array?) and your radio buttons will be 1,2,3,4 etc.
In WHEN-RADIO-CHANGED you can retrieve the value from the array using the radio button value. Then store that value.
e.g. Your screen shows
What is the sound of one hand clapping?
o Blue
o Yes
o 12
These labels will be set dynamically, but the values for the radio buttons will be 1,2,3. If they pick "Yes", your radio button will be 2. You then get the value you really want from answer_array(2), where you put it when you retrieved the question details. Then you insert that into your users_answers table.

Similar Messages

  • Using an array to assign values to 36 radio buttons

    Okay, here's another doozy for y'all.
    As some of you know, I'm trying to create a character creation program for D&D. When we roll ability scores, we roll 3 sets of 6 rolls, rolling 4 six-sided dice, rerolling 1s and dropping the lowest number, then add the highest 3 rolled numbers together.
    Great! Got that part done!
    The next thing I'm having some issues with is transferring those numbers to radio button text property. What I have done is created a form that has the rolled values in listboxes so the user can see what was rolled. They can only choose one "set"
    of rolls, so each set of 6 rolls is in a separate listbox. I can get the values from the listbox to an array, but I can't figure out how to get the values from an array to the radio buttons on the next form in the program.
    The next form in the program has 6 group boxes, each labeled with a different ability score name (ie: Strength, Dexterity, etc.). Also in each group box are 6 radio buttons. Each radio button in each group box needs to have the same values. For example,
    the first listed radio button in each group box needs to have the first value listed in the list box on the previous page. The second listed radio button in each group box needs to have the second value listed in the list box, and so on. I want it
    to automatically load, but I'll settle for ANY load at the moment!
    The other thing is that I don't want to write 36 lines of code for each group box's radio buttons! I would like to be able to populate the values with a loop. So, the biggest question is how to create an array containing all 36 radio buttons, then assign
    my list box values to them according to their position in the multidimensional array.
    Here is a tidbit so you'll have an idea what I'm looking at.
    list box 1 has values 17, 18, 8, 12, 15, and 13. I want the radio buttons in each group box on the second form to be 17 for the 1st radio button, 18 for the 2nd radio button, 8 for the 3rd radio button, 12 for the 4th radio button, 15 for the 5th radio
    button, and 13 for the 6th radio button.
    Any ideas?

    The array of radio buttons:
    radGr1_1
    radGr1_2
    radGr1_3
    radGr1_4
    radGr1_5
    radGr1_6
    radGr2_1
    radGr2_2
    radGr2_3
    radGr2_4
    radGr2_5
    radGr2_6
    radGr3_1
    radGr3_2
    radGr3_3
    radGr3_4
    radGr3_5
    radGr3_6
    radGr4_1
    radGr4_2
    radGr4_3
    radGr4_4
    radGr4_5
    radGr4_6
    radGr5_1
    radGr5_2
    radGr5_3
    radGr5_4
    radGr5_5
    radGr5_6
    radGr6_1
    radGr6_2
    radGr6_3
    radGr6_4
    radGr6_5
    radGr6_6
    Those listed with “radGr1” are in the first group box labeled grpST, “radGr2” are in the second group box labeled grpDX, and so on (grpCN, grpIQ, grpWS, grpCH). What I want the code to do is change the labels of the radio buttons so that the text displayed
    in everything with a suffix of “_1” is filled with the first number in the selected listbox. For example, if I select the first list box, the other 2 are cleared and only the 6 numbers in the first one are used for the rest of the program. If those numbers
    are 12, 13, 14, 15, 17, and 11, then everything with _1 at the end should have “12”, everything with _2 should have “13”, and so on. What I don’t want to have to do is initialize 36 elements, then have 6 different selections for each group box. I tried to
    attach an image, but it wouldn’t let me…something about verifying my account or something…
    Can I suggest a different layout?  It seems like the status selection process is over-complicating the code... please consider this form layout:
    Once the user has selected the set of rolls they want you use, you can then just work with that single listbox.  The radio buttons let them select a particular stat and the listbox lets them select a value.  The "<-" button then assigns
    the selected value to the selected stat, and removes it from the listbox.  The "->" button clears the selected stat and returns the value to the listbox.  The code is something like:
    Public Class Form1
    Private Sub SetButton_Click(sender As Object, e As EventArgs) Handles SetButton.Click
    If ChosenRollsListBox.SelectedIndex > -1 Then
    Select Case True
    Case StrRadioButton.Checked
    If Not StrLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(StrLabel.Text)
    End If
    StrLabel.Text = ChosenRollsListBox.SelectedItem.ToString
    ChosenRollsListBox.Items.RemoveAt(ChosenRollsListBox.SelectedIndex)
    Case DexRadioButton.Checked
    If Not DexLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(DexLabel.Text)
    End If
    DexLabel.Text = ChosenRollsListBox.SelectedItem.ToString
    ChosenRollsListBox.Items.RemoveAt(ChosenRollsListBox.SelectedIndex)
    Case ConRadioButton.Checked
    If Not ConLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(ConLabel.Text)
    End If
    ConLabel.Text = ChosenRollsListBox.SelectedItem.ToString
    ChosenRollsListBox.Items.RemoveAt(ChosenRollsListBox.SelectedIndex)
    Case IntRadioButton.Checked
    If Not IntLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(IntLabel.Text)
    End If
    IntLabel.Text = ChosenRollsListBox.SelectedItem.ToString
    ChosenRollsListBox.Items.RemoveAt(ChosenRollsListBox.SelectedIndex)
    Case WisRadioButton.Checked
    If Not WisLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(WisLabel.Text)
    End If
    WisLabel.Text = ChosenRollsListBox.SelectedItem.ToString
    ChosenRollsListBox.Items.RemoveAt(ChosenRollsListBox.SelectedIndex)
    Case ChaRadioButton.Checked
    If Not ChaLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(ChaLabel.Text)
    End If
    ChaLabel.Text = ChosenRollsListBox.SelectedItem.ToString
    ChosenRollsListBox.Items.RemoveAt(ChosenRollsListBox.SelectedIndex)
    End Select
    End If
    End Sub
    Private Sub ClearButton_Click(sender As Object, e As EventArgs) Handles ClearButton.Click
    Select Case True
    Case StrRadioButton.Checked
    If Not StrLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(StrLabel.Text)
    StrLabel.Text = "_"
    End If
    Case DexRadioButton.Checked
    If Not DexLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(DexLabel.Text)
    DexLabel.Text = "_"
    End If
    Case ConRadioButton.Checked
    If Not ConLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(ConLabel.Text)
    ConLabel.Text = "_"
    End If
    Case IntRadioButton.Checked
    If Not IntLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(IntLabel.Text)
    IntLabel.Text = "_"
    End If
    Case WisRadioButton.Checked
    If Not WisLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(WisLabel.Text)
    WisLabel.Text = "_"
    End If
    Case ChaRadioButton.Checked
    If Not ChaLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(ChaLabel.Text)
    ChaLabel.Text = "_"
    End If
    End Select
    End Sub
    End Class
    This may not suit your requirements but I thought it was at least worth considering an alternate design that would be much easier to implement.
    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

  • How to set the value of an radio button using set_radio_button_property

    I'd like to set the value of an radio button dynamically, depending of the situation.
    (=> the value which the object returns to the radio group)
    Means: the 'radio button value' of my object 'rb_1' shall be 1, in other circumstances 99 and so on.
    Is it possible to set this value at runtime ?

    the problem is as Gerd wrote:
    there are two or more radio buttons in an option group.
    Their value depends on the text objext t_field.
    If t_field is "car" the value of radio button 1 shall be 75, button 2: 90 and button 3 115.
    if t_field is "bus" the value of radio button 1 shall be 250, button 2: 275 and button 3 300 and so on.
    My problem is to set the value of the radio buttons at runtime after choosing/typing the value of the text field t_field.
    Message was edited by:
    PatrickM

  • Set a default value for a radio button populated with a List of value

    Hi,
    I am using jdeveloper 11.1.1.3.0. I need to set a default value for a radio button populated with a List of value(Yes/No). Here's the selectonechoice code.
    <af:selectOneRadio value="#{bindings.Code.inputValue}"
    label="#{bindings.Code.label}"
    required="#{bindings.Code.hints.mandatory}"
    shortDesc="#{bindings.Code.hints.tooltip}"
    id="sor1" autoSubmit="true"
    valuePassThru="true" layout="horizontal">
    <f:selectItems value="#{bindings.Code.items}" id="si1"/>
    </af:selectOneRadio>
    I want to have the selectonechoice set to No by default. In the previous versions, I set the default value in the base attribute VO. But it is not working in the new version.
    Thanks

    Hi,
    this should work in JDeveloper 11.1.1.3 the same as in 11.1.1.2. If it doesn't then it is better to file a bug than to work around it
    Frank

  • Assigning values dynamically to drop down

    Hi,
    I have drop down for which i have to assign values dynamically, I am getting values as a form of Array list.

    Hi Venki,
    Say your ArrayList is al . Create a value attribute under the root node. Say test. Bind this test to the DropdownByKey UI element. You can populate test attribute like this.
    IWDAttributeInfo attributeInfo =
    wdContext.getNodeInfo().getAttribute(IPrivate<viewname>View.IContextElement.TEST);
    ISimpleTypeModifiable valuesType =
    attributeInfo.getModifiableSimpleType();
    IModifiableSimpleValueSet VS=
    valuesType.getSVServices().getModifiableSimpleValueSet();
           for (int i = 0; i < al.size(); i++) {
              VS.put(al.get(i),""+al.get(i));
    Regards
    Siva

  • Is it possible to assign a value to a radio button or checkbox?

    I would like to assign radio buttons or checkboxes a value and then have the results of the buttons selected tabulated at the end of a form, if desired. Is that possible? Thanks

    Thanks for your reply and help. I appreciate it. I was able to get an export value added to the check box, but did not see and option for a radio button. But the check box works fine for now. Thanks again.

  • Using a dropdown box to change the specified value of a radio button?

    I have a form that generates the body text for an email.
    First there is a dropdown box in which the choices are either "red" or "blue"
    Further down the page, there is a radiobutton list with 2 items "available" and "unavailable".
    The specified values for these items (as defined on the binding tab) are "have blue hats" or "do not have blue hats".
    This value is concatenated in the email body textfield which is to be copied by the user to an email body:
    Concat("Dear", NameField, "," We ", RadioButtonList, " today. ")  // Dear Persons Name, We have blue hats today.
    Is there any way to change the value of the selected radio button based on the selected dropdown choice?
    So if the user selected "red" in the dropdown field, the radio button values could become  "have red hats" or "do not have red hats"?
    Or perhaps there is a better way from the start?
    Thanks!

    Ok, so now I've done that...
    But is there a way to change that value with another field (ie when a user chooses "red" or "blue" in a dropdown box) so that the concatenated message reflects both the users choice of color and the availibility?
    I'm guessing I should probably use an intermediary text box and put
    InterText.rawValue = Concat ("We have ', dropdown1, " hats today") in the change event of the available radio button and:
    InterText.rawValue = Concat ("We do not have ', dropdown1, " hats today") in the change event of the unavailable radio button.
    then concatenate that box in the final textbox.

  • Adding function code dynamically for radio buttons

    Hi Experts,
             I have two  radio buttons in standard screen which when clicked my custom logic should be executed.
    The issue here is the standard screen radio button does not have a Fcode assigned in the field properties because of this no event is triggered when the radio button is selected.
    Thank You,
    Anupama.

    Hi anu,
         Try the following procedure,
    - Combine all the radio buttons into a group. T
    - Create a common function code for all the radio buttons. F
    - Assign all the radio buttons to the same modification group. F
    - Enclose all entire radio button in a frame. F
    Also check the website it help u as u need,
    [http://help.sap.com/saphelp_nw04/Helpdata/EN/3d/c3b23782a9cc68e10000009b38f8cf/content.htm]
    Hope it helps u....
    Regards,
    Annevit

  • How to get the value assigned in dropdowmlistbox as well as radio button

    Hi Everybody,
       Please help me to find the solution for the following:
       1. How to get the value assigned in dropdowmlistbox?
       2. How to get the value assigned in radio button?
      I am waiting for the answer and reply...
      Thanks & Regards,
      ShanthaKumar.KA.

    The radio button has a name attribute. That name attribute should be the same as the bean property. Then you just need a
    <jsp:setProperty name="mybean" property="*"/>
    and the bean's set method will be called for the value of that radio button.
    so...
    <input type="radio" name="doit"/>
    class MyBean
    public void setDoit( boolean yes )
    //do whatever here
    }

  • Setting/Clearing Dynamic Radio Button values

    Hi, i have the following Radio buttons defined within an iteration
    <c:forEach items="${searchresults}" var="post" varStatus="status">                                        
         <tr class = "text_results"> 
              <c:url value="/searchposts.do" var="url">
                   <c:param name="postitle" value="${post.postId.postTitle.title}"/>
                   <c:param name="postcode" value="${post.postId.postTitle.code}"/>                    
                   <c:param name="unitcode" value="${post.postId.units.unitCode}"/>
                   <c:param name="auth" value="${post.postId.auth}"/>
              </c:url>
              <td>
                   <a href='<c:out value = "${url}" />'>                                        
                   <c:out value="${post.postId.postTitle.title}"></c:out></a>
              </td>
              <td><c:out value = "${post.mustering}"/></td>  
              <td><c:out value = "${post.rank}"/></td>  
              <td>
                   <html:radio property="incmbt" 
                        value='${post.postId.postTitle.title}'>
                   </html:radio>                                             
                   <a href = "javascript:unCheckRadio(document.searchForm.incmbt)">
                        clear
                   </a>
              </td>                                             
         </tr> 
    </c:forEach>  The property "incmbt" is declared as a form property (String incmbt) with its getters and setters ... i plan to set each radio button with a value from database within an object called post. The actual value to set for each radio is a post title ... I seem to be getting a NULL value when i try to get the value in action class (form.getIncmbt() yields null) ... Am i assigning the value correctly?
    Further, here's is how i clear the values which seems to work
    Javascript
    function unCheckRadio(btngrp) {     
         for(var i=0; i < btngrp.length; i++)
              if( btngrp.checked == true ) {
                   btngrp[i].checked = false;
                   document.write("Selected Radio is :" + btngrp[i].value);
    But the "Selected Radio is :" displays "${post.postId.postTitle.title}", not the actual post title... ???

    I just thought about this quickly, i think its because an href link does not submit form values ... If so, how can i submit the value of a radio button through the <c:param/> tag or any other way after clicking the href link to submit the form?

  • To Retrieve dynamic radio button values using jsp & javascript

    Hi All,
    How can i retrive the dynamically created radio button values and also want to get the clicked radio button values.I am using JSP and JAVA beans to retrive the values from the form. I dont have any probs to retrieve combo box values, text box values only problem showing with radio button values. If any data which is entered wrong in the form all the fields should prefills with the old value.Except radio button values all others fields such as combo box, text box values are prefilled with the old values.
    I have given the code for radios.
    document.write('<input type="radio" name="distradio" OnClick="sampleReq.fcidis.value=\'Y\'"/>Yes   ');
    document.write('<input type="radio" name="distradio" OnClick="sampleReq.fcidis.value=\'N\'"/>No');
    document.write('<input type="hidden" name="fcidis" value="">')
    <form method="POST" action="Update.jsp" name="sampleReq" >
    <tr>
    <td class="Txt_gris">
    <input type="radio" name="requester" OnClick="sampleReq.requester1.value='supplier'"/> supplier
    </td>
    <td class="Txt_gris">
    <input type="radio" name="requester" OnClick="sampleReq.requester1.value='customer'"/>customer
    </td>
    <td class="Txt_gris">
    <input type="radio" name="requester" OnClick="sampleReq.requester1.value='distributor'"/> distributor
    </td>
    <td class="Txt_gris">
    <input type="radio" name="requester" OnClick="sampleReq.requester1.value='employee'"/> employee
    </td>
    <td class="Txt_gris">
    <input type="radio" name="requester" OnClick="sampleReq.requester1.value='New partner'"/>New partner
    <input type="hidden" name="requester1" value=""/>
    </td>
    </tr>
    Advanced Thanks for help
    Regards
    Sona

    Hi,
    If you have this code
    document.write('<input type="radio" name="distradio" OnClick="sampleReq.fcidis.value=\'Y\'"/>Yes ');
    document.write('<input type="radio" name="distradio" OnClick="sampleReq.fcidis.value=\'N\'"/>No');
    document.write('<input type="hidden" name="fcidis" value="">')
    <form method="POST" action="Update.jsp" name="sampleReq" >
    <tr>
    <td class="Txt_gris">
    <input type="radio" name="requester" OnClick="sampleReq.requester1.value='supplier'"/> supplier
    </td>
    <td class="Txt_gris">
    <input type="radio" name="requester" OnClick="sampleReq.requester1.value='customer'"/>customer
    </td>
    <td class="Txt_gris">
    <input type="radio" name="requester" OnClick="sampleReq.requester1.value='distributor'"/> distributor
    </td>
    <td class="Txt_gris">
    <input type="radio" name="requester" OnClick="sampleReq.requester1.value='employee'"/> employee
    </td>
    <td class="Txt_gris">
    <input type="radio" name="requester" OnClick="sampleReq.requester1.value='New partner'"/>New partner
    <input type="hidden" name="requester1" value=""/>
    </td>
    </tr>
    this field distradio will not be able Update.jsp.
    You will need to insert these field into the form definition.
    Now, to get a valeu from a radio button, you need only to do request.getAttribute("fieldName").
    To generate dinamically all radio button values, i need to know where are these information? In database? If yes, you need to read the resultset na in value attribute you need to do somethink like this <input type=radio name=fieldName value="<%out.println(resultset.getString("FieldName"));%>">
    If you have more question, only send me a email,
    best regards
    Edney Imme
    [email protected]

  • Dynamic Radio button

    I tried to created radio button dynamically through loop. But for the values and labels- i am not able to assign values dynamically.
    Is there any other way by which i can dynamically create radio buttons inside a loop and assign them values & labels?

    I tried to created radio button dynamically through
    loop. But for the values and labels- i am not able to
    assign values dynamically.
    Is there any other way by which i can dynamically
    create radio buttons inside a loop and assign them
    values & labels?<Display class='Radio'>
    <Property name='title' value='Account Ids:'/>
                   <Property name='labels'>
                        <dolist name='accountId'>
    <ref>:variables.accountIds</ref>               
    <ref>accountId</ref>
         </dolist>
                   </Property>
                   <Property name='required' value='true'/>
    </Display>
    hope this helps

  • Dynamic table with radio buttons

    I need to load a dynamic table with radio buttons that allow
    the user to select an item in the table. I need to have it add a
    radio button with a unique identifier for each table item.
    For example: the table will load all of the seminars
    locations available in a certain state, the radio button will allow
    the user to select the city in which they would like to attend and
    that value will get passed to the registration page. The value of
    each radio button would be equal to the location_id in the database
    for each of the locations in the table (The table includes the
    date, day, venue, address, hotel info, etc. details for each city.)
    When I add dynamic radio buttons and set the value to the
    location_id in the database, it allows the user to select multiple
    radio buttons. I cannot find any information on how to
    resolve.....??
    Any help is appreciated.

    beanieboo wrote:
    > I need to load a dynamic table with radio buttons that
    allow the user to select
    > an item in the table. I need to have it add a radio
    button with a unique
    > identifier for each table item.
    >
    > For example: the table will load all of the seminars
    locations available in a
    > certain state, the radio button will allow the user to
    select the city in which
    > they would like to attend and that value will get passed
    to the registration
    > page. The value of each radio button would be equal to
    the location_id in the
    > database for each of the locations in the table (The
    table includes the date,
    > day, venue, address, hotel info, etc. details for each
    city.)
    >
    > When I add dynamic radio buttons and set the value to
    the location_id in the
    > database, it allows the user to select multiple radio
    buttons. I cannot find
    > any information on how to resolve.....??
    > Any help is appreciated.
    Give each radio button the same name
    <input type="radio" name=theLocation" value="<?php
    $recordset['location_id'] ?>">
    Mick

  • PAGE RADIO BUTTONS and APPLICATION ITEM VALUE

    I have several pages that use same radio button group that permits filtering the report query (of course on each page, it is a page level radio button item).
    I created an application item value to hold the last used value of a radio button item.
    On login, I would like the application item value set to a default value.
    For a given page using the recurring radio button group item,
    I would like the radio button item value set to the application item value on entry into a page.
    I would like the report to use the application item value on entry to a page.
    I would like the application item value be updated anytime the page level radio button item value is changed, so that when you move to another page,
    the next radio button group and report can use the last selected radio group button value.
    I am trying to use a variety of solutions in COMPUTATION and CONDITIONAL COMPUTATION... to include use of set_session_state procedure, and I am not getting desired result, partial success, but not complete.
    Can you have a computation item that is only for initialization of the report and radio button group on page entry?
    And a separate computation item that senses user selection of another radio button, updating the report, and updating the application level item?
    Help requested. Thank you.
    Would be nice to have application level objects, like radio button groups.

    Created Page 0
    Created an HTML region in COLUMN 2 and SEQUENCE 10.
    Selected under region CONDITION:
    Current Page is contained within Expression 1 as comma delimited list of pages
    in the EXPRESSION 1 provided the requested comma delimited list of pages that I wished the HTML region to appear.
    Created the radio button group item P0_RADIO and assigned to Page0 HTML region.
    Selected under item CONDITION:
    Current Page is contained within Expression 1 as comma delimited list of pages
    in the EXPRESSION 1 provided the requested comma delimited list of pages that I wished theradio button group to appear.
    In SHARED COMPONENTS I created an APPLICATION COMPUTATION
    In the computation I created a PL/SQL function to initialize the radio group
    BEGIN
    IF :P0_RADIO IS NULL THEN
    RETURN 'A_ALL';
    ELSE
    RETURN :P0_RADIO;
    END IF;
    END;
    'A_ALL' being the default value for :P0_RADIO
    Radio group appears on the desired pages, is initialized to the desired default value, and works properly on each page.

  • Dynamic radio buttons - Saving state?

    Hello
    I am trying to add some radio button groups to a page displaying products for sale. The number of groups depends on the record being displayed. For example, a television might have two option groups, one named 'Size' with options 24", 26", 28", another named 'Colour' with options black and silver.
    I have a DataTable bound to a HtmlDataTable in a backing bean This has an ArrayDataModel as its value. The DataTable has two columns. The first one displays the attributes name, e.g. 'Colour'. The second column displays the attributes values as a radio button group.
    When the product is loaded, the ArrayDataModel ('attributesArray') in the backing bean is populated with the product attributes. The class of objects held in the array are Object[] as this is necessary to split the data for the two columns.
    E.g. for two attribute in the table 'Size' and 'Colour'
    Object[] attributesArray = new Object[2];
    ArrayList colourSelectItems = new Array();
    ArrayList sizeSelectItems = new Array();
    SelectItem 24inch = new SelectItem(new Integer(24),"24 inch");
    SelectItem 26inch = new SelectItem(new Integer(26),"26 inch");
    SelectItem 28inch = new SelectItem(new Integer(28),"28 inch");
    SelectItem black = new SelectItem("silver","Silver");
    SelectItem silver = new SelectItem("black","Black");
    colourSelectItems.add(black);
    colourSelectItems.add(silver);
    sizeSelectItems.add(24inch);
    sizeSelectItems.add(26inch);
    sizeSelectItems.add(28inch);
    Object colourAttributeArray = new Object[]{"Colour",colourSelectItems};
    Object sizeAttributeArray = new Object[]{"Size",sizeSelectItems};
    attributesArray[0] = colourAttributeArray;
    attributesArray[1] = sizeAttributeArray;On the page i display the datatable as follows:
    <h:dataTable id="attributesTable" binding="#{addProductBean.attributesTable}" var="attribute" cellspacing="0" cellpadding="0" border="0" width="100%" columnClasses="default">
      <h:column id="attributeNameColumn">
        <h:outputText id="attributeName" value="#{attribute[0]}:" style="margin-right: 4px;"/>
      </h:column>
      <h:column id="attributeValuesColumn">
        <h:selectOneRadio id="attributeValues">
          <f:selectItems value="#{attribute[1]}"/>
        </h:selectOneRadio>
      </h:column>
    </h:dataTable>This works fine except I would like the first radio button in each group selected by default.
    This can be done pretty easy.
    I just change the row array to hold an extra element with the id of the default select item in it and add a value parameter to the h:selectOneRadio tag
    Object colourAttributeArray = new Object[]{"Colour","silver",colourSelectItems};
    Object sizeAttributeArray = new Object[]{"Size","24inch",sizeSelectItems};
    <h:selectOneRadio id="attributeValues" value="#{attribute[1]}">
      <f:selectItems value="#{attribute[2]}"/>
    </h:selectOneRadio>But there is a problem...
    Since the number of rows is dynamic there could be any number of radio button groups. As there is only one h:selectRadioButton in the display code (within the datatable tag) it can't be bound to a HtmlSelectOneRadioButton object in the backing bean. Each group loses its value if the form is submitted and returned with errors on it.
    Any solution or other help greatly appreciated. Thanks.

    I believe in this case, the standard way of doing things would be best. Create two String variables and a respective getter and setter. One String will hold the selected size, the other will hold the selected colour. Bind the value attribute of each selectOneRadio to the respective getter/setter of the backing bean.
    If you want to set the default to "silver" or "24inch", just initialize the String with those values.
    Here's how you're code will break down:
    Object[] attributesArray = new Object[2];
    ArrayList colourSelectItems = new Array();
    ArrayList sizeSelectItems = new Array();
    SelectItem 24inch = new SelectItem(new Integer(24),"24 inch");
    SelectItem 26inch = new SelectItem(new Integer(26),"26 inch");
    SelectItem 28inch = new SelectItem(new Integer(28),"28 inch");
    SelectItem black = new SelectItem("silver","Silver");
    SelectItem silver = new SelectItem("black","Black");
    colourSelectItems.add(black);
    colourSelectItems.add(silver);
    sizeSelectItems.add(24inch);
    sizeSelectItems.add(26inch);
    sizeSelectItems.add(28inch);
    Object colourAttributeArray = new Object[]{"Colour",colourSelectItems};
    Object sizeAttributeArray = new Object[]{"Size",sizeSelectItems};
    attributesArray[0] = colourAttributeArray;
    attributesArray[1] = sizeAttributeArray;
    String selectedColour = "silver";
    String selectedSize = "24inch";Don't forget to create your getter and setter for selectedColour and selectedSize in the addProductBean.
    And then create your datatable the same, but change the selectOneRadio tag like this:
    <h:selectOneRadio id="attributeValues" value="#{addProductBean.selectedColour}">
      <f:selectItems value="#{attribute[1]}"/>
    </h:selectOneRadio>Does that make any sense? Let me know how it turns out.
    CowKing
    PS - BTW, when you set the SelectItems for the TV size, you use Integer's as the value. Then later in your examples, you set the defaults using a String. Is this just a typo? I assume that you can get it working fine in whatever way you need it.

Maybe you are looking for

  • PrintToPrinter, ExportToDisk Problem

    Hello, I am using Crystal Reports 2008 inside VS2005 and I wanna get the report in PDF format. The first thing i tried was exporting the report using the ExportToDisk function. It works ok, but the fonts of the PDF generated werent the same as the fo

  • [new] ruby-gnome2

    This is bindings for gnome related stuff and gtk2 for ruby programming language. Please, dont upgrade on 0.10.1. In 0.10.1 there is unbeauty bug somewhere and it may but laso may not work. # Contributor: Lukas Konarovsky <http://daeltar.org> pkgname=

  • The icons on the tool bar to the right (Bluetooth, time, volume etc) are missing. How do I restore them? Do I have to use my installer discs again?

    I started up my iMac G5 this morning, and all the icons to the right end of the tool bar are missing, namely time counter, bluetooth logo, volume slider etc are missing. Do I have to re-install the startup disc to get them back?

  • Unable to bind OS X Mavericks to Active Directory

    Recently I had one of my iMacs lose its trust relationship with Active Directory.  I tried unbinding and then rebinding it but that's where I ran into problems.  Of course, unbinding was simple and easy.  Now, I can't get this bound back to the domai

  • Unable to open iSync: "Not supported on this platform"

    Maybe it was the 10.5.5 upgrade, maybe not. Right now, when I click on iSync, I get an immediate popup saying "You can't open the application 'iSync' because it is not supported on this architecture. Well, it was a month ago. I use iSync to set the t