Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSTL String in Loop

 
Steve Dyke
Ranch Hand
Posts: 1619
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to create a string in the JSTL loop by concatenating a "0" with the varStatus property. However the following seems to drop the "0".

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What the heck is faiInspectionLocationLogHoldLocationOption? and why would it have a leading zero?

The appropriate approach would be to fix the data rather than jumping through hoops in the JSP.
 
Steve Dyke
Ranch Hand
Posts: 1619
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:What the heck is faiInspectionLocationLogHoldLocationOption? and why would it have a leading zero?

The appropriate approach would be to fix the data rather than jumping through hoops in the JSP.


Remember you asked:

My record location options from datatable are:
1 CMM Room
2 Tooling Inspection

I am providing a form that the user can fill out using barcodes.

Well, guess what? Single digit barcodes will not scan so the option is to make it 01, 02.

Now the user can choose an option to repeat the previous entries. The input for the location option is a drop down list. So the faiInspectionLocationLogHoldLocationOption is a stored session attribute that needs to match the foreach loop varStatus so it knows what should be auto selected.
 
Stefan Evans
Bartender
Posts: 1712
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My solution if you are going for a minimal fix




Other leading questions
Why is "faiInspectionLocationLogHoldLocationOption" a number formatted in this way?
As opposed to something like the VALUE that should be selected from the dropdown?

Rather than writing out a select tag and options, conditionally marking one as selected (ie doing it manually) my preference is to use a framework which provides JSP tags to accomplish the task
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic