Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-12-2008, 07:10 PM   PM User | #1
BubikolRamios
Senior Coder

 
Join Date: Dec 2005
Location: Slovenia
Posts: 1,876
Thanks: 114
Thanked 76 Times in 76 Posts
BubikolRamios is on a distinguished road
format code

Code:
....
while(con.rs.next())
      {
      %>
                <a class = "knof" <%if (con.rs.getString("grupa").equals("2")) { %>style = "background:#43E87F;"<%}else if (con.rs.getString("grupa").equals("1")){%> style = "background:#CC9F1B;"<%}else{%> style = "background:#6798E0;" <%}%>> <%=con.rs.getString("naziv")%></a>
      <%
      }
.....
How to format this, are there any rules about that ?
BubikolRamios is offline   Reply With Quote
Old 10-15-2008, 12:14 PM   PM User | #2
shyam
Senior Coder

 
shyam's Avatar
 
Join Date: Jul 2005
Posts: 1,563
Thanks: 2
Thanked 163 Times in 160 Posts
shyam will become famous soon enough
there are no specific rules as such...but, you can define your own to improve readability...its going to be difficult to follow though
__________________
You never have to change anything you got up in the middle of the night to write. -- Saul Bellow
shyam is offline   Reply With Quote
Old 10-15-2008, 05:11 PM   PM User | #3
LoriQuaid
New to the CF scene

 
Join Date: Oct 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
LoriQuaid is an unknown quantity at this point
Try putting your conditional logic in a single scriplet which sets a local variable. For example:

....
while(con.rs.next())
{
String bg = "style = 'background:";
if (con.rs.getString("grupa").equals("2"))
bg += "#43E87F;' ";
else if (con.rs.getString("grupa").equals("1"))
bg += "#CC9F1B;' ";
else
bg += "#6798E0;' ";
%>
<a class = "knof" <%= bg %> ...
<%
}
.....
LoriQuaid is offline   Reply With Quote
Old 10-15-2008, 05:52 PM   PM User | #4
shyam
Senior Coder

 
shyam's Avatar
 
Join Date: Jul 2005
Posts: 1,563
Thanks: 2
Thanked 163 Times in 160 Posts
shyam will become famous soon enough
Quote:
Originally Posted by LoriQuaid View Post
Try putting your conditional logic in a single scriplet which sets a local variable.
actually its better not to use scriptlets at all...they can be a huge source of pain when trying to fix bugs later...instead use JSTL (tutorial - part1, part2)
__________________
You never have to change anything you got up in the middle of the night to write. -- Saul Bellow
shyam is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


Advertisement
Log in to turn off these ads.