Search in sources :

Example 6 with WebDoc

use of org.compiere.util.WebDoc in project adempiere by adempiere.

the class WZoom method createPage.

//  doPost
/**
	 * 	Create Attachment Page
	 * 	@param ctx context
	 *	@param AD_Attachment_ID id for existing attachment
	 *	@param AD_Table_ID table for new attachment
	 *	@param Record_ID record for new attachment
	 *	@param error optional error message
	 *	@return WebDoc
	 */
public static WebDoc createPage(Properties ctx, HttpServletRequest request, int AD_Record_ID, int AD_Table_ID) {
    //WebDoc doc = WebDoc.createPopup (Msg.translate(ctx, "AD_Attachment_ID"));		
    WebDoc doc = null;
    String TableName = null;
    int AD_Window_ID = 0;
    int PO_Window_ID = 0;
    String sql = "SELECT TableName, AD_Window_ID, PO_Window_ID FROM AD_Table WHERE AD_Table_ID=?";
    try {
        PreparedStatement pstmt = DB.prepareStatement(sql, null);
        pstmt.setInt(1, AD_Table_ID);
        ResultSet rs = pstmt.executeQuery();
        if (rs.next()) {
            TableName = rs.getString(1);
            AD_Window_ID = rs.getInt(2);
            PO_Window_ID = rs.getInt(3);
        }
        rs.close();
        pstmt.close();
    } catch (SQLException e) {
        log.log(Level.SEVERE, sql, e);
    }
    if (TableName == null || AD_Window_ID == 0) {
        doc = WebDoc.createPopup("No Context");
        doc.addPopupClose(ctx);
        return doc;
    }
    //	PO Zoom ?
    boolean isSOTrx = true;
    if (PO_Window_ID != 0) {
        String whereClause = TableName + "_ID=" + AD_Record_ID;
        isSOTrx = DB.isSOTrx(TableName, whereClause);
        if (!isSOTrx)
            AD_Window_ID = PO_Window_ID;
    }
    /**
		 *  New Window data
		 */
    WWindowStatus ws = WWindowStatus.get(request);
    HttpSession sess = request.getSession();
    WebSessionCtx wsc = WebSessionCtx.get(request);
    if (ws != null) {
        int WindowNo = ws.mWindow.getWindowNo();
        log.fine("Disposing - WindowNo=" + WindowNo + ", ID=" + ws.mWindow.getAD_Window_ID());
        ws.mWindow.dispose();
        Env.clearWinContext(wsc.ctx, WindowNo);
    }
    GridWindowVO mWindowVO = GridWindowVO.create(ctx, s_WindowNo++, AD_Window_ID, 0);
    if (mWindowVO == null) {
        String msg = Msg.translate(ctx, "AD_Window_ID") + " " + Msg.getMsg(ctx, "NotFound") + ", ID=" + AD_Window_ID + "/" + 0;
        doc = WebDoc.createPopup(msg);
        doc.addPopupClose(ctx);
        return doc;
    }
    //  Create New Window
    ws = new WWindowStatus(mWindowVO);
    sess.setAttribute(WWindowStatus.NAME, ws);
    //  Query
    ws.mWindow.initTab(ws.curTab.getTabNo());
    ws.curTab.setQuery(MQuery.getEqualQuery(TableName + "_ID", AD_Record_ID));
    ws.curTab.query(false);
    return doc;
}
Also used : SQLException(java.sql.SQLException) WebDoc(org.compiere.util.WebDoc) HttpSession(javax.servlet.http.HttpSession) ResultSet(java.sql.ResultSet) GridWindowVO(org.compiere.model.GridWindowVO) PreparedStatement(java.sql.PreparedStatement) WebSessionCtx(org.compiere.util.WebSessionCtx)

Example 7 with WebDoc

use of org.compiere.util.WebDoc in project adempiere by adempiere.

the class WZoom method doPost.

//  doGet
/**
	 *  Process the HTTP Post request.
	 *  Update Attachment
	 *  @param request request
	 *  @parem response response
	 */
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    HttpSession sess = request.getSession(false);
    WWindowStatus ws = WWindowStatus.get(request);
    WebDoc doc = null;
    //		
    doc = WebDoc.create("Help - Post Not Implemented");
    //
    WebUtil.createResponse(request, response, this, null, doc, false);
}
Also used : HttpSession(javax.servlet.http.HttpSession) WebDoc(org.compiere.util.WebDoc)

Example 8 with WebDoc

use of org.compiere.util.WebDoc in project adempiere by adempiere.

the class WWindow method createLayout.

//	getMR_Form
/**
	 *  Create Window Layout.
	 *  @param action form action
	 *  @param contentTable content table
	 *  @param wsc web session context
	 *  @param ws window status
	 *  @param statusInfo status line info
	 *  @param statusDB status db info
	 *  @return Form
	 */
