Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-04-2008, 11:56 PM
Member
 
Join Date: Jul 2008
Posts: 3
wonderpets is on a distinguished road
JSTL forEach Query
Hi All,

This is my first post to this forum so please let me know if I go off track.
Can someone help me with a jstl forEach issue I have. We have been provided with jsp pages from an external company that we now have to incorporate our variable data. This is received in the normal way via collections. The problem I have is that the pages are structured with a series of divs specifying column 1 followed by a series of divs specifying column 2 etc... Each item from the collection, however, corresponds to a row across each of these divs.

My first thought was to create variable fields from the collection so I could just place them into the right pages as below:

<c:set var="count" value="1" />
<c:forEach var="bookListEntry" items="${bookSearchResultList}" begin="${param.first}" end="${param.first + noOfRows - 1}">
<c:set var="who${count}" value="${bookListEntry.artistName}"/>
<c:set var="where${count}" value="${bookListEntry.countyName}"/>
<c:set var="cost${count}" value="${bookListEntry.costRangeFrom}"/>
<c:set var="bandIndex${count}" value="${bookListEntry.bandIndex}"/>
<c:set var="proFile${count}" value="${bookListEntry.proFile}"/>

<c:set var="count" value="${count+1}"/>
</c:forEach>

but according to the DTD atrribute var does not accept expressions. I'm using the begin and end attributes because I only want to partially traverse the collaction as there is a "next" and "prev" button at the bottom.

My question is, is there any way to create a variable "var" name or alternatively can anyone think of a better way to do this.

I hope this makes sense as it's always difficult to try and put into words something you've been working on for a while.

Thanks for any help.

Gareth
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-05-2008, 12:50 AM
Nicholas Jordan's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Southwest
Posts: 402
Nicholas Jordan is on a distinguished road
yep, it's them words again.
What DTD, where?

Last time I heard JSTL was not ready for PrimeTime. Did Marty get Vol-2 on the trucks yet?

It does not take me a long time to figure this stuff, if you can give me a base reference page I may be able to provide some help. Your words are clear: get a var ( variable / label / whatever ) such that the expressions who / where / band / costIndex and proFile become ( words again ) assigned to a label in your source code such that they may be worked as any other variable in traditional code.

Swamped right now with a major project, hope I helped you with your wording. Nil illegitimo in desperandum carborundum.
__________________
Please provide your feedback on our
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-05-2008, 01:13 AM
Member
 
Join Date: Jul 2008
Posts: 3
wonderpets is on a distinguished road
JSTL forEach Query
Thanks for the reply Nickolas and I appreciate your time (fully understand that you deadlines to meet). Hopefully, I can clarify what I said.

When I said DTD a bit of dyslexia crept in. I meant TLD, sorry.

I have put the jsp up as a text page so, hopefully, you can see what I mean instead of trying to decipher my babble. There is some hard-coding at the moment with c:set's but please ignore these for now.

msgnitsolutions com test TestResults.txt

Hopefully this makes a bit more sense.

Thanks,

Gareth
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-05-2008, 02:44 PM
Nicholas Jordan's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Southwest
Posts: 402
Nicholas Jordan is on a distinguished road
xml
TLD's are in xml - you have to write the tags.

who / where / cost / bandIndex / proFile should be in a Bean.

Where is bookSearchResultList?

As for time, I really put up some sloppy code in front of a convert from Captain Hoppers legendary business oriented language. That poster is a Navigator, but not a Browser.
__________________
Please provide your feedback on our
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 07-06-2008, 11:56 PM
Member
 
Join Date: Jul 2008
Posts: 3
wonderpets is on a distinguished road
JSTL forEach Query
Hi Nicholas,

Thanks for the reply again. Unfortunately I'm under contract with my wife and I'm not allowed to work Saturday nights so I've only just got your reply.

The properties you mentioned are defined in a bean bookSearchResultList which is built using a struts config file and appropriate servlet. When I hard-code this list of c:set's to use who1, where1 etc... everything works fine. The bean is picked up and everything is displayed correctly. It's only when I try to make the var property contain a variable name I am having problems.

Is that COBOL you're talking about? I've not had the misfortune to use that for some years.

Thanks again,

Gareth
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 07-14-2008, 07:35 PM
Nicholas Jordan's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Southwest
Posts: 402
Nicholas Jordan is on a distinguished road
busy too
Quote:
Originally Posted by wonderpets View Post
Hi Nicholas,
Hi, Gaeth.
Quote:
Originally Posted by wonderpets View Post
Thanks for the reply again. Unfortunately I'm under contract with my wife and I'm not allowed to work Saturday nights so I've only just got your reply.
I have responses, we do not have a Wombat patch so I cannot do anything but let the moderators have a swipe at your swipe. ( weak humor, weak reference )
Quote:
Originally Posted by wonderpets View Post
The properties you mentioned are defined in a bean bookSearchResultList which is built using a struts config file
Do you have some code snippets you can show me? I do not at this point even know what a c:set is.
Quote:
Originally Posted by wonderpets View Post
When I hard-code this list of c:set's to use who1, where1 etc... everything works fine. The bean is picked up and everything is displayed correctly. It's only when I try to make the var property contain a variable name I am having problems.
Struts is an intermediary of some kind, I have no experience with struts.
Quote:
Originally Posted by wonderpets View Post
Is that COBOL you're talking about? I've not had the misfortune to use that for some years.
Norm, this one's yours.
__________________
Please provide your feedback on our
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use Foreach on an Array Java Tip java.lang 0 04-17-2008 12:06 AM
Question regarding foreach loop... theonlywalks New To Java 2 03-15-2008 07:15 AM
foreach in jstl to display nested colums-struts jsp adil7 JavaServer Pages (JSP) and JSTL 1 02-11-2008 07:19 AM
Jstl Exception Handling vamsidharpoosarla JavaServer Pages (JSP) and JSTL 2 07-18-2007 07:17 AM
JSTL error Eric JavaServer Pages (JSP) and JSTL 1 06-11-2007 10:36 PM


All times are GMT +3. The time now is 01:33 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org