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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:01:08+00:00 2026-05-26T06:01:08+00:00

In my application, I have the following Constants class public class Constants { …

  • 0

In my application, I have the following Constants class

public class Constants {
    ...
    public static final int MAX_NUM_OF_PICTURES = 2
    ...
}

Earlier when I was using JSP, I managed to dynamically render input fields for uploading files based on this constant as following:

<%
    for (int i = 1; i < Constants.MAX_NUM_OF_PICTURES + 1; i++) {
%>
<tr>
    <td>Upload Picture <%= i %></td>
    <td><input name="<%= i%>" type="file" /></td>
</tr>
<tr>
    <td>Description <%= i %></td>
    <td><input type="text" name="<%= "description" + i%>" id="description" /></td>
</tr>
<%
    }
%>

Currently, I am trying to use JSF to achieve the above task. If these input fields are not dynamically generated, I can easily define the following properties in my backing bean:

@ManagedBean
@RequestScoped
public class MrBean {
   ...
   private UploadedFile picture1;
   private String       pictDescription1;
   ...
}

However, since these fields are now dynamically generated, I cannot know how many properties I would need to define in advance to capture these uploaded files.

I’d be very grateful if someone could give me an advice on how I should tackle this problem?

Best regards,

James Tran

  • 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-26T06:01:10+00:00Added an answer on May 26, 2026 at 6:01 am

    Put those properties in another javabean class and have a collection of those javabeans in your managed bean.

    E.g.

    public class Picture {
    
        private UploadedFile file;
        private String description;
    
        // ...
    }
    

    and

    @ManagedBean
    @ViewScoped
    public class Profile {
    
        List<Picture> pictures;
    
        public Profile() {
            pictures = new ArrayList<Picture>();
    
            for (int i = 0; i < Constants.MAX_NUM_OF_PICTURES; i++) {
                pictures.add(new Picture());
            }
        }
    
        // ...
    }
    

    Then you can loop over it in for example <ui:repeat> (or maybe <h:dataTable>, but this isn’t really suitable if you want two repeating rows instead of one).

    <table>
        <ui:repeat value="#{profile.pictures}" var="picture" varStatus="loop">
            <tr>
                <td>Upload Picture #{loop.index + 1}</td>
                <td><t:inputFileUpload value="#{picture.file}" /></td>
            </tr>
            <tr>
                <td>Description #{loop.index + 1}</td>
                <td><h:inputText value="#{picture.description}" /></td>
            </tr>
        </ui:repeat>
    </table>
    

    I have no idea what component library you’re using for uploading files, so I assumed it be just Tomahawk.

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

Sidebar

Related Questions

In an ASP.NET MVC application where I have the following model.. public class EventViewModel
We have a Hibernate/Spring application that have the following Spring beans: <bean id=transactionManager class=org.springframework.orm.hibernate3.HibernateTransactionManager
I have following code in my application: // to set tip - photo in
I have following requirement in my application. A tableView with games title After selecting
I have following code in my Application. Comments in my code will specify My
I have following code in my application. [self.navigationController pushViewController:x animated:YES]; It will push a
I have following problem: I have built a tabbar application with 4 tabs. I
I have following requirement, I have C#/.Net console application, which refers to 'System.Data.Sqlite.dll' 'System.Data.Sqlite.dll'
I have the following application which replicates an issue I'm having in a larger
I have the following problem deploying my application. It uses JMS and a remote

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.