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 3313082
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:04:25+00:00 2026-05-17T22:04:25+00:00

I have a contant list declared in java using enum type, that must appears

  • 0

I have a contant list declared in java using enum type, that must appears in a jsp.
Java enum declaration :

public class ConstanteADMD {


    public enum LIST_TYPE_AFFICHAGE {
        QSDF("qsmldfkj"), POUR("azeproui");

        private final String name;

        @Override
        public String toString() {
            return name;
        }

        private LIST_TYPE_AFFICHAGE(String name) {
            this.name = name;
        }

        public static List<String> getNames() {
            List<String> list = new ArrayList<String>();
            for (LIST_TYPE_AFFICHAGE test : LIST_TYPE_AFFICHAGE.values()) {
                list.add(test.toString());
            }
            return list;
        }
    }
}


<select name="typeAffichage" id="typeAffichage">
    <c:forEach var="type" items="${netcsss.outils.ConstanteADMD.LIST_TYPE_AFFICHAGE.names}">
        <option value="${type}">${type}</option>
    </c:forEach>
</select>

where as :

<select name="typeAffichage" id="typeAffichage">
    <c:choose>
        <c:when test="${catDecla ne null}">
            <option
                value="<%=catDecla.getCatDecla().getSTypeAffichage()%>"
                selected="selected"><%=catDecla.getCatDecla().getSTypeAffichage()%></option>
        </c:when>
    </c:choose> 
        <%List<String> list = ConstanteADMD.LIST_TYPE_AFFICHAGE.getNames();
                for(String test : list) {
            %>
        <option value="<%=test%>"><%=test%></option>
        <%}%>
</select>

Works fine.
Is there a limitation on enum types ni foreach loop?

  • 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-05-17T22:04:25+00:00Added an answer on May 17, 2026 at 10:04 pm

    The values method works fine, my mistake.
    Indeed the problem was that I didn’t put my list in the page scope of my jsp.

    <%    pageContext.setAttribute("monEnum", ConstanteADMD.ListTypeAffichage.values()); %>
    
    ...
    <c:forEach var="entry" items="${monEnum}">
        <option>${entry.type}</option>
    </c:forEach>
    

    No need of the getNames method

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

Sidebar

Related Questions

I have a contact picker list with chckboxes of the contacts that have a
I have a script that sends emails to a contact list. I would like
I am using grouped tableview for developing a contact list using database. I have
I have a content string that starts with an unordered list I want to
I have a SharePoint list with Content Approval enabled. The business requirement is that
I have an asp.net UserControl that writes HTML content from a SharePoint list to
I have a list of values that i need to check against a constant
I have contact list and I want to send an sms using MFMessageComposeViewController and
I have a list view declared in my xml: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
I have a content type that has a lookup field for a document library

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.