Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Null Arguement Question

Status
Not open for further replies.

BBobinski

Programmer
Oct 2, 2002
9
US
In a report called the Daily Bulletin I have a notification section. One of the fields is entitled NARRATIVE. If the rpdnotification table is empty, can I set the value of NARRITIVE to "None at this time" and have is display the same? I have tried several times but get no results. My code for that section is as follows.

TABLE rpdnotifiation
FIELDS are subject, authority, narrative, startdate, rundays, and rundays

Code is as follows

<% // Get NOTIFICATION from rpdnotifications
while(rsLog2.next()) {
String subject = rsLog2.getString("subject");
String authority = rsLog2.getString("authority");
String narrative = rsLog2.getString("narrative");
String startdate = rsLog2.getString("startdate");
String rundays = rsLog2.getString("rundays");
%>
<tr>
<td height="25" colspan="6"><table width="760" border="0" cellpadding="0" cellspacing="0" id="notification">
<tr>
<td width="123" height="25"><strong>?Entered:</strong> <%=startdate%></td>
<td width="485" height="25"><strong>?Subject: <%=subject%></strong></td>
<td width="152"><strong># of Days to Run:</strong> <%=rundays%></td>
</tr>
<tr>
<td height="25" colspan="3"><%=(narrative != null ? narrative : "None at this time")%>?</td>
</tr>
<tr>
<td height="25" colspan="3"><strong>?Authority: </strong><%=authority%></strong> ?</td>
</tr>
<tr>
<td height="25" colspan="3">?</td>
</tr>
<%
} // end of rsLog2 WHILE Loop
%>

 
do you get an error?

try

<%=((narrative != null && narrative.length() > 0) ? narrative : "None at this time")%>

=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
 
Tried your code - the results are still negative. Question - Does it have something to do with the WHILE LOOP. Does the LOOP have to be broken to show desired results?
 
Its nothing to do with the while loop.

Look at this code, which proves that jemminger's example will work perfectly :

Code:
public class Test {
 	public static void main(String args[]) {
		String narrative = null;
		System.err.println("narrative is '" +narrative +"'");
		System.err.println((narrative != null && narrative.length() > 0) ? narrative : "None at this time");
		narrative = "";
		System.err.println("\nnarrative is '" +narrative +"'");
		System.err.println((narrative != null && narrative.length() > 0) ? narrative : "None at this time");
		narrative = "abcdefg";
		System.err.println("\nnarrative is '" +narrative +"'");
		System.err.println((narrative != null && narrative.length() > 0) ? narrative : "None at this time");
    }
}

Are you sure that you are even entering the while loop (ie rs.next() == false) ?

--------------------------------------------------
Free Database Connection Pooling Software
 
I solved the Null Argument Problem. Weird - Code looked like it should have worked but when I ran Tests - Every time I placed the statement in the WHILE loop all I got was a blank page. So I attacked the problem form a new angle and ended up successful. I used the following code.

bullNotificationTrue.jsp - Displays Query Results
bullNotificationFalse.jsp - Displays "None at this time"

<% // Determine if the rpdnotification table is null or not and display results
String notificationFile = "bullNotificationTrue.jsp";
int cnt = 0;
while(rsLog2.next())
cnt++;
if (cnt == 0) notificationFile = "bullNotificationFalse.jsp";
%>
<tr>
<td height="25" colspan="6"><table width="760" border="0" cellpadding="0" cellspacing="0" id="notification">
<tr>
<td width="760" height="25" colspan="3"><jsp:include page="<%=notificationFile%>"></jsp:include></td>
</tr>
</table></td>
</tr>


Thanks again for the help



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top