Hello list,
please be lenient with me. I am new to QX and also to the objectorientated
programming.
In the main function there is a menu bar and a empty table (when the page is
loaded)
You can click in the menu "File--Open" and an modal window with an upload
widget appears. You can upload an file to a directory. This works fine.
Now I want to show the uploaded file in the table.
I made a function "getTableData" which gets the file information and makes
an array to show it in the table. (this works also if I put this into the
main window)
I tried to call the function "this.getTableData();" in the "getModalWindow1
: function()" and here in the "form.addListener('completed',function(e)"
because I thought this is the right place when the file is uploaded.
But I receive the error message
this.getTableData is not a function
How can I access from the "getModalWindow1" function the tablemodel in the
main function.
Any help and tips are apreciated.
best regards
Hansjoerg
-----------------------------------------------------------------
/* ************************************************************************
Copyright:
License:
Authors:
************************************************************************ */
/* ************************************************************************
#asset(firstQxApp/*)
************************************************************************ */
/**
* This is the main application class of your custom application
"firstQxApp"
*/
qx.Class.define("firstQxApp.Application",
{
extend : qx.application.Standalone,
/*
*****************************************************************************
MEMBERS
*****************************************************************************
*/
members :
{
/**
* This method contains the initial application code and gets called
* during startup of the application
*/
main : function()
{
// Call super class
this.base(arguments);
// Enable logging in debug variant
if (qx.core.Variant.isSet("qx.debug", "on"))
{
// support native logging capabilities, e.g. Firebug for Firefox
qx.log.appender.Native;
// support additional cross-browser console. Press F7 to toggle
visibility
qx.log.appender.Console;
}
/*
-------------------------------------------------------------------------
Below is your actual application code...
-------------------------------------------------------------------------
*/
var doc = this.getRoot();
//SEKTION Menu
var scroller = new qx.ui.container.Scroll();
var container = new qx.ui.container.Composite(new
qx.ui.layout.Canvas);
container.setPadding(5);
container.setAllowStretchX(false);
scroller.add(container);
this.getRoot().add(scroller, {edge : 0});
this.createCommands();
container.add(this.getMenuBar());
//END SEKTION Menu
var mainContainer = new qx.ui.container.Composite(new
qx.ui.layout.HBox(40));
this.getRoot().add(mainContainer, { top:220, left: 20 });
var Welcomelabel = new qx.ui.basic.Label(this.tr("Welcome to the
WebJobTicket"));
doc.add(Welcomelabel,{
left : 100,
top : 50
});
var tableModel = new qx.ui.table.model.Simple();
tableModel.setColumns([ this.tr("No"), this.tr("File"), this.tr("File
size"), this.tr("Pages") ]);
var table = new qx.ui.table.Table(tableModel);
table.setLayoutProperties({top: 120});
table.setLayoutProperties({left: 200});
table.setWidth(500);
table.setHeight(200);
with (table) {
getSelectionModel().setSelectionMode(qx.ui.table.selection.Model.SINGLE_SELECTION);
setColumnWidth(0, 50);
setColumnWidth(1, 200);
setColumnWidth(2, 80);
setColumnWidth(3, 150);
};
doc.add(table,{
left : 20,
top : 75
});
},//main function
getTableData : function(){
var req = new qx.io.remote.Request(
"http://localhost/PA/firstQxApp/getUserUploadFile.php",
"GET",
"application/json");
req.addListener("completed", function(e) {
try
{
var content = e.getContent();
if (content.length > 0) {
tableModel.setData(content);
}//if
}
catch (e)
{
alert("Fehler bei Erhalt der Tabellendaten: "
+ e.toString());
}
});
//}, this);
//req.setParameter("UserID", MyParam);
req.setParameter("UserID", 3);
req.send();
},
changeLanguage_de : function(){
//alert('Sprache de wechseln');
qx.locale.Manager.getInstance().setLocale('de');
},
changeLanguage_en : function(){
//alert('Sprache en wechseln');
qx.locale.Manager.getInstance().setLocale('en');
},
getModalWindow1 : function() {
var wm1 = new qx.ui.window.Window(this.tr("Please choose a file"));
wm1.setLayout(new qx.ui.layout.VBox(10));
wm1.setModal(true);
wm1.moveTo(150, 150);
/*
* SINGLE UPLOAD WIDGET
*/
var container = new qx.ui.container.Composite(new
qx.ui.layout.VBox(10));
var form = new
firstQxApp.UploadForm('uploadFrm','/uploads/upload.php');
form.setParameter('rm','upload');
form.setLayout(new qx.ui.layout.Basic);
container.add(form);
//mainContainer.add(container);
var file = new firstQxApp.UploadField('uploadfile', 'Upload
File','icon/16/actions/document-save.png');
form.add(file, {left:0,top:0});
form.addListener('completed',function(e) {
//var that = this;
this.debug('completed');
file.setFieldValue('');
var response = this.getIframeHtmlContent();
this.debug(response);
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
this.getTableData();
///////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
wm1.close();
});
//}, this);
form.addListener('sending',function(e) {
this.debug('sending');
});
file.addListener('changeFieldValue',function(e){
if(e.getData()!='') {
form.send();
}
});
wm1.add(container);
//alert('hallo');
//this.debug('this='+this);
return wm1;
//wm1.open();
},
//end function getmodal window
debugRadio : function(e) {
this.debug("Change selection: " + e.getData()[0].getLabel());
},
debugCommand : function(e) {
this.debug("Execute command: " + this.getShortcut());
},
debugButton : function(e) {
alert('Druecke Button' + this.getLabel());
this.debug("Execute button: " + this.getLabel());
},
debugCheckBox : function(e) {
this.debug("Change checked: " + this.getLabel() + " = " +
e.getData());
},
createCommands : function()
{
this._newCommand = new qx.ui.core.Command("Ctrl+N");
this._newCommand.addListener("execute", this.debugCommand);
this._openCommand = new qx.ui.core.Command("Ctrl+O");
this._openCommand.addListener("execute", this.debugCommand);
//this._openCommand.addListener("execute", this.wm1.open, this.wm1);
this._saveCommand = new qx.ui.core.Command("Ctrl+S");
this._saveCommand.addListener("execute", this.debugCommand);
this._undoCommand = new qx.ui.core.Command("Ctrl+Z");
this._undoCommand.addListener("execute", this.debugCommand);
this._redoCommand = new qx.ui.core.Command("Ctrl+R");
this._redoCommand.addListener("execute", this.debugCommand);
this._cutCommand = new qx.ui.core.Command("Ctrl+X");
this._cutCommand.addListener("execute", this.debugCommand);
this._copyCommand = new qx.ui.core.Command("Ctrl+C");
this._copyCommand.addListener("execute", this.debugCommand);
this._pasteCommand = new qx.ui.core.Command("Ctrl+P");
this._pasteCommand.addListener("execute", this.debugCommand);
this._pasteCommand.setEnabled(false);
},
getMenuBar : function()
{
var frame = new qx.ui.container.Composite(new qx.ui.layout.Grow);
var menubar = new qx.ui.menubar.MenuBar;
menubar.setWidth(600);
frame.add(menubar);
var fileMenu = new qx.ui.menubar.Button(this.tr("File"), null,
this.getFileMenu());
var editMenu = new qx.ui.menubar.Button(this.tr("Edit"), null);
var searchMenu = new qx.ui.menubar.Button(this.tr("Search"), null);
var viewMenu = new qx.ui.menubar.Button(this.tr("View"), null);
var optionsMenu = new qx.ui.menubar.Button(this.tr("Options"), null,
this.getOptionsMenu());
var helpMenu = new qx.ui.menubar.Button(this.tr("Help"), null);
menubar.add(fileMenu);
menubar.add(editMenu);
menubar.add(searchMenu);
menubar.add(viewMenu);
menubar.add(optionsMenu);
menubar.add(helpMenu);
return frame;
},
getFileMenu : function()
{
var menu = new qx.ui.menu.Menu;
var newButton = new qx.ui.menu.Button(this.tr("New"),
"icon/16/actions/document-new.png", this._newCommand);
//var openButton = new qx.ui.menu.Button("Open",
"icon/16/actions/document-open.png", this._openCommand);
var openButton = new qx.ui.menu.Button(this.tr("Open"),
"icon/16/actions/document-open.png", this._openCommand);
var closeButton = new qx.ui.menu.Button(this.tr("Close"));
var saveButton = new qx.ui.menu.Button(this.tr("Save"),
"icon/16/actions/document-save.png", this._saveCommand);
var saveAsButton = new qx.ui.menu.Button(this.tr("Save as..."),
"icon/16/actions/document-save-as.png");
var printButton = new qx.ui.menu.Button(this.tr("Print"),
"icon/16/actions/document-print.png");
var exitButton = new qx.ui.menu.Button(this.tr("Exit"),
"icon/16/actions/application-exit.png");
newButton.addListener("execute", this.debugButton);
//openButton.addListener("execute", this.debugButton);
var wm1 = this.getModalWindow1();
openButton.addListener("execute", wm1.open, wm1);
//openButton.addListener("execute", this.getModalWindow1);
closeButton.addListener("execute", this.debugButton);
saveButton.addListener("execute", this.debugButton);
saveAsButton.addListener("execute", this.debugButton);
printButton.addListener("execute", this.debugButton);
exitButton.addListener("execute", this.debugButton);
menu.add(newButton);
menu.add(openButton);
menu.add(closeButton);
menu.add(saveButton);
menu.add(saveAsButton);
menu.add(printButton);
menu.add(exitButton);
return menu;
},
getOptionsMenu : function()
{
var menu = new qx.ui.menu.Menu;
var panesButton = new qx.ui.menu.Button(this.tr("Choose language"),
null, null, this.getLanguagesMenu());
var syntaxButton = new qx.ui.menu.Button(this.tr("Syntax"), null,
null);
var rulerButton = new qx.ui.menu.CheckBox(this.tr("Show ruler"));
var numbersButton = new qx.ui.menu.CheckBox(this.tr("Show line
numbers"));
var asciiButton = new qx.ui.menu.Button(this.tr("ASCII table"));
rulerButton.addListener("changeValue", this.debugCheckBox);
numbersButton.addListener("changeValue", this.debugCheckBox);
asciiButton.addListener("execute", this.debugButton);
menu.add(panesButton);
menu.add(syntaxButton);
menu.addSeparator();
menu.add(rulerButton);
menu.add(numbersButton);
menu.addSeparator();
menu.add(asciiButton);
return menu;
}
}//members
/*
*****************************************************************************
DESTRUCTOR
*****************************************************************************
*/
});
---------------------------------------------------------------------
--
View this message in context:
http://old.nabble.com/How-to-access-tablemodel-in-main-function--tp27813228p27813228.html
Sent from the qooxdoo-devel mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel