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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:36:29+00:00 2026-05-27T07:36:29+00:00

I have a problem using JSF to display some data in Facelets. I have

  • 0

I have a problem using JSF to display some data in Facelets. I have list of hashmaps:

List<Map<String, String>> persons = new LinkedList<Map<String,String>>();

public List getPersons() {
    return this.persons;
}

I get this as follows from database:

while(rs.next()) {
  Map<String,String> result = new HashMap<String,String>();
  result.put("name", rs.getString(1));
  result.put("category", rs.getString(2));
  this.persons.add(result);
}

So, my problem is how to display info for every map in xhtml. I try to used ui:repeat but it is wrong so I need help. I must have getter for name and family but how should I add it?

<ui:repeat value="#{class.persons}" var="persons">   
  <h:outputText value="#{persons['name'}"/>
  <h:outputText value="#{persons['family'}"/>                       
</ui:repeat>

I hope you understand my problem and will help me to fix it. Thanks in advance!

  • 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-27T07:36:30+00:00Added an answer on May 27, 2026 at 7:36 am

    The #{persons} is thus a Map<String, String>. You can access map values by keys in the same way as normal Javabeans. So #{person.name} will return map.get("name").

    So, this should do:

    <ui:repeat value="#{class.persons}" var="person">   
      <h:outputText value="#{person.name}"/>
      <h:outputText value="#{person.family}"/>
    </ui:repeat>
    

    (I only renamed persons to person, because it essentially represents only one person)

    The following way is by the way also valid and it would actually be the only way if you have a map key which contained periods:

    <ui:repeat value="#{class.persons}" var="persons">   
      <h:outputText value="#{persons['name']}"/>
      <h:outputText value="#{persons['family']}"/>                       
    </ui:repeat>
    

    (you see, you were close, you only forgot the closing brace)

    The normal practice, however, is to create a Javabean class instead of a Map if it actually represents an entity.

    public class Person {
    
        private String name;
        private String family;
        // ...
    
        // Add/generate getters/setters and other boilerplate.
    }
    

    And feed it as List<Person> to the view.

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

Sidebar

Related Questions

I have some problem using JSF <h:selectManyListbox> and Google Chrome. When my page is
First of all, i'm using Jsf 1.2... I have a problem with submitting some
Using: JSF 1.2, Facelets 1.1.15, GateIn 3.1 GA, Richfaces 3.3.3 I have some common
I have a problem using the SSIS. I try to import data from database
I'm using JSF 2.0 and Glassfish 3.1 and have the following problem: I've got
I have a problem with using jQuery Dialog and Ajax submit in JSF. I
I have problem with core tag in JSF. Im using this tag for pagination
I have a problem using JSF 2.0, PrimeFaces and the tuckey.org UrlRewriteFilter. The problem
I have a problem when using h:head tag. I am using JSF 2.0 Mojarra's
Using jsf 1.2, hibernate, richfaces 3.3.0GA and facelets. I have this code in my

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.