NullPointer exception when using AEnv.zoom wiht Idempiere (same code works on Adempiere 3.6.1)

221 views
Skip to first unread message

Pedro Rozo

unread,
Dec 3, 2013, 10:01:27 AM12/3/13
to idem...@googlegroups.com
Hi everyone

I am trying to use the zoom functionality to open a Material Receipt document at the end of a process with Idempiere, I already have done it with  Adempiere without any issues, but with idempiere I have spent a couple of hours and it doesn´t work .. I got a null pointer exception all the time, is there any change in the API ?  anythng wrong with my code, this is the source code:

public static boolean openWindow2(Integer windowId, String table, Integer record){
 String whereString = " "+table+"_ID= "+record+" "; 
 MQuery query = new MQuery(table); 
 query.addRestriction(whereString); 
 int AD_Window_ID = windowId; 
 AEnv.zoom(AD_Window_ID, query);
 return true; 
}//openWindow2

I am using a valid window_id  from the AD ( similar to adempiere) 

windowId  = 184  //Material receipit window id
table= m_inout   // table name
record= 1000006  // existent material receipt document


I am just got this exception, any suggestions: 

GRAVE: org.adempiere.webui.exception.ApplicationException
java.lang.NullPointerException
at org.zkoss.zk.ui.Executions.createComponents(Executions.java:179)
at org.adempiere.webui.adwindow.ADWindowToolbar.createButton(ADWindowToolbar.java:230)
at org.adempiere.webui.adwindow.ADWindowToolbar.init(ADWindowToolbar.java:148)
at org.adempiere.webui.adwindow.ADWindowToolbar.<init>(ADWindowToolbar.java:141)
at org.adempiere.webui.adwindow.AbstractADWindowContent.initComponents(AbstractADWindowContent.java:237)
at org.adempiere.webui.adwindow.AbstractADWindowContent.<init>(AbstractADWindowContent.java:197)
at org.adempiere.webui.adwindow.ADWindowContent.<init>(ADWindowContent.java:71)
at org.adempiere.webui.adwindow.ADWindow.init(ADWindow.java:102)
at org.adempiere.webui.adwindow.ADWindow.<init>(ADWindow.java:93)
at org.adempiere.webui.desktop.TabbedDesktop.showZoomWindow(TabbedDesktop.java:251)
at org.adempiere.webui.apps.AEnv.showZoomWindow(AEnv.java:405)
at org.adempiere.webui.apps.AEnv.zoom(AEnv.java:417)
at org.adempiere.webui.apps.AEnv.zoom(AEnv.java:160)
at org.smj.process.LoadProducts.openWindow(LoadProducts.java:316)
at org.smj.process.LoadProducts.start(LoadProducts.java:137)
at org.smj.process.LoadProducts.doIt(LoadProducts.java:72)
at org.compiere.process.SvrProcess.process(SvrProcess.java:176)
at org.compiere.process.SvrProcess.startProcess(SvrProcess.java:122)
at org.adempiere.util.ProcessUtil.startJavaProcess(ProcessUtil.java:172)
at org.compiere.apps.AbstractProcessCtl.startProcess(AbstractProcessCtl.java:466)
at org.compiere.apps.AbstractProcessCtl.run(AbstractProcessCtl.java:234)
at org.adempiere.webui.apps.WProcessCtl.process(WProcessCtl.java:158)
at org.adempiere.webui.apps.ProcessDialog$ProcessDialogRunnable.doRun(ProcessDialog.java:852)
at org.adempiere.util.ContextRunnable.run(ContextRunnable.java:38)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Regards 

Pedro Rozo


Heng Sin Low

unread,
Dec 3, 2013, 10:33:37 AM12/3/13
to idem...@googlegroups.com
The difference is idempiere process is running as background thread, off the UI thread. To perform any UI operations you need to use the AEnv.executeAsyncDesktopTask(Runnable) api.


--
You received this message because you are subscribed to the Google Groups "iDempiere" group.
To unsubscribe from this group and stop receiving emails from it, send an email to idempiere+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/8bce3a26-8a62-4411-bb03-24c9d21c3eea%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Pedro Rozo

unread,
Dec 3, 2013, 11:40:55 AM12/3/13
to idem...@googlegroups.com
Thanks hengsin,  it is working now, here a simple example for other people looking about it:


public static boolean openWindow(Integer windowId, String table, Integer record){
OpenWindow ow = new OpenWindow();
ow.windowId = windowId;
ow.table = table;
ow.record = record;
AEnv.executeAsyncDesktopTask(ow);
 return true; 
}//openWindow


public class OpenWindow implements Runnable {

public Integer windowId;
public String table;
public Integer record; 
@Override
public void run() {
String whereString = " "+table+"_ID= "+record+" ";
 MQuery query = new MQuery(table); 
  query.addRestriction(whereString);    // restriction was removed
  String tabla = query.getZoomTableName();

Carlos Antonio Ruiz Gomez

unread,
Dec 3, 2013, 12:18:27 PM12/3/13
to idem...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages