Corrects bug 1748285 and 1738952 in the HTML Client

This commit is contained in:
rob_k 2007-07-19 04:17:32 +00:00
parent 297fbb0179
commit f74a1fcaf4
9 changed files with 210 additions and 110 deletions

View File

@ -64,7 +64,7 @@ public class WebDoc
{
WebDoc doc = create (title);
doc.getHead().addElement(new script((Element)null, "/adempiere/js/window.js"));
doc.getHead().addElement(new script((Element)null, "/adempiere/js/Calendar-setup.js"));
//doc.getHead().addElement(new script((Element)null, "/adempiere/js/Calendar-setup.js"));
doc.getHead().addElement(new script((Element)null, "/adempiere/js/calendar.js"));
doc.getHead().addElement(new script((Element)null, "/adempiere/js/table.js"));
doc.getHead().addElement(new script((Element)null, "/adempiere/lang/calendar-en.js"));
@ -74,6 +74,7 @@ public class WebDoc
doc.getHead().addElement(new link("/adempiere/css/calendar-blue.css", link.REL_STYLESHEET, link.TYPE_CSS));
doc.setClasses ("popupTable", "popupHeader");
doc.getTable().setCellSpacing(0);
return doc;
} // createPopup
@ -87,7 +88,7 @@ public class WebDoc
WebDoc doc = create (title);
doc.getHead().addElement(new script((Element)null, "/adempiere/js/window.js"));
doc.getHead().addElement(new script((Element)null, "/adempiere/js/Calendar-setup.js"));
//doc.getHead().addElement(new script((Element)null, "/adempiere/js/Calendar-setup.js"));
doc.getHead().addElement(new script((Element)null, "/adempiere/js/calendar.js"));
doc.getHead().addElement(new script((Element)null, "/adempiere/js/table.js"));
doc.getHead().addElement(new script((Element)null, "/adempiere/lang/calendar-en.js"));

View File

@ -100,11 +100,11 @@ public final class WFilter implements javax.servlet.Filter
throws IOException, ServletException
{
WebSessionCtx wctx = WebSessionCtx.get((HttpServletRequest)request);
if (wctx == null) {
/**if (wctx == null) {
if (m_filterConfig != null) {
String login_page = m_filterConfig.getInitParameter("LoginServlet");
if (login_page != null && !"".equals(login_page)) {
m_filterConfig.getServletContext().getRequestDispatcher(login_page).forward(request, response);
m_filterConfig.getServletContext().getRequestDispatcher("/WLogin").forward(request, response);
return;
}
}
@ -116,11 +116,18 @@ public final class WFilter implements javax.servlet.Filter
if (m_filterConfig != null) {
String login_page = m_filterConfig.getInitParameter("LoginServlet");
if (login_page != null && !"".equals(login_page)) {
m_filterConfig.getServletContext().getRequestDispatcher(login_page).forward(request, response);
return;
RequestDispatcher rd=request.getRequestDispatcher("/WLogin");
rd.forward(request, response);
return;
}
}
throw new ServletException("Unauthorized access, unable to forward to login page");
} **/
String sessionID = wctx.ctx.getProperty("#AD_Session_ID");
if (sessionID == null) {
//log.info("Still no session id");
}
// Get URI
@ -131,15 +138,38 @@ public final class WFilter implements javax.servlet.Filter
uri = req.getRequestURI();
}
boolean pass = true;
// Ignore static content
boolean check = true;
if (!uri.startsWith(WebEnv.DIR_BASE) // not requesting /adempiere/...
if (sessionID == null)
if(uri.endsWith("index.html")
|| uri.endsWith("cmd.html")
|| uri.endsWith("menu.html")
|| uri.endsWith("menu.js")
|| uri.endsWith("window.html")
|| uri.endsWith("Logo.gif")
|| uri.endsWith("standard.js")
|| uri.endsWith("standard.css")
|| uri.endsWith("calendar-blue.css")
|| uri.endsWith("table.css")
|| uri.endsWith("table.js")
|| uri.endsWith("calendar.js")
//|| uri.endsWith("calendar-setup.js")
|| uri.endsWith("calendar-en.js")
|| uri.endsWith("window.css")
|| uri.endsWith("window.js")
|| uri.endsWith("WLogin"))
;
else
pass = false;
else if (!uri.startsWith(WebEnv.DIR_BASE) // not requesting /adempiere/...
|| uri.endsWith(".gif") || uri.endsWith(".jpg") || uri.endsWith(".png")
|| uri.endsWith(".html") || uri.endsWith(".css")
|| uri.endsWith(".js"))
check = false;
//
boolean pass = true;
else
;
// We need to check
StringBuffer sb = new StringBuffer ("| Parameters");
@ -178,17 +208,19 @@ public final class WFilter implements javax.servlet.Filter
chain.doFilter(request, response);
else
{
log.warning("Rejected " + uri);
String msg = "Error: Access Rejected";
WebDoc doc = WebDoc.create (msg);
//log.warning("Rejected " + uri);
//String msg = "Error: Access Rejected";
//WebDoc doc = WebDoc.create (msg);
// Body
body b = doc.getBody();
b.addElement(new p(uri, AlignType.CENTER));
//body b = doc.getBody();
//b.addElement(new p(uri, AlignType.CENTER));
// fini
response.setContentType("text/html");
PrintWriter out = new PrintWriter (response.getOutputStream());
doc.output(out);
out.close();
//response.setContentType("text/html");
//PrintWriter out = new PrintWriter (response.getOutputStream());
//doc.output(out);
//out.close();
RequestDispatcher rd=request.getRequestDispatcher("/index.html");
rd.forward(request, response);
}
// Post
@ -198,6 +230,7 @@ public final class WFilter implements javax.servlet.Filter
myTime = System.currentTimeMillis() - myTime;
log.info("End " + uri + "| " + (m_timing ? String.valueOf(myTime) : null));
}
} // doFilter

