Hi;
Am having a challenge on how to modify the value of an entry(parmMonthofYear) which uses MonthOfYearId EDT during runtime through a controller. Prior to changing the value of the said entry, the user will select first an entry; which means the value of parmMonthYear will be based on the first entry. Any idea guys on how to deal with this. Thanks in advance.
If you’re talking about changing a field value in a dialog when user changes another value there, you have to add this logic to your UI builder class. The controller has nothing to do with it. But if you want to do it after closing the dialog, controller’s preRunModifyContract() is a good choice.
As you see, it’s important that you explain your requirement in detail.
Am a newbie, considering that I’ll do the coding within the preRunModifyContract(), can you give me a code snippet or say a site that can be a reference. Thanks.
Does it mean that doing it after closing a dialog meets your requirements, or did you just pick randomly one option and maybe will throw it away and start again, when you find that it doesn’t work as needed? It would be a waste of time for both of us.
This is a requirement where I do not know how to deal with changing the values during run-time considering that it will be done in preRunModifyContract(). The requirement is, I have two parameters, wherein the second parameter is dependent on the first parameter. The second parameter value will be based on the first parameter value. I already seen a site that is similar to my problem however what I’d like to achieve is to immediately set the value of the parameter. Here 's the link I’m referring to - vasantharivali.wordpress.com/…/
If you need to changes values in dialog, preRunModifyContract() won’t help you, because it runs after closing the dialog. It’s important to make clear what exactly you’re trying to achieve before designing the solution (and maybe writing some code later).
Unfortunately your statements such as “during run-time” and “is dependent” are too vague and can be interpreted in several ways. All code is executed at runtime, so it’s not useful information. And there may be many kind of dependencies, applied at any time. So still doesn’t explain even whether you want it in the dialog or not. I suggest you give us a use case. i.e. a description of steps what user does and how the system reacts.
I already design the said parameters using UI Builder. Below are the steps as follows:
- Dialog pop-ups.
- User selects an option (i.e. Daily, Monthly, Yearly) on the first parameter. Upon selecting an option, it will automatically fill-out the value of second parameter. For example, if the user selects DAILY, the value of the second parameter will be September 1, 2016 - September 28, 2016.
- When the user clicks on the OK button, this will render the report.
On the steps I stated above, only #2 is my problem.
Great, thank you. So playing with preRunModifyContract() wouldn’t help you to implement this particular requirement; you have to implement this in the UI builder class.
The first step is override modified() value of the first control and provide your own method to execute your code (let’s leave the content for later).
In the UI builder class, you can implement something like this:
public void postBuild()
{
DialogField df;
super();
// Find the automatically generated control
df = this.bindInfo().getDialogField(
his.dataContractObject(),
methodstr(YourDataContractClass, parmSomeField));
// Register override method
df.registerOverrideMethod(
methodstr(FormComboBoxControl, modified),
methodstr(YourUIBuilderClass, yourOverrideMethod), this);
}
(Note that this was written by hand without IntelliSense and compiler, so there may be mistakes.)
If you’re not familiar with UI builder class, just search the internet, you’ll easily find several articles.
Thank you Martin for the time. And I am sorry, let me re-iterate my challenge,
- A dialog box (created using UIBuilder) pop-up with two parameters but let me consider it as three because the second parameter is range (From and To)
- User selects an option in the first parameter it can be one of the following; DAILY, MONTHLY, YEARLY. The first parameter uses an EDT created by me where its values come from Base Enums.
- When the user selects the option DAILY, this will automatically set the value of second parameter. The second parameter is consists of FROM and TO entry. Therefore, these two entries will have of September 1, 2016 (FROM entry) and September 28, 2016 (TO entry).
Considering your code above and I will create a method like the the one below.
boolean yourOverrideMethod(FormComboBoxControl _control)
{
//Will this code set the value of FROM entry to a certain date?
//If not, how am I going to the value of From entry to a certain date?
dlgFrom.value(_control.valueStr());
return true;
}
Will it change the value of second parameter “FROM entry”?
In case of date controls, you want to use the dateValue() method and provide a value of the date type, instead of a string. And you’ll have to build the date value first, so you don’t want to assign _control.valueStr() there. First of all, try it with a fixed date (e.g. mkDate(28,9,2016)), to check that you know how to set the value. When it works, you can start looking at how to calculate the value for daily, monthly or yearly (got from selection() method). Don’t try to do many things at once.
Also, it will ‘change the value of second parameter “FROM entry”’ only if your dlgFrom variable contains a reference to that dialog field. Hopefully it does, but you can’t ask me, because I’ve never seen your code for doing that.
I will take this statement "Also, it will ‘change the value of second parameter “FROM entry”’ only if your dlgFrom variable contains a reference to that dialog field." as an answer for now. I’ll click on the This Helped Me link when it works.