Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8517061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:35:52+00:00 2026-06-11T05:35:52+00:00

My viewmodel has an enum with three possible values: public enum PollFrequency { SixHours,

  • 0

My viewmodel has an enum with three possible values:

public enum PollFrequency {
    SixHours, TwentyFourHours, Weekly
}

public class AlertViewModel {
    private PollFrequency pollFrequency;
    public PollFrequency getPollFrequency(){
        return pollFrequency;
    }
    public void setPollFrequency(PollFrequency pollFrequency){
        this.pollFrequency = pollFrequency;
    }

    public AlertViewModel(){
        pollFrequency = PollFrequency.TwentyFourHours;
    }
}

My JSP page has a set of three radio buttons:

<input checked="<c:if test="${viewModel.pollFrequency eq 'SixHours'}">checked</c:if>" type="radio" name="checkEvery" value="checkEvery6Hours" /> 6 Hours<br />
<input checked="<c:if test="${viewModel.pollFrequency eq 'TwentyFourHours'}">checked</c:if>" type="radio" name="checkEvery" value="checkEvery24Hours" /> 24 Hours<br />
<input checked="<c:if test="${viewModel.pollFrequency eq 'Weekly'}">checked</c:if>" type="radio" name="checkEvery" value="checkEveryWeek" /> Weekly

I’d like to set the checked property of the radio buttons based on the enum value, but currently the last radio button is always checked. I found some threads on how to do it with springsource, but I’m not using that. Is there a simple solution to this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T05:35:54+00:00Added an answer on June 11, 2026 at 5:35 am

    Try this,

    <input type="radio" <c:if test="${model.thing eq 'Thing1'}">checked</c:if> name="thing" value="thing1" /> Thing1<br />
    <input type="radio" <c:if test="${model.thing eq 'Thing2'}">checked</c:if> name="thing" value="thing2" /> Thing2<br />
    <input type="radio" <c:if test="${model.thing eq 'Thing3'}">checked</c:if> name="thing" value="thing3" /> Thing3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I Have an Enum Called ActionStatus that has 2 possible values open=0 and closed
I have three classes, first: public class Setting which has properties: string ID, string
My Viewmodel has an event public class TestViewModel { public event RoutedEventHandler Run; }
We have a ViewModel with a collection of Widget<dynamic> : public class Widget<T> {
My ViewModel class has a property that contains a ShareClass object. ShareClass has a
My ViewModel class has a child property of type 'Messages' that has an indexed
I have a ViewModel that looks like this: public class CreateReviewViewModel { public string
I have ViewModel classes like these that follow: public class ReferenceDetailsViewModel { public ReferenceDetailsViewModel()
I have a window that is databound to a ViewModel. The ViewModel has many
I have a DatePicker working on a View which also has a ViewModel associated

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.