private WebDoc createLayout(String action, table contentTable, WebSessionCtx wsc, WWindowStatus ws, String statusInfo, String statusDB) {
    form myForm = null;
    myForm = new form(action);
    myForm.setID("WForm");
    myForm.setOnSubmit("this.target=window.name");
    String AD_Language = Env.getAD_Language(ws.ctx);
    //	Window
    myForm.setName(FORM_NAME);
    //  button commands
    myForm.addElement(new input("hidden", P_Command, ""));
    //  RowNo
    myForm.addElement(new input("hidden", P_MR_RowNo, ""));
    //  
    myForm.addElement(new input("hidden", P_ChangedColumn, ""));
    //  Set Title of main window
    String title = ws.mWindow.getName() + " - " + wsc.loginInfo;
    myForm.addElement(new script("top.document.title='" + title + "';"));
    //Modified by Rob Klein 4/29/07
    //	Buttons
    td toolbar = new td("toolbar", AlignType.LEFT, AlignType.MIDDLE, true);
    //	Toolbar
    toolbar.addElement(createImageLink(AD_Language, "Menu", "parent.resizeFrame('5,*')", true, false));
    toolbar.addElement(createImageLink(AD_Language, "Ignore", "'reset'", true, false));
    toolbar.addElement(" ");
    toolbar.addElement(createImageLink(AD_Language, "Help", "startPopup('WHelp?AD_Window_ID=" + ws.mWindow.getAD_Window_ID() + "')", true, false));
    toolbar.addElement(createImageLink(AD_Language, "New"));
    toolbar.addElement(createImageLink(AD_Language, "Delete", "'if(confirm(deleteText))'", true, false));
    toolbar.addElement(createImageLink(AD_Language, "Save"));
    toolbar.addElement(" ");
    toolbar.addElement(createImageLink(AD_Language, "Chat", "startPopup('WChat')", true, false));
    toolbar.addElement(createImageLink(AD_Language, "Refresh"));
    toolbar.addElement(createImageLink(AD_Language, "Attachment", "startPopup('WAttachment')", ws.curTab.canHaveAttachment(), ws.curTab.hasAttachment()));
    toolbar.addElement(createImageLink(AD_Language, "Multi", null, true, !ws.curTab.isSingleRow()));
    toolbar.addElement(createImageLink(AD_Language, "FindAdv", "startPopup('WFindAdv')", true, false));
    if (m_searchField != null) {
        input txtSearch = new input(input.TYPE_TEXT, "txtSearch", "[" + m_searchField + "]");
        txtSearch.setOnChange("SubmitForm('Find', 'Submit','toolbar');return false;");
        toolbar.addElement(txtSearch);
    }
    toolbar.addElement(" ");
    toolbar.addElement(createImageLink(AD_Language, "History", "startPopup('WHistory')", true, false));
    //toolbar.addElement(createImageLink (AD_Language, "History", 
    //	null, ws.mWindow.isTransaction()&&ws.curTab.getTabNo()==0, !ws.curTab.isOnlyCurrentRows()));
    toolbar.addElement(" ");
    boolean isFirst = ws.curTab.getCurrentRow() < 1;
    toolbar.addElement(createImageLink(AD_Language, "First", null, !isFirst, false));
    toolbar.addElement(createImageLink(AD_Language, "Previous", null, !isFirst, false));
    boolean isLast = ws.curTab.getCurrentRow() + 1 == ws.curTab.getRowCount();
    toolbar.addElement(createImageLink(AD_Language, "Next", null, !isLast, false));
    toolbar.addElement(createImageLink(AD_Language, "Last", null, !isLast, false));
    toolbar.addElement("&nbsp;");
    toolbar.addElement(createImageLink(AD_Language, "Report", "startPopup('WReport')", true, false));
    toolbar.addElement("&nbsp;");
    toolbar.addElement(createImageLink(AD_Language, "Favorite"));
    toolbar.addElement(createImageLink(AD_Language, "Exit"));
    //  Tabs
    td tabbar = new td("windowCenter", AlignType.LEFT, AlignType.MIDDLE, false);
    tabbar.addElement(new input(input.TYPE_HIDDEN, P_Tab, ""));
    for (int i = 0; i < ws.mWindow.getTabCount(); i++) {
        GridTab tab = ws.mWindow.getTab(i);
        if (tab.isSortTab())
            continue;
        //Modified by Rob Klein 4/29/07
        a big = new a("#", new span(tab.getName()));
        if (ws.curTab.getTabNo() == i)
            //  css
            big.setID("tabSelected");
        else {
            //Modified by Rob Klein 4/29/07
            //  css				
            big.setID("tab");
            big.setOnClick("SubmitForm(" + i + ",'Submit','tab')");
        }
        //  Status: Description
        if (tab.getDescription().length() > 0)
            big.setOnMouseOver("status='" + tab.getDescription() + "';return true;");
        if (tab.isReadOnly())
            tabbar.addElement(new i().addElement(big));
        else
            tabbar.addElement(big);
    }
    //	Top Table
    //Modified by Rob Klein 4/29/07
    table topTable = new table("0", "0", "0", "100%", null);
    topTable.setID("WWindow.topTable");
    topTable.addElement(new tr(toolbar));
    topTable.addElement(new tr(tabbar));
    myForm.addElement(topTable);
    //  Fields
    div panel = new div();
    panel.setStyle("overflow: scroll;overflow: auto;");
    panel.addElement(contentTable);
    myForm.addElement(panel);
    //  Status Line
    table statusTable = new table("0", "0", "0", "100%", null);
    topTable.setID("WWindow.statusLine");
    tr statusLine = new tr();
    statusLine.addElement(new td().setWidth("85%").setAlign(AlignType.LEFT).addElement("&nbsp;# " + statusInfo));
    a db = new a("#");
    db.setOnClick("alert('" + ws.curTab.getKeyColumnName() + " = " + ws.curTab.getRecord_ID() + "')");
    db.addElement(statusDB);
    statusLine.addElement(new td().setWidth("10%").setAlign(AlignType.RIGHT).addElement(db));
    statusLine.addElement(new td().setWidth("5%").setAlign(AlignType.RIGHT).addElement(createImageLink(AD_Language, "Save")));
    statusTable.addElement(statusLine).setClass("windowCenter");
    myForm.addElement(statusTable);
    //Beg Modified by Rob Klein
    //div menupop = new div();
    //menupop.setOnMouseOver("clearhidemenu()");
    //menupop.setOnMouseOut("dynamichide(event)");
    //menupop.setID("popitmenu");
    //myForm.addElement(menupop);
    //End Modified by Rob Klein
    //  fini
    /** @todo Dynamic Display */
    //	myForm.addElement(new script("dynDisplay(); createWCmd();"));   //  initial Display & set Cmd Window
    WebDoc doc = createPage(ws);
    //	Main Table
    doc.getTable().addElement(new tr().addElement(new td(null, AlignType.CENTER, AlignType.MIDDLE, true, myForm).setColSpan(2)));
    //
    return doc;
}
Also used : org.apache.ecs.xhtml.a(org.apache.ecs.xhtml.a) org.apache.ecs.xhtml.i(org.apache.ecs.xhtml.i) org.apache.ecs.xhtml.script(org.apache.ecs.xhtml.script) org.apache.ecs.xhtml.td(org.apache.ecs.xhtml.td) org.apache.ecs.xhtml.div(org.apache.ecs.xhtml.div) org.apache.ecs.xhtml.input(org.apache.ecs.xhtml.input) org.apache.ecs.xhtml.form(org.apache.ecs.xhtml.form) GridTab(org.compiere.model.GridTab) WebDoc(org.compiere.util.WebDoc) org.apache.ecs.xhtml.table(org.apache.ecs.xhtml.table) org.apache.ecs.xhtml.tr(org.apache.ecs.xhtml.tr) org.apache.ecs.xhtml.span(org.apache.ecs.xhtml.span)

