Context context,
RunData rundata )
{
int resultSetSize, next, prev, windowSize;
BrowserIterator iterator = getDatabaseBrowserIterator(portlet, rundata);
String sortColName = getRequestParameter(portlet, rundata, SORT_COLUMN_NAME);
int start = getStartVariable(portlet, rundata, START, sortColName, iterator);
windowSize = Integer.parseInt((String)getParameterUsingFallback(portlet, rundata, WINDOW_SIZE, "10"));
next = start + windowSize;
prev = start - windowSize;
try
{
if(iterator == null || PortletSessionState.getPortletConfigChanged(portlet, rundata))
{
String sql = getQueryString(portlet, rundata, context);
//System.out.println("buildNormalContext SQL: "+sql);
if(sql != null )
{
readUserParameters(portlet,rundata,context);
getRows(portlet, rundata, sql, windowSize);
iterator = getDatabaseBrowserIterator(portlet, rundata);
}
else
{
logger.info("The sql query is null, hence not generating the result set.");
}
}
else
{
if(sortColName != null)
{
iterator.sort(sortColName);
}
iterator.setTop(start);
}
readLinkParameters(portlet, rundata, context);
if(iterator != null)
{
resultSetSize = iterator.getResultSetSize();
if(next < resultSetSize)
{
context.put(NEXT, String.valueOf(next));
}
if(prev <= resultSetSize && prev >=0 )
{
context.put(PREVIOUS, String.valueOf(prev));
}
context.put(BROWSER_ITERATOR, iterator);
context.put(BROWSER_TITLE_ITERATOR, iterator.getResultSetTitleList());
context.put(BROWSER_TABLE_SIZE, new Integer(resultSetSize));
/*
System.out.println("buildNormalContext Sort column name= "+sortColName);
System.out.println("buildNormalContext Iterator: "+iterator);