a more permanent fix to that Find problem - moved the "static" functions

defined in the JSP to the FindData object and eliminated the InternalStateError
throw.  Lesson here, kids...just because you CAN do a thing doesn't mean you
SHOULD do a thing.
This commit is contained in:
Eric J. Bowersox 2001-11-19 09:16:11 +00:00
parent 6ec1986ba6
commit a376aad722
2 changed files with 44 additions and 44 deletions

View File

@ -390,4 +390,41 @@ public class FindData implements JSPRender, SearchMode
} // end getCatJumpLink } // end getCatJumpLink
public static String getCommunityHostName(CommunityContext comm)
{
try
{ // get the host name for the specified community
UserProfile prof = comm.getHostProfile();
return prof.getUserName();
} // end try
catch (DataException e)
{ // just return NULL if an exception strikes
return null;
} // end catch
} // end getCommunityHostName
public static int getCommunityMemberCount(CommunityContext comm)
{
try
{ // get the member count for the specified community
return comm.getMemberCount();
} // end try
catch (DataException e)
{ // just return -1 if an exception strikes
return -1;
} // end catch
} // end getCommunityMemberCount
public static String getActivityString(CommunityContext comm, RenderData rdat)
{
return rdat.getActivityString(comm.getLastAccessDate());
} // end getActivityString
} // end class FindData } // end class FindData

View File

@ -18,48 +18,8 @@
<%@ page import = "java.util.*" %> <%@ page import = "java.util.*" %>
<%@ page import = "com.silverwrist.util.StringUtil" %> <%@ page import = "com.silverwrist.util.StringUtil" %>
<%@ page import = "com.silverwrist.venice.core.*" %> <%@ page import = "com.silverwrist.venice.core.*" %>
<%@ page import = "com.silverwrist.venice.except.*" %>
<%@ page import = "com.silverwrist.venice.servlets.Variables" %> <%@ page import = "com.silverwrist.venice.servlets.Variables" %>
<%@ page import = "com.silverwrist.venice.servlets.format.*" %> <%@ page import = "com.silverwrist.venice.servlets.format.*" %>
<%!
private static String getCommunityHostName(CommunityContext comm)
{
try
{ // get the host name for the specified community
UserProfile prof = comm.getHostProfile();
return prof.getUserName();
} // end try
catch (DataException e)
{ // just return NULL if an exception strikes
return null;
} // end catch
} // end getCommunityHostName
private static int getCommunityMemberCount(CommunityContext comm)
{
try
{ // get the member count for the specified community
return comm.getMemberCount();
} // end try
catch (DataException e)
{ // just return -1 if an exception strikes
return -1;
} // end catch
} // end getCommunityMemberCount
private static String getActivityString(CommunityContext comm, RenderData rdat)
{
return rdat.getActivityString(comm.getLastAccessDate());
} // end getActivityString
%>
<% <%
FindData data = FindData.retrieve(request); FindData data = FindData.retrieve(request);
Variables.failIfNull(data); Variables.failIfNull(data);
@ -106,7 +66,10 @@ private static String getActivityString(CommunityContext comm, RenderData rdat)
<%= rdat.getStdFontTag(ColorSelectors.CONTENT_FOREGROUND,2) %> <%= rdat.getStdFontTag(ColorSelectors.CONTENT_FOREGROUND,2) %>
Display all categories whose name&nbsp;&nbsp; Display all categories whose name&nbsp;&nbsp;
<% } else throw new InternalStateError("display parameter " + data.getDisplayOption() + " invalid"); %> <% } else { %>
<%-- shouldn't get here --%>
<H1><FONT COLOR="red">Display parameter invalid!</FONT></H1>
<% } // end if %>
<SELECT NAME="mode" SIZE=1> <SELECT NAME="mode" SIZE=1>
<OPTION VALUE="<%= SearchMode.SEARCH_PREFIX %>" <OPTION VALUE="<%= SearchMode.SEARCH_PREFIX %>"
@ -254,8 +217,8 @@ private static String getActivityString(CommunityContext comm, RenderData rdat)
<% if (data.getDisplayOption()==FindData.FD_COMMUNITIES) { %> <% if (data.getDisplayOption()==FindData.FD_COMMUNITIES) { %>
<% <%
CommunityContext comm = (CommunityContext)item; CommunityContext comm = (CommunityContext)item;
String host_name = getCommunityHostName(comm); String host_name = FindData.getCommunityHostName(comm);
int members = getCommunityMemberCount(comm); int members = FindData.getCommunityMemberCount(comm);
%> %>
<A HREF="<%= rdat.getEncodedServletPath("sig/" + comm.getAlias()) %>"><%= StringUtil.encodeHTML(comm.getName()) %></A><BR> <A HREF="<%= rdat.getEncodedServletPath("sig/" + comm.getAlias()) %>"><%= StringUtil.encodeHTML(comm.getName()) %></A><BR>
<% if (host_name!=null) { %> <% if (host_name!=null) { %>
@ -266,7 +229,7 @@ private static String getActivityString(CommunityContext comm, RenderData rdat)
<%= members %> members <%= members %> members
<% } // end if (got member count) %> <% } // end if (got member count) %>
<% if ((host_name!=null) || (members>=0)) { %><BR><% } %> <% if ((host_name!=null) || (members>=0)) { %><BR><% } %>
Latest activity: <%= getActivityString(comm,rdat) %><BR> Latest activity: <%= FindData.getActivityString(comm,rdat) %><BR>
<EM><%= StringUtil.encodeHTML(comm.getSynopsis()) %></EM> <EM><%= StringUtil.encodeHTML(comm.getSynopsis()) %></EM>
<% } else if (data.getDisplayOption()==FindData.FD_USERS) { %> <% } else if (data.getDisplayOption()==FindData.FD_USERS) { %>