Restricting the number of rows in each div in a JSP data table

On my webpage, I have labels and input text fields for users to enter data to send back to the server. Sometimes, the server sends over 50 rows of information, which causes the user to scroll multiple times to see all the fields. I'm thinking of creating 2 or 3 divs, each containing around 20 fields so that everything can be displayed without scrolling. Any suggestions?

Take a look at my code below:

<div class="container">
    <div class="row">
        <f:view>
            <h:form>
                <h:dataTable value="#{Message.bits}" var="bit">
                    <h:column>
                        <div class="col-lg-4">
                            <h:outputText value="#{bit.id} #{bit.name}" />
                            <div class="input-group">
                                <h:inputText styleClass="form-control" size="100"
                                    maxlength="100" value="#{bit.value}" />
                            </div>
                            </p>
                        </div>
                    </h:column>
                </h:dataTable>
            </h:form>
        </f:view>
    </div>
</div>

The Message class serves as a container for bits, managed by the bean manager.

@ManagedBean
@ViewScoped
public class Message implements Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = 2712306195992874273L;

    private List<Bit> bits = null;

    public List<Bit> getBits() {
            return bits;
        } 
    //Do more things

The Bit class looks like this:

public class Bit implements Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = -6341896264030346040L;

    private String name = null;

    private String value = null;

    private int id = 0;

   //Business logic

I am open to using HTML, CSS, any JS framework, JSP, Java, etc. Thank you for your assistance.

Answer №1

It seems like you're looking to organize your data in a specific way, similar to the following:

1   4   7
2   5   8
3   6   9

Rather than the conventional layout like this:

1
2
3
4
5
..

While there may be other methods, here's an approach that has worked for me.

You can experiment with the code provided below.

<div class="row">

   <ui:repeat var="bit" value="#{message.bits}" varStatus="bitstatus">
       <h:outputText escape="false" value="&lt;div class='col-lg-4'&gt;" rendered="#{(bitstatus.index + 1) % 20 eq 1}" />

       <h:outputText value="#{bit.id} #{bit.name}" />

       <div class="input-group">
         <h:inputText styleClass="form-control" size="100" maxlength="100" value="#{bit.value}" />
       </div>

       <h:outputText escape="false" value="&lt;/div&gt;" rendered="#{(productstatus.index + 1) % 5 eq 0}" />
   </ui:repeat>


</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for eliminating extra blank space under the footer on an HTML website

Just beginning my journey with bootstrap and I am encountering an issue on my website where there is space after the footer when resizing to a mobile size. I've tried setting margin: 0; padding: 0; but it hasn't resolved the problem. Here's ...

Exporting table data from Bootstrap 3 DataTable to Excel is not functioning as expected

I am attempting to export the data from a table to MS Excel by referring to this example: https://datatables.net/extensions/buttons/examples/styling/bootstrap.html While the content displays correctly on the page, the issue arises when I try to export it. ...

Learn how to easily incorporate a drop-down list into the material-UI Search component within the navbar to enhance the search results

I integrated a Material UI search bar into my React app's navbar following the instructions from the official documentation on MUI. However, the article does not provide any guidance on how to add a dropdown list when selecting the search input field. ...

Issues with keyboard accessibility in drop down menus

Looking to improve the keyboard accessibility of my menu bar. Swapped out all instances of :hover with :focus, but unfortunately dropdown menus are still not accessible via keyboard. Does anyone have a solution for this issue? Appreciate any help! ...

The class in my CSS is currently impacting all the menu bar items, but I specifically want it to only affect my photo gallery

<div class="gallery"> <a tabindex="1"><img src="images/smile.jpg"></a> <a tabindex="1"><img src="images/smile.jpg"></a> <a tabindex="1"><img src="images/smile.jpg"></a> ...

Ajax - Trouble with Updating DIV Content

As a beginner in AJAX, I am encountering difficulties creating a simple AJAX program. My goal is to have a button that, when clicked, changes the text of the div below it. Despite numerous attempts, I have not been able to identify the issue. Below is the ...

The Safari browser is plagued by a flickering issue with CSS perspective flip animations, even when using the back

I'm facing an issue with Safari (both desktop and iOS) related to a simple CSS flip animation. Despite searching through similar posts and answers, I haven't found a solution yet and am in need of a fresh perspective. Essentially, I am creating ...

The collision function is currently not functioning properly, causing a hindrance in movement. There are no other codes restricting movement

const rightPressed = false; const leftPressed = false; const upPressed = false; const downPressed = false; const players = []; players[0] = new victim(1234); const arrayw = 50; const arrayh = 50; const canvas = document.getElementById("myCanvas"); const ...

Incorporate an MP3 audio track into an image

Greetings, I have an image and I am interested in embedding the associated MP3 file directly onto the image instead of having it displayed separately below. Is this achievable? Thank you Best regards, Gary <!doctype html> <html> <head&g ...

Adjusting the content of a span causes the parent element to shift to the left

I'm having trouble finding a solution to a specific issue that seems to be only affecting Chrome. Whenever I try to replace the text in a span element, it causes the parent anchor to shift left. You can see a demonstration of this problem here: http:/ ...

List that dynamically changes in HTML email template

I'm currently working on an email template using HTML, and I've run into a roadblock while trying to create a list based on Java code data. The challenge is that the length of the list varies each time. Here's what I tried: <span st ...

Troubleshooting Checkbox Problem in a Perl Script Triggered by an HTML Form

Prior to presenting the inquiry, a few notes must be made clear: As someone who is not a programmer, I have been given the challenging task of making this work. My knowledge is limited to the basics, with minimal experience from previous dabbling. My skill ...

Maintaining Changes in Javascript and CSS

I have created a header that can slide in and out of view with a toggle function. However, I want the header to be in the down position by default, without requiring users to click the toggle every time a new page loads. I have limited knowledge of JavaScr ...

Expanding the size of a buffer array dynamically in JavaScript while adding items

Within the source table are several records stored. Upon clicking each record in the source table, the AddSelectedItem(sValue) function is triggered, adding those specific records to the destination table. The desired outcome is for the array to dynamica ...

What is the best DOCTYPE declaration to implement?

After exploring various resources on DOCTYPE declaration and its variations - strict, transitional, and frameset, I am still struggling to grasp their distinctions. The specific confusion lies in understanding the variance between strict and transitional d ...

Adaptable backdrop picture within a full-width container

Currently experiencing an issue with my website that requires some assistance. When a user visits my site, the image of the 'cutlery pouch' will resize based on the size of the user's browser or monitor. However, some users are seeing the b ...

equal child width as parent column container

I'm in the process of developing a custom dropdown search bar that presents results as the user enters text. One issue I'm facing is that the list of results must have a position: absolute. This causes it to disregard the width of the parent col ...

Reducing the slide margins in impress.js?

When using Impress.js, I noticed that the default slides have a large left margin (or padding - it's hard to determine with Firefox's Inspector). I have a slide with a wide <pre> block that would fit if it were aligned to the left, but it d ...

"Troubleshooting a malfunctioning PHP contact form that is not functioning properly

Here's some of my JavaScript code: var form = $('#main-contact-form'); form.submit(function(event){ event.preventDefault(); var form_status = $('<div class="form_status"></div>'); $.ajax({ url: $(th ...

Achieve center alignment for two column divs without altering the HTML code using only CSS

Recently, I stumbled upon a basic HTML code that I am unable to modify due to restrictions: <div id="container"> <div id="a"> Title col </div> <div id="b"> Left col </div> <div id="c"> ...