Announcement Announcement Module
Collapse
No announcement yet.
Enabling a <form:radiobutton> property to be selected by default Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Enabling a <form:radiobutton> property to be selected by default

    Hi,
    this might seem like a very basic question, but has me baffled for a few hours now. On my jsp page i have two radio buttons using <form:radiobutton> to bind, and I want one checked by default but I can't find the right attribute to enable this.

    code:
    <form:radiobutton path="contactPreference" id="emailPref" value="Email"/>
    <label for="contactPreference">Email<label>
    <form:radiobutton path="contactPreference" id="phonePref" value="Telephone"/>
    <label for="contactPreference">Telephone</label>

    Any ideas?

  • #2
    I found the solution to this For anyone who's interested,

    In my FormBackingObject i set the value of the variable that i want it defaulted to.
    newForm.setContactPreference("Email");

    and this matches up the value attribute to make Email radio button the default selection.

    <form:radiobutton path="contactPreference" id="emailPref" value="Email"/>
    <label for="contactPreference">Email<label>
    <form:radiobutton path="contactPreference" id="phonePref" value="Telephone"/>
    <label for="contactPreference">Telephone</label>

    Comment


    • #3
      What should we do in case of BaseFormAction?

      Comment


      • #4
        realta, thankh! Your solution help me!

        Comment

        Working...
        X