Example 9 with WebDoc

use of org.compiere.util.WebDoc in project adempiere by adempiere.

the class WReport method doPost.

//  doGet
/**
	 *  Process the HTTP Post request
	 */
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    WebDoc doc = WebDoc.createPopup("Report - Post - Not Implemented");
    WebUtil.createResponse(request, response, this, null, doc, false);
}
Also used : WebDoc(org.compiere.util.WebDoc)

Example 10 with WebDoc

use of org.compiere.util.WebDoc 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);
}
Also used : WebDoc(org.compiere.util.WebDoc) MQuery(org.compiere.model.MQuery) GridField(org.compiere.model.GridField) WebSessionCtx(org.compiere.util.WebSessionCtx) File(java.io.File)

Aggregations

WebDoc (org.compiere.util.WebDoc)58 WebSessionCtx (org.compiere.util.WebSessionCtx)21 HttpSession (javax.servlet.http.HttpSession)13 org.apache.ecs.xhtml.td (org.apache.ecs.xhtml.td)13 org.apache.ecs.xhtml.p (org.apache.ecs.xhtml.p)12 org.apache.ecs.xhtml.tr (org.apache.ecs.xhtml.tr)12 org.apache.ecs.xhtml.table (org.apache.ecs.xhtml.table)11 org.apache.ecs.xhtml.body (org.apache.ecs.xhtml.body)9 org.apache.ecs.xhtml.input (org.apache.ecs.xhtml.input)9 org.apache.ecs.xhtml.form (org.apache.ecs.xhtml.form)8 org.apache.ecs.xhtml.script (org.apache.ecs.xhtml.script)7 Timestamp (java.sql.Timestamp)6 org.apache.ecs.xhtml.a (org.apache.ecs.xhtml.a)6 GridField (org.compiere.model.GridField)5 SQLException (java.sql.SQLException)4 org.apache.ecs.xhtml.i (org.apache.ecs.xhtml.i)4 File (java.io.File)3 IOException (java.io.IOException)3 Properties (java.util.Properties)3 ServletException (javax.servlet.ServletException)3