use of org.compiere.util.WebSessionCtx in project adempiere by adempiere.
the class RequestServlet method doGet.
/**
* Process Get Request
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String l_szRequestID = null;
HttpSession sess = request.getSession(true);
sess.setMaxInactiveInterval(WebEnv.TIMEOUT);
ctx = getCtx();
if (sess.getAttribute("ctx") != null)
ctx = (Properties) sess.getAttribute("ctx");
WebSessionCtx wsc = (WebSessionCtx) sess.getAttribute(WebSessionCtx.NAME);
// Create New Request
if (wsc != null) {
String mode = WebUtil.getParameter(request, "Mode");
if (mode != null && mode.equals("RequestNew")) {
l_szRequestID = Request.createRequest(request, ctx);
} else if (mode != null && mode.equals("RequestChange")) {
l_szRequestID = Request.changeRequest(request, ctx);
}
}
String url = request.getParameter("ForwardTo") + l_szRequestID;
if (!url.startsWith("/"))
url = "/" + url;
response.sendRedirect(url);
}
use of org.compiere.util.WebSessionCtx in project adempiere by adempiere.
the class WReport method copyFormat.
// createNewFormat
/**
* Copy existing Format
* @param AD_PrintFormat_ID print format
* @param To_Client_ID to client
*/
private File copyFormat(int AD_PrintFormat_ID, int To_Client_ID, HttpServletRequest request, GridTab m_curTab, MQuery m_query) {
WebSessionCtx wsc = WebSessionCtx.get(request);
MPrintFormat pf = MPrintFormat.copyToClient(wsc.ctx, AD_PrintFormat_ID, To_Client_ID);
File file = launchReport(pf, request, m_curTab, m_query);
return file;
}
use of org.compiere.util.WebSessionCtx in project adempiere by adempiere.
the class WReport method getPrintFormats.
// doPost
/**
* Get the Print Formats for the table.
* Fill the list and the popup menu
* @param AD_Table_ID table
* @param invoker component to display popup (optional)
*/
private File getPrintFormats(int AD_Table_ID, HttpServletRequest request, GridTab m_curTab, MQuery m_query) {
WebSessionCtx wsc = WebSessionCtx.get(request);
WWindowStatus ws = WWindowStatus.get(request);
int AD_Client_ID = Env.getAD_Client_ID(wsc.ctx);
File file = null;
m_list = new ArrayList<KeyNamePair>();
//
String sql = MRole.getDefault().addAccessSQL("SELECT AD_PrintFormat_ID, Name, AD_Client_ID " + "FROM AD_PrintFormat " + "WHERE AD_Table_ID=? AND IsTableBased='Y' " + // Own First
"ORDER BY AD_Client_ID DESC, IsDefault DESC, Name", "AD_PrintFormat", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
KeyNamePair pp = null;
try {
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Table_ID);
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
if (rs.getInt(3) == AD_Client_ID) {
m_list.add(pp);
//m_popup.add(pp.toString()).addActionListener(this);
}
}
rs.close();
pstmt.close();
} catch (SQLException e) {
log.log(Level.SEVERE, sql, e);
}
// No Format exists - create it
if (m_list.size() == 0) {
if (pp == null)
// calls launch
file = createNewFormat(AD_Table_ID, request, m_curTab, m_query);
else
file = copyFormat(pp.getKey(), AD_Client_ID, request, m_curTab, m_query);
} else
// One Format exists or no invoker - show it
//else if (m_list.size() == 1 || invoker == null)
file = launchReport((KeyNamePair) m_list.get(0), request, m_curTab, m_query);
//m_popup.show(invoker, 0, invoker.getHeight()); // below button
return file;
}
use of org.compiere.util.WebSessionCtx in project adempiere by adempiere.
the class WReport method createNewFormat.
// getPrintFormats
/**
* Create and Launch new Format for table
* @param AD_Table_ID table
*/
private File createNewFormat(int AD_Table_ID, HttpServletRequest request, GridTab m_curTab, MQuery m_query) {
WebSessionCtx wsc = WebSessionCtx.get(request);
MPrintFormat pf = MPrintFormat.createFromTable(wsc.ctx, AD_Table_ID);
File file = launchReport(pf, request, m_curTab, m_query);
return file;
}
use of org.compiere.util.WebSessionCtx in project adempiere by adempiere.
the class WReport method doGet.
// init
/**
* Process the HTTP Get request
*/
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
log.fine("doGet");
log.info(response.toString());
WebSessionCtx wsc = WebSessionCtx.get(request);
WWindowStatus ws = WWindowStatus.get(request);
m_curTab = ws.curTab;
//
WebDoc doc = null;
File file = null;
if (ws == null) {
doc = WebDoc.createPopup("No Context");
doc.addPopupClose(wsc.ctx);
} else /**else if (fileName!=null)
{
int AD_PInstance_ID = WebUtil.getParameterAsInt(request, "AD_PInstance_ID");
File file = new File (fileName);
String error = WebUtil.streamFile(response, file);
if (error == null)
return;
doc = WebDoc.createWindow(error);
}**/
{
log.info("");
if (!MRole.getDefault().isCanReport(ws.curTab.getAD_Table_ID())) {
doc = WebDoc.createPopup("Access Cannot Report");
doc.addPopupClose(wsc.ctx);
}
// Query
MQuery query = new MQuery(m_curTab.getTableName());
// Link for detail records
String queryColumn = m_curTab.getLinkColumnName();
// Current row otherwise
if (queryColumn.length() == 0)
queryColumn = m_curTab.getKeyColumnName();
// Find display
String infoName = null;
String infoDisplay = null;
for (int i = 0; i < m_curTab.getFieldCount(); i++) {
GridField field = m_curTab.getField(i);
if (field.isKey())
infoName = field.getHeader();
if ((field.getColumnName().equals("Name") || field.getColumnName().equals("DocumentNo")) && field.getValue() != null)
infoDisplay = field.getValue().toString();
if (infoName != null && infoDisplay != null)
break;
}
if (queryColumn.length() != 0) {
if (queryColumn.endsWith("_ID"))
query.addRestriction(queryColumn, MQuery.EQUAL, new Integer(Env.getContextAsInt(wsc.ctx, m_curTab.getWindowNo(), queryColumn)), infoName, infoDisplay);
else
query.addRestriction(queryColumn, MQuery.EQUAL, Env.getContext(wsc.ctx, m_curTab.getWindowNo(), queryColumn), infoName, infoDisplay);
}
file = getPrintFormats(m_curTab.getAD_Table_ID(), request, m_curTab, query);
String error = WebUtil.streamFile(response, file);
if (error == null)
return;
doc = WebDoc.createWindow(error);
}
//
WebUtil.createResponse(request, response, this, null, doc, false);
}
Aggregations