View source | View content page | Page history | Printable version   

Projects:Attachment icon/Technical Documentation

Contents

Show attachment status with icon - Technical Documentation

Implementation

Function which checks the attachments

In Utility.java is placed hasAttachments method that return true if the record has attachments or false if it hasn't.

 public static boolean hasAttachments(ConnectionProvider conn, VariablesSecureApp vars, String strTab, String recordId) throws IOException, ServletException {
   TabAttachmentsData[] data = TabAttachmentsData.selectTabInfo(conn, strTab);
   String tableId = "";
   if (data==null || data.length==0) throw new ServletException("Tab not found: " + strTab);
   else tableId = data[0].adTableId;
   
   data = TabAttachmentsData.select(conn, Utility.getContext(conn, vars, "#User_Client", ""), Utility.getContext(conn, vars, "#User_Org", ""), tableId, recordId);
   if (data!=null && data.length!=0) return true;
   else return false;
 } //Utility.java


Form view

Attachments checking is made when is created the toolbar class.

There is a new constructor for toolbar that has a new parameter hasAttachments of type boolean.

 void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strC_Order_ID) {
   ...
   ToolBar toolbar = new ToolBar(this, editableTab, vars.getLanguage(), "Header",
                    (strCommand.equals("NEW") || boolNew || (dataField==null && (data==null || data.length==0))),
                    "document.frmMain.inpcOrderId", "", "../RptC_Order.pdf", "N".equals("Y"), "SalesOrder", strReplaceWith,
                    true, false, false, Utility.hasAttachments(this, vars, tabId, strC_Order_ID));
   ...
 } //Header.java of SalesOrder


Grid view

There is a command CHECK implemented in TabAttachments.java, which return a page with the result of call "Utility.hasAttachments(...)" that is true or false.

The check in grids is made by the method appStatus.js/checkAttachmentIconRelation(), which makes an Ajax call to TabAttachments.java with command CHECK.

 cellClicked: function(evt) {
   ...
   checkAttachmentIconRelation();
 }
 
 goToRow: function(rowNo) {
   ...
   checkAttachmentIconRelation();
 } //DataGrid.js


Attachments window

When loading TabAttachments_F1.html appStatus.js/checkAttachmentIcon() is executed, which makes an Ajax call to TabAttachments.java with command CHECK.

So, when an attachment is added or deleted, the attach icon is updated. This works in form and grid view.

 function onLoadDo(){
   ...		
   top.opener.checkAttachmentIcon();
 } //TabAttachmets_F1.html

Retrieved from "http://wiki.openbravo.com/wiki/Projects:Attachment_icon/Technical_Documentation"

This page has been accessed 4,462 times. This page was last modified on 8 June 2012, at 05:26. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.