[Idrs-commit] CVS: Idrs/dev/src/net/sourceforge/idrs/core/report NavNextChunk.java,NONE,1.1 NavPrevC
Brought to you by:
bigman921
|
From: Marc B. <big...@us...> - 2002-09-16 15:21:07
|
Update of /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/core/report
In directory usw-pr-cvs1:/tmp/cvs-serv13695
Added Files:
NavNextChunk.java NavPrevChunk.java NavigateChunk.java
Log Message:
Added data paging support, fixed hot deployment bug
--- NEW FILE: NavNextChunk.java ---
/*
NavNextChunk.java
Copyright (C) 2001 Marc Boorshtein
The contents of this file are subject to the Mozilla Public License Version 1.0 (the License);
you may not use this file except in compliance with the License. You may obtain a copy of the
License at http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific
language governing rights and limitations under the License.
*/
package net.sourceforge.idrs.core.report;
import java.io.*;
import java.util.*;
import java.net.*;
import net.sourceforge.idrs.utils.*;
import javax.servlet.http.*;
/**
Encapsulates any plain text found in an RML page
*/
public final class NavNextChunk extends NavigateChunk {
public NavNextChunk(String txt) {
super(txt);
}
protected int adjustPosition(DB db) throws Exception {
System.out.println("Curr Location : " + db.getCurrLocation());
System.out.println("Num Recs : " + db.getNumRecs());
return db.getCurrLocation();
}
}
--- NEW FILE: NavPrevChunk.java ---
/*
NavPrevChunk.java
Copyright (C) 2001 Marc Boorshtein
The contents of this file are subject to the Mozilla Public License Version 1.0 (the License);
you may not use this file except in compliance with the License. You may obtain a copy of the
License at http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific
language governing rights and limitations under the License.
*/
package net.sourceforge.idrs.core.report;
import java.io.*;
import java.util.*;
import java.net.*;
import net.sourceforge.idrs.utils.*;
import javax.servlet.http.*;
/**
Encapsulates any plain text found in an RML page
*/
public final class NavPrevChunk extends NavigateChunk {
public NavPrevChunk(String txt) {
super(txt);
}
protected int adjustPosition(DB db) throws Exception {
return db.getFirstRec() - db.getNumRecs();
}
}
--- NEW FILE: NavigateChunk.java ---
/*
NavigateChunk.java
Copyright (C) 2001 Marc Boorshtein
The contents of this file are subject to the Mozilla Public License Version 1.0 (the License);
you may not use this file except in compliance with the License. You may obtain a copy of the
License at http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific
language governing rights and limitations under the License.
*/
package net.sourceforge.idrs.core.report;
import java.io.*;
import java.util.*;
import java.net.*;
import net.sourceforge.idrs.utils.*;
import javax.servlet.http.*;
/**
Encapsulates any plain text found in an RML page
*/
public abstract class NavigateChunk implements Chunk, Serializable {
String text;
StringBuffer buff;
/**
Initializes the Chunk
@param text Text to be stored
*/
public NavigateChunk(String text) {
this.text = text;
buff = new StringBuffer();
}
protected abstract int adjustPosition(DB db) throws Exception ;
/**
Returns the link to the next page
@param head IDRSHead for report
*/
public String toString(IDRSHead head) throws Exception {
buff.setLength(0);
Enumeration paramNames;
String paramName;
String param;
HttpServletRequest request = head.getRequest();;
//loop through all parameters
buff.append("<a href=\"").append(request.getRequestURI()).append('?');
paramNames = request.getParameterNames();
DB db;
boolean returnLink = false;
int adjustedPos;
while (paramNames.hasMoreElements()) {
paramName = (String) paramNames.nextElement();
param = request.getParameter(paramName);
if (paramName.indexOf("_FirstRecord") != -1) {
db = head.getDB(paramName.substring(0,paramName.indexOf("_")));
adjustedPos = adjustPosition(db);
returnLink = returnLink || ((adjustedPos >= 0) && (adjustedPos <= db.getNumberRows()));
buff.append(paramName).append('=').append(adjustedPos).append('&');
}
else if (paramName.indexOf("_Reset") != -1) {
buff.append(paramName).append('=').append(0).append('&');
}
else {
buff.append(paramName).append('=').append(URLEncoder.encode(param)).append('&');
}
}
if (returnLink) {
buff.deleteCharAt(buff.length()-1);
buff.append("\">").append(text).append("</a>");
return buff.toString();
}
else {
return "";
}
}
}
|