How to open ZK custom forms from a toolbar button/java class.

269 views
Skip to first unread message

Pedro Rozo

unread,
Dec 7, 2016, 12:59:34 PM12/7/16
to iDempiere
In previous releases of smartpos we have open existent windows at the end of a process, with the existent method:

String whereString = " smj_closecash_ID= "+elementId+" "; 
MQuery query = new MQuery("smj_closecash"); 
query.addRestriction(whereString); 
int AD_Window_ID = 1000004; // close cash window is 1000004
AEnv.zoom(AD_Window_ID, query);



But now we have  to open custom forms (zk based), they  are already working from the normal menu but we have to open them at the end from a custom toolbar button /java class now. 

Analyzing the source code we have tried with this approach, and thogh we do not get any exception, nothing is displayed .. so it looks we have something missing, any suggestion ....?


public class ProductButton implements IAction {

@Override
public void execute(Object target) {

ADWindow window = (ADWindow) target;
ADWindowContent content = window.getADWindowContent();
GridTab tab = content.getActiveGridTab();
        log.info("boton pressed" + tab.getRecord_ID());
try {
WQueryProducts wProducts;
wProducts = new WQueryProducts();
GridTab grid = window.getADWindowContent().getActiveGridTab();
   ADForm.openForm(1000001,grid);

Thanks in advance for your comments,

Pedro R

Murilo Habermann Torquato

unread,
Dec 7, 2016, 2:45:10 PM12/7/16
to iDempiere
Hi Pedro,

Take a look at "Special Form" field ad REport & Process window (AD_Process.AD_Form_ID).

It opens a form BEFORE running the process, maybe looking at how it's implemented can help you on something.

BR

Pedro Rozo

unread,
Dec 7, 2016, 3:58:04 PM12/7/16
to iDempiere
Thanks Murillo, your suggestion and some testing guide us to the correct scenario and it works now , here the final code for a generic method ..

public static void open(ADForm form, String title) {
form.setTitle(title);
form.setAttribute(Window.MODE_KEY, form.getWindowMode());
SessionManager.getAppDesktop().showWindow(form);
Reply all
Reply to author
Forward
0 new messages