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

  • SEARCH
  • Home
  • 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 8997075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:50:22+00:00 2026-06-15T23:50:22+00:00

Let’s say I have classes Project , Employee , and ProjectAssignement . I have

  • 0

Let’s say I have classes Project, Employee, and ProjectAssignement. I have an enum Role, with two values, LEADER and FOLLOWER. Employees are assigned to Projects via the ProjectAssignment object, which has a member field role of type Role.

I have a business rule that each project can only have one leader but can have many followers. To implement this, I give Role a member field singular, which is true for LEADER and false for FOLLOWER. (I might add more roles in the future.) My server-side Java checks if you try to assign multiple leaders to a project and doesn’t let you.

So far, I don’t think I’m describing anything particularly unusual.

Here is the awkward bit: I have some (handwritten) client-side JavaScript validation to make sure you don’t assign multiple people with the same role to a project. It has a hardcoded exception for followers. Is there any clean way to just give the JavaScript code awareness of the Role enum, so it can access the isSingular method?

(Obviously, anything of the sort would actually have to transcribe the Role enum into JavaScript at some point; I want to avoid doing that manually or even semi-automatically, because that rapidly becomes more effort than it’s worth as I do it for more situations.)

I am not using Spring or any similar framework, just plain .jsps. Rewriting the whole application to use something like that might be a good idea, but is well beyond the scope of the problem.

  • 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-15T23:50:23+00:00Added an answer on June 15, 2026 at 11:50 pm

    I usually solve this kind of thing by adding a lookup-table in some dynamically-generated Javascript on the page. Maybe the id of the user is the key and their “singularness” is the value. Or maybe you only list those who are less popular (there are likely fewer LEADERs, so only list those). Then just consult the LUT in the javascript.

    Actually accessing the ENUMs is not possible. Instead, you’ll have to bridge the gap yourself, even if it means basically building a Javascript object that fully-models your server-side object description and then copy all the data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have two Entity classes: SocialApp and SocialAppType In SocialApp I have
Let's say I have 2 windows in my application, and two classes responsible for
Let's say I have a Scala project with a bunch of case classes under
Let's say I have two text files that I need to extract data out
Let's say we have two pages in Orchard CMS. The homepage and the About
Let's say you have a class library project that has any number of supplemental
Let's say that I have classes like this: public class Parent { public int
Let's say I have two objects, Master and Slave . Slave has a method
Let's say I have the following two lists of tuples myList = [(1, 7),
Let say I have two UIViews: View1: - bounds: 0, 0, 20, 20 -

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.