LWUIT: overriding Dialog - java-me

I want to override Dialog so that it disposes itself the very moment it shows.

though it is a strange question, but you can override onShow() or onShowCompleted() and call dispose() inside one of them to close the dialog immediately.

Related

Acumatica override method in Receivre and Put Away

I am looking to customize Receivre and Put Away screen. After an Item code scaned. I want it go to Quantity enter Sacn state.
When an item scaned, should the method ProcessItemBarcode in PX.Objects.PO.ReceivePutAway.cs be called? I put an breakpoint in this method, but it never get hitted.
If it is this method called, how can I override this method? This method is defined as protected not public.
Thanks in advance.

I have added an OnPaint() function to my dialog class but its not getting called after dlg.DoModal()

Can anyone please help me understand how to override OnPaint() for a dialog class derived from CDialog.
Here is the code:
ColorImageDlg *pDlg = NULL;
pDlg = new ColorImageDlg;
pDlg->DoModal();
delete pDlg;
I'm overriding OnInitDialog() and it's getting called.
But while overriding OnPaint() it is not getting called.
Can any one please help me fixing it?
First of all what is the point of creating the instance of the dialog on heap? You can simply do:
ColorImageDlg dlg;
dlg.DoModal();
You need to modify your message map like this:
BEGIN_MESSAGE_MAP(ColorImageDlg, CDialog)
ON_WM_PAINT()
END_MESSAGE_MAP()
Use VS Class Wizard to avoid problems like that.
If you can't use the ClassWizard then there is another way. Here is a resource about it:
(VS2015 version) https://msdn.microsoft.com/en-us/library/dey7ke4c.aspx
(VS2008 version) https://msdn.microsoft.com/en-us/library/dey7ke4c(v=vs.90).aspx)
But basically, once you have defined the dialog resource and attached it to a new class, make sure the Class View tab is selected:
Next, make sure your dialog class is selected in the class view:
Then, click on the Messages icon of the Properties panel:
Scroll down the list of messages and locate WM_PAINT. Then click the dropdown arrow and select the option to add it:
As you can see, it has inserted all the needed code:
Hope this helps.

primefaces close dialog on init don't work

Im'using Primefaces 5.0 and I tried to use PF Dialog Framework features, but with some problems.
I open a dialog using openDialog() method.
In the dialog bean I managed an init() method annotated with #PostConstruct.
In that method I read parameters and load a list of records (to bind with a dataTable).
All seems work fine... dialog opens, I choose a record , close with closeReturn and so on.
But I want that in init(), if a single record was found, I could close immediately the dialog.
So I call closeDialog(), passing my bean... but nothing happens... the dialog opens and I have to close it manually.
And this is frustrating...
Could anyone help me?
Thanks
You can use primefaces requestContext to close the dialog from your bean.
#PostConstruct
public void init() {
recordList = loadListOfRecords();
if ( recordList.size() == 1 ) {
RequestContext.getCurrentInstance().execute('yourDialogWidgeVar.close()');
}
}
This is just a possibility to close a dialog from Bean. I don't know if it fits to your demands.
Please post your code next time. It is hard to figure out your problem without it.

LWUIT javame Dialog dispose

I cannot seem to make the dialog in my javame program disapear. I have used dispose but nothing. Any help. Here is the code
Dialog d=new Dialog("Comment added");
Label lb=new Label(response);
d.setLayout(new BorderLayout());
d.addComponent(BorderLayout.CENTER,lb);
d.show();
d.dispose();
the d.show(); blocks until the dialog disposes, therefore you are not getting to the next line of code.
add a Button to your dialog and on the button event invoke dispose.

LWUIT Dialog problem with dispose()

I am making a dialog with a command. This command must close the dialog and go back to the previous form, but it is not working as expected. When I press the command, it closes the dialog but the form do not go back.
I am using the resource editor. State machine controls the app´s navigation.
The code inside the command´s logic is:
dialog.dispose();
StateMachine.back();
Is dispose() the method that I must use to close my dialog?
Thanks for reading.
As Nirmal said disposing the dialog goes to the previous form so while your call to "back()" works as expected your call to dispose() breaks that logic.
You can override the postShow method for the form you are showing and detect the case of leaving the dialog (just turn on a flag when you need to go back) and call the back method when the form is shown in that condition.
dont call StateMachine.back() just use dialog.dispose();
There is another solution : try to use the protected void onShowCompleted() method that you must implement in your Form. And declare a boolean variable in your Form ( for example private boolean isDialogShown; ), then in the constructor of your Form set that boolean variable to false, and just before the code of opening the Dialog set its value to true. Then in the code of the protected void onShowCompleted() test if it is true , and if it is true then set it to false and perform the back action : backForm.showBack();

Resources