View File

@ -57,6 +57,7 @@ public class WLookup extends HttpServlet
/** The Data List */
protected volatile ArrayList<Object> p_data = new ArrayList<Object>();
private static final int MAX_LINES = 5;
private StringBuffer HeaderSelect = null;
@ -100,10 +101,14 @@ public class WLookup extends HttpServlet
// Get Mandatory Parameters
String columnName = WebUtil.getParameter (request, "ColumnName");
//Lookup called from a process
//Modified by Rob Klein 4/29/07
int AD_Process_ID = WebUtil.getParameterAsInt(request, "AD_Process_ID");
//Lookup modified to include paging
//Modified by Rob Klein 07/07/07
int page = WebUtil.getParameterAsInt(request, "page");
log.info("This is the page on original call"+page);
if (AD_Process_ID > 0)
{
@ -145,14 +150,38 @@ public class WLookup extends HttpServlet
String script = targetBase + "F.value='';" + targetBase + "D.value='';closePopup();";
button.setOnClick(script);
//
// Next Page
String textbtn = "Next Page";
if (wsc.ctx != null)
text = Msg.getMsg (wsc.ctx, "Next Page");
input nextpgbtn = new input(input.TYPE_BUTTON, textbtn, " "+text);
int nextpage = (page+1);
nextpgbtn.setOnClick("startLookup('" + columnName + "', "+AD_Process_ID+", "+nextpage+");return false;");
nextpgbtn.setID(text);
nextpgbtn.setClass("nextpgbtn");
//Previous Page
textbtn = "Prior Page";
if (wsc.ctx != null)
text = Msg.getMsg (wsc.ctx, "Prior Page");
input prevpgbtn = new input(input.TYPE_BUTTON, textbtn, " "+text);
int prevpage = (page == 1) ? 1 : page-1;
prevpgbtn.setOnClick("startLookup('" + columnName + "', "+AD_Process_ID+", "+prevpage+");return false;");
prevpgbtn.setID(text);
prevpgbtn.setClass("prevpgbtn");
doc.getTable().addElement(new tr()
.addElement(fillTable(wsc, para.getColumnName(), para.getAD_Reference_Value_ID(), request.getRequestURI(),targetBase,false))
.addElement(fillTable(wsc, para.getColumnName(), para.getAD_Reference_Value_ID(), request.getRequestURI(),targetBase,false, page))
.addElement(nextpgbtn)
.addElement(prevpgbtn)
.addElement(button));
//
doc.addPopupClose(wsc.ctx);
// log.trace(log.l6_Database, doc.toString());
WebUtil.createResponse (request, response, this, null, doc, false);
}
//Lookup called from a window
else{
@ -184,7 +213,6 @@ public class WLookup extends HttpServlet
boolean hasCallout = mField.getCallout().length() > 0;
// Reset
// Reset
String text = "Reset";
if (wsc.ctx != null)
text = Msg.getMsg (wsc.ctx, "Reset");
@ -196,14 +224,36 @@ public class WLookup extends HttpServlet
if (hasDependents || hasCallout)
script += "startUpdate(" + targetBase + "F);";
restbtn.setOnClick(script);
//
//Next Page
String textbtn = "Next Page";
if (wsc.ctx != null)
text = Msg.getMsg (wsc.ctx, "Next Page");
input nextpgbtn = new input(input.TYPE_BUTTON, textbtn, " "+text);
int nextpage = (page+1);
nextpgbtn.setOnClick("startLookup('" + columnName + "', "+AD_Process_ID+", "+nextpage+");return false;");
nextpgbtn.setID(text);
nextpgbtn.setClass("nextpgbtn");
//Previous Page
textbtn = "Prior Page";
if (wsc.ctx != null)
text = Msg.getMsg (wsc.ctx, "Prior Page");
input prevpgbtn = new input(input.TYPE_BUTTON, textbtn, " "+text);
int prevpage = (page == 1) ? 1 : page-1;
prevpgbtn.setOnClick("startLookup('" + columnName + "', "+AD_Process_ID+", "+prevpage+");return false;");
prevpgbtn.setID(text);
prevpgbtn.setClass("prevpgbtn");
doc.getTable().addElement(new tr()
.addElement(fillTable(wsc, mField.getColumnName(), mField.getAD_Reference_Value_ID(), request.getRequestURI(),targetBase, hasDependents || hasCallout))
.addElement(restbtn));
//
.addElement(fillTable(wsc, mField.getColumnName(), mField.getAD_Reference_Value_ID(), request.getRequestURI(),targetBase, hasDependents || hasCallout, page))
.addElement(nextpgbtn)
.addElement(prevpgbtn));
//.addElement(restbtn));
doc.addPopupClose(ws.ctx);
// log.trace(log.l6_Database, doc.toString());
WebUtil.createResponse (request, response, this, null, doc, false);
}
} // doGet
@ -234,7 +284,7 @@ public class WLookup extends HttpServlet
* @return Table with selection
*/
private table fillTable (WebSessionCtx wsc, String columnName, int fieldRefId,
String action,String targetBase, boolean addStart)
String action,String targetBase, boolean addStart, int page)
{
/**
if (mField.getColumnName().equals("C_BPartner_ID"))
@ -263,7 +313,7 @@ public class WLookup extends HttpServlet
table.addElement("<tbody>");
// Fillout rows
table = fillTable_Lookup_Rows(wsc, columnName, fieldRefId, table, targetBase, true, true, true, false);
table = fillTable_Lookup_Rows(wsc, columnName, fieldRefId, table, targetBase, true, true, true, false, page);
table.addElement("</tbody>");
// Restore
@ -281,7 +331,7 @@ public class WLookup extends HttpServlet
*/
private table fillTable_Lookup_Rows (WebSessionCtx wsc, String columnName, int fieldRefId,
table table1, String targetBase, boolean mandatory, boolean onlyValidated, boolean onlyActive,
boolean temporary)
boolean temporary, int page)
{
ArrayList<Object> list = new ArrayList<Object>();
StringBuffer sqlSelect = null;
@ -392,11 +442,18 @@ public class WLookup extends HttpServlet
}
try
{
PreparedStatement pstmt = DB.prepareStatement(sqlSelect.toString(), null);
PreparedStatement pstmt = DB.prepareStatement(sqlSelect.toString(),
ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY, null);
pstmt.setInt(1, Env.getAD_Client_ID(wsc.ctx));
ResultSet rs = pstmt.executeQuery();
log.info("This is the page number "+page);
log.info("This is the MAX_LINES "+MAX_LINES);
rs.absolute(((page-1)*MAX_LINES)+1);
while (rs.next()){
for (int j= 1; j<= MAX_LINES; j++){
if(rs.next()){
StringBuffer name = new StringBuffer ("");
for (int i = 2; i <= size; i++)
{
@ -443,6 +500,7 @@ public class WLookup extends HttpServlet
}
table1.addElement(line);
}
}
rs.close();
pstmt.close();

View File

@ -80,6 +80,7 @@ public class WWindow extends HttpServlet
protected static final String FORM_NAME = "WForm";
//Modified by Rob Klein 4/29/07
protected static String sectionNameOld = null;
/** Hidden Parameter Command - Button */
@ -903,7 +904,6 @@ public class WWindow extends HttpServlet
tr line = new tr();
// First Column
//Modified by Rob Klein 4/29/07
//line.addElement(new th().addElement(" "));
line.addElement(new th().addElement(" "));
// Tab not displayed
if (!ws.curTab.isDisplayed())

View File

@ -464,10 +464,10 @@ public class WebField
button.setOnClick("startLocation('" + m_columnName + "');return false;");
else if (m_displayType == DisplayType.Account)
//modified by rob klein 4/29/07
button.setOnClick("startLookup('" + m_columnName + "', "+m_processID+");return false;");
button.setOnClick("startLookup('" + m_columnName + "', "+m_processID+", 1);return false;");
else
//modified by rob klein 4/29/07
button.setOnClick("startLookup('" + m_columnName + "', "+m_processID+");return false;");
button.setOnClick("startLookup('" + m_columnName + "', "+m_processID+", 1);return false;");
//Start Popup Menu
//Add by Rob Klein 6/6/2007

View File

@ -1,31 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
**********************************************************************
* This file is part of Adempiere ERP Bazaar *
* http://www.adempiere.org *
* *
* Copyright (C) 1999 - 2006 Compiere Inc. *
* Copyright (C) Contributors *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301, USA. *
* *
* Contributors: *
* - Bahman Movaqar (bmovaqar@users.sf.net) *
**********************************************************************
-->
<!-- edited with XMLSPY v2004 rel. 4 U (http://www.xmlspy.com) by Jorg Janke (ComPiere, Inc.) -->
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@ -49,10 +22,6 @@
<param-name>Timing</param-name>
<param-value>Y</param-value>
</init-param>
<init-param>
<param-name>LoginServlet</param-name>
<param-value>/WLogin</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>WFilter</filter-name>

View File

@ -99,6 +99,21 @@ td {
background:url(/adempiere/images/Delete16.gif) no-repeat left;
background-color:#ffffff;
}
.nextpgbtn {
cursor:pointer;
margin-top:5px;
border:outset 2px #ccc;
background:url(/adempiere/images/Next16.gif) no-repeat left;
background-color:#ffffff;
}
.prevpgbtn {
cursor:pointer;
margin-top:5px;
border:outset 2px #ccc;
background:url(/adempiere/images/Previous16.gif) no-repeat left;
background-color:#ffffff;
}
.Cerror {
background: #FF4A4A;
}

View File

@ -2,7 +2,6 @@
<html>
<head>
<title>ADempiere ERP+CRM Reach Client</title>
<script language="JavaScript" src="calendar2.js"></script>
<script type="text/javascript">

View File

@ -12,27 +12,28 @@ var deleteText = "ConfirmDelete";
/****************************************************************************
* Popup Menu variables
*/
var parentopener;
/****************************************************************************
* Field Update
***************************************************************************/
function fieldUpdate(e)
{
if (!top.WCmd) //{ no cmd frame
if (!top.WCmd) //{ no cmd frame
return;
// if (!top.myiframe.WCmd){
// return;
// }
// else{
// var d = top.myiframe.WCmd.document;
// var path = "top.myiframe.";
// }
//if (!top.myiframe.WCmd){
// return;
//}
//else{
// var d = top.myiframe.WCmd.document;
// var path = "top.myiframe.";
//}
//}
//else{
var d = top.WCmd.document;
var path = "top.";
//}
//}//
//if (!e) e = window.event;
@ -55,16 +56,16 @@ function fieldUpdate(e)
function createWCmd()
{
if (!top.WCmd) //{ no cmd frame
return;
if (!top.WCmd)//{ no cmd frame
return;
// if (!top.myiframe.WCmd){
// return;
// }
// else{
// var d = top.myiframe.WCmd.document;
// var path = "top.myiframe.";
// }
//if (!top.myiframe.WCmd){
// return;
//}
//else{
// var d = top.myiframe.WCmd.document;
// var path = "top.myiframe.";
//}
//}
//else{
var d = top.WCmd.document;
@ -202,9 +203,23 @@ function getRealValue (myValue)
* Open PopUp with Attachment Info
*/
function popUp(URL,name) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + name + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=300,left = 212,top = 234');");
day = new Date();
var id = day.getTime();
var callWindow;
browser = navigator.appName
if(browser=="Netscape" ){
if(window.parentopener){
callWindow = window.parentopener;
window.close();
}
else{
callWindow = window;
}
}
var openwindow = eval("page" + id + " = window.open(URL, '" + name + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=300,left = 212,top = 234');");
openwindow.parentopener = callWindow;
}
/****************************************************************************
@ -212,6 +227,7 @@ eval("page" + id + " = window.open(URL, '" + name + "', 'toolbar=0,scrollbars=1,
*/
function startPopup (targetCmd)
{
var url = targetCmd;
return popUp(url,targetCmd);
} // startPopup
@ -227,9 +243,10 @@ function closePopup ()
/****************************************************************************
* Lookup - get FormName and ColumnName and submit to WLookup
*/
function startLookup (columnName, processid)
function startLookup (columnName, processid, page)
{
var url = "WLookup?ColumnName=" + columnName+"&AD_Process_ID="+processid;
var url = "WLookup?ColumnName=" + columnName+"&AD_Process_ID="+processid+"&page="+page
return popUp(url,columnName);
} // startLookup
/****************************************************************************
@ -275,11 +292,19 @@ function startUpdate (column)
*/
function startLookUpdate(column, name1, value1, name2, value2)
{
browser = navigator.appName
if(browser=="Netscape" ){
var d = window.parentopener.document;
}
else{
var d = opener.document;
}
window.close();
opener.document.getElementById(name2).focus();
opener.document.getElementById(name1).value =value1;
opener.document.getElementById(name2).value =value2;
d.getElementById(name2).focus();
d.getElementById(name1).value =value1;
d.getElementById(name2).value =value2;
} // startLookUpdate