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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:27:55+00:00 2026-06-01T09:27:55+00:00

I want to create JSF table which has select all button and check box

  • 0

I want to create JSF table which has select all button and check box in every row. I found this source code example. Following this JSF table tutorial I found this JSF table with select row example. I tried to modify the code but I get error in Netbeans which I don’t know how to fix:

import java.io.Serializable;
import java.math.BigDecimal;
import javax.enterprise.context.SessionScoped;
// or import javax.faces.bean.SessionScoped;
import javax.inject.Named;
/* include SQL Packages */
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.sql.DataSource;
import javax.annotation.Resource;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
// or import javax.faces.bean.ManagedBean;   

import org.glassfish.osgicdi.OSGiService;

@Named("SessionsController")
@SessionScoped
public class Sessions implements Serializable {

    public Sessions() {
    }

    private Map<Long, Boolean> selectedIds = new HashMap<Long, Boolean>();
    private List<MyData> selectedDataList;

    /* Call the Oracle JDBC Connection driver */
    @Resource(name = "jdbc/Oracle")
    private DataSource ds;

    private static final ArrayList<SessionArray> sessionList =
            new ArrayList<SessionArray>(Arrays.asList(
            new SessionArray("A0001", "Intel CPU",
            new BigDecimal("700.00"), 1),
            new SessionArray("A0002", "Harddisk 10TB",
            new BigDecimal("500.00"), 2),
            new SessionArray("A0003", "Dell Laptop",
            new BigDecimal("11600.00"), 8),
            new SessionArray("A0004", "Samsung LCD",
            new BigDecimal("5200.00"), 3),
            new SessionArray("A0005", "A4Tech Mouse",
            new BigDecimal("100.00"), 10)));

    public ArrayList<SessionArray> getSessionList() {

        return sessionList;

    }

    public String deleteAction(SessionArray session) {

        sessionList.remove(session);
        return null;
    }

    public static class SessionArray {

        String orderNo;
        String productName;
        BigDecimal price;
        int qty;

        public SessionArray(String orderNo, String productName,
                BigDecimal price, int qty) {
            this.orderNo = orderNo;
            this.productName = productName;
            this.price = price;
            this.qty = qty;
        }

        public String getOrderNo() {
            return orderNo;
        }

        public void setOrderNo(String orderNo) {
            this.orderNo = orderNo;
        }

        public String getProductName() {
            return productName;
        }

        public void setProductName(String productName) {
            this.productName = productName;
        }

        public BigDecimal getPrice() {
            return price;
        }

        public void setPrice(BigDecimal price) {
            this.price = price;
        }

        public int getQty() {
            return qty;
        }

        public void setQty(int qty) {
            this.qty = qty;
        }
    }

    //select all  button code

    public String getSelectedItems() {

        // Get selected items.
        selectedDataList = new ArrayList<MyData>();
        for (MyData dataItem : dataList) {
            if (selectedIds.get(dataItem.getId()).booleanValue()) {
                selectedDataList.add(dataItem);
                selectedIds.remove(dataItem.getId()); // Reset.
            }
        }

        // Do your thing with the MyData items in List selectedDataList.

        return "selected"; // Navigation case.
    }

    public Map<Long, Boolean> getSelectedIds() {
        return selectedIds;
    }

    public List<MyData> getSelectedDataList() {
        return selectedDataList;
    }

}

Netbeans gave me an error whrn I want to use this code private List<MyData> selectedDataList;. MyData Class is not found. How I can fix this error?

Best wishes

  • 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-01T09:27:57+00:00Added an answer on June 1, 2026 at 9:27 am

    Do you have the class MyData in your project/workspace…

    If not implement it… if it is present, import it

    In case you took the code from some example, double check that you haven’t forgot anything…

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

Sidebar

Related Questions

I want to create a JSF table like this . But instead delete button
I want to create this JSF table with paging and sorting. This is JSF
I want to use this code and create JSF 2.0 table. I get this
I want create a pdf using iText. The method which does this is a
I want to translate this html table into JSF table <table border=1> <tr> <td>OS
I want to create JSF page which displays Oracle connections. The web page will
I want to create JSF page which displays Glassfish connections. The web page will
We have a web based java/JSF/Spring application for which we want to create sitempas.xml
I want to create JSF page with tabs. Something like this . But I
In my JSF web-app, I want to create a URL for the user to

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.