aspose file tools*
The moose likes JSP and the fly likes Starting new row after every 4 table cells using c:forEach Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Starting new row after every 4 table cells using c:forEach" Watch "Starting new row after every 4 table cells using c:forEach" New topic
Author

Starting new row after every 4 table cells using c:forEach

Mike Dell
Greenhorn

Joined: Sep 28, 2009
Posts: 10
Hi,
I am stuck on how I can get this to work. What I have at the moment is always missing a closing </tr> somewhere. I'd appreciate any pointers on this.

Here is what I have so far:
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61772
    
  67

The way I'd do it is to just test whether a multiple has been reached and insert "</tr><tr>" into the template text.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mike Dell
Greenhorn

Joined: Sep 28, 2009
Posts: 10
Bear Bibeault wrote:The way I'd do it is to just test whether a multiple has been reached and insert "</tr><tr>" into the template text.


Thanks! That worked in terms of getting the tags right. But now, I've noticed another thing...

<c:when test="<%=status.getCount()%5==0%>"> doesn't work quite the way I want it to when the count gets above 8.
For example, when it is displaying the 9th cell item, 9%5 is not 0 so it remains on the second row instead of going to the 3rd row. What is the proper test condition here?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61772
    
  67

Why are you still using scriptlets? The JSTL is better meant to use the EL. That'd be the first step to fixing any problems in my opinion.

(Unless you are still, for whatever reasons, stuck on JSP 1.2? )
Mike Dell
Greenhorn

Joined: Sep 28, 2009
Posts: 10
Bear Bibeault wrote:Why are you still using scriptlets? The JSTL is better meant to use the EL. That'd be the first step to fixing any problems in my opinion.

(Unless you are still, for whatever reasons, stuck on JSP 1.2? )


Thanks for your suggestion. I removed the scriptlets and was able to get it working.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Starting new row after every 4 table cells using c:forEach