[Idrs-commit] CVS: Idrs/dev/src/net/sourceforge/idrs/core/report NavCurFormChunk.java,NONE,1.1 Navig
Brought to you by:
bigman921
|
From: Marc B. <big...@us...> - 2003-03-26 23:03:34
|
Update of /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/core/report
In directory sc8-pr-cvs1:/tmp/cvs-serv6946/dev/src/net/sourceforge/idrs/core/report
Modified Files:
NavigateChunk.java
Added Files:
NavCurFormChunk.java
Log Message:
refactored navigation tags, also added a <navcur> tag that generates a link that will kepp a page it it's current state, minus any specified parameters.
--- NEW FILE: NavCurFormChunk.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 NavCurFormChunk extends NavigateChunk {
LinkedList ignore;
public NavCurFormChunk(String signore) {
super("");
ignore = new LinkedList();
StringTokenizer tok = new StringTokenizer(signore,",",false);
while (tok.hasMoreTokens()) {
ignore.add(tok.nextToken());
}
}
protected int adjustPosition(DB db) throws Exception {
int currPos = db.getCurrLocation();
/*System.out.println("Name : " + db.getID());
System.out.println("Current Pos: " + currPos);
System.out.println("Number Rows : " + db.getNumberRows());
System.out.println("Num Recs : " + db.getNumRecs());*/
// if (currPos >= db.getNumberRows()) {
return db.getFirstRec();
//}
//else {
//return currPos;
// }
}
public String toString(IDRSHead head) throws Exception {
String params = super.toStringForm(head,ignore);
return params;
}
}
Index: NavigateChunk.java
===================================================================
RCS file: /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/core/report/NavigateChunk.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** NavigateChunk.java 26 Mar 2003 21:33:06 -0000 1.5
--- NavigateChunk.java 26 Mar 2003 23:03:22 -0000 1.6
***************
*** 117,119 ****
--- 117,186 ----
}
+
+ public String toStringForm(IDRSHead head,LinkedList ignore) throws Exception {
+ buff.setLength(0);
+
+
+ Enumeration paramNames;
+ String paramName;
+ String param;
+ HttpServletRequest request = head.getRequest();;
+ //loop through all parameters
+
+ paramNames = request.getParameterNames();
+ DB db;
+
+ boolean returnLink = false;
+ int adjustedPos;
+
+ Iterator it = head.dbs.keySet().iterator();
+ while (it.hasNext()) {
+ db = (DB) head.dbs.get(it.next());
+ if (db.getIsPaged()) {
+ if (ignore != null ? ! ignore.contains(db.getID() + "_Reset") : true) buff.append("<INPUT TYPE=\"HIDDEN\" NAME=\"").append(db.getID()).append("_Reset\" VALUE-\"false\">").append('\n');
+ if (ignore != null ? ! ignore.contains(db.getID() + "_PageSize") : true)buff.append("<INPUT TYPE=\"HIDDEN\" NAME=\"").append(db.getID()).append("_PageSize\" VALUE=\"").append(db.getNumRecs()).append("\">\n");
+
+ adjustedPos = adjustPosition(db);
+ //System.out.println("Begining : " + adjustedPos);
+ returnLink = returnLink || ((adjustedPos >= 0) && (adjustedPos <= db.getNumberRows()));
+
+ if (ignore != null ? ! ignore.contains(db.getID() + "_Reset") : true) buff.append("<INPUT TYPE=\"HIDDEN\" NAME=\"").append(db.getID()).append("_FirstRecord\" VALUE=\"").append(adjustedPos).append("\">\n");
+ }
+ }
+
+
+
+ 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);
+ //System.out.println("Begining : " + adjustedPos);
+ returnLink = returnLink || ((adjustedPos >= 0) && (adjustedPos <= db.getNumberRows()));
+
+ buff.append(paramName).append('=').append(adjustedPos).append('&');
+ }
+ else if (paramName.indexOf("_Reset") != -1) {
+ buff.append(paramName).append("=false").append('&');
+ }
+ else {*/
+ if ((ignore != null ? ! ignore.contains(param) : true) && paramName.indexOf("_Reset") == -1 && paramName.indexOf("_FirstRecord") == -1 && paramName.indexOf("_Reset") == -1) {
+ buff.append("<INPUT TYPE=\"HIDDEN\" NAME=\"").append(paramName).append("\" VALUE=\"").append(URLEncoder.encode(param)).append("\">\n");
+ }
+ }
+
+
+ buff.deleteCharAt(buff.length()-1);
+ //buff.append("\">").append(text).append("</a>");
+ return buff.toString();
+
+
+ }
+
+
}
|