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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:22:57+00:00 2026-06-18T06:22:57+00:00

I’d like to display 2d array of floats in a table on a xhtml

  • 0

I’d like to display 2d array of floats in a table on a xhtml page using JSF2 and I have no idea how to do that. I tried to find the answer in google but I couldn’t. All examples were displaying classes objects and I was not able to make it working with the table.

The sitation is:
I have the array of some size – the size of the array depends on entered data:
float [][] variables = new float[size1][size2]

After user enters data and pressess button a method is called in the managed bean. The calculation begins and the table is filled with data.

Please tell me how can I display the array.

  • 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-18T06:22:58+00:00Added an answer on June 18, 2026 at 6:22 am

    To achieve that you can use c:forEach tag to dinamically buid a h:panelGrid. Just save size2, which is the column number as a property and store all the input numbers in a normal java.util.List. Then you set that size to the h:panelGrid columns attribute and the component will split the rows for you. You can also style the content inside the c:forEach tag, bordering it in order to give it a table behaviour.

    <h:form>
        <h:panelGrid columns="#{bean.numberCount}">
            <c:forEach var="num" items="#{bean.numberList}">
                #{number}
            </c:forEach>
        </h:panelGrid>
    </h:form>
    

    EDITED

    If you want to maintain the original structure but in a List, you can create a List<List<Float>>. That means a List which is composed by List which contains Float Objects. The same as a 2d array.

    private List<List<Float>> _Matrix;
    
    public List<List<Float>> get_Matrix() {
        return this._Matrix;
    }
    
    /**
     * Constructor for BackingBean.
     */
    public BackingBean() {
        this._Matrix = new ArrayList<List<Float>>();
        this._Matrix.add(new ArrayList<Float>());
        this._Matrix.add(new ArrayList<Float>());
        this._Matrix.get(0).add(1.0f);
        this._Matrix.get(0).add(2.0f);
        this._Matrix.get(0).add(3.0f);
        this._Matrix.get(1).add(1.0f);
        this._Matrix.get(1).add(2.0f);
        this._Matrix.get(1).add(3.0f);
    }
    

    In the code above I’m constructing the equivalent to a 2d array with 2 rows and values 1.0,2.0 and 3.0 on each row. You can use this code to iterate it over the view:

    <h:panelGrid columns="#{backingBean._ColumnNumber}">
            <c:forEach var="row" items="#{backingBean._Matrix}">
    
                <c:forEach var="value" items="#{row}">
    
                    #{value}
                        </c:forEach>
            </c:forEach>
        </h:panelGrid>
    

    Where #{backingBean._ColumnNumber} will be the length of the first array of the List (supposing all of them have the same length).

    Good Luck.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have two tables with like below codes: Table: Accounts id | username |
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.