I have a set of feature toggles configured in an ENUM.
If I insert a value into the TOGGLZ table, i can override this flag.
How can I block this? Is my config wrong?
getFlag(my_fag) == false;
insert into TOGGLZ values ('my_flag','1','null','null')
getFlag(my_fag) == true; // i expect false
Any one an idea?
Related
I have an existing database, and if I define a new bool hide_in_main_screen = false; property in my objectbox class, and I query it like Store.box<TM>().query(TM_.hide_in_main_screen.equals(false)).build().find(), I got 0 items.
If I query the whole table I see that this property value is false.
Why I don't get the items, and how can I solve this problem?
Based on this objectbox issue information, I created a db migration routine and filled the new properties with default values.
Suppose in Hash map of java collections has already a pair 0,"Ram" and I add a new pair 0,"Sham" with same key. I knew it override the value and at last we get the 0,"Sham" in hash set.
My Questions is Why "Sham" i.e newer element override the "Ram" i.e. previous element? Is there any function to stop this overriding or I should use if-else conditions to make a check on it?
You can write your own put method using delegation technique, if any value already present in map, ignore the calling of put and returns false status.
boolean putIfNotPresent(Map map, Object key, Object value){
if(map.get(key)==null){
map.put(key, value);
return true;
}else{
return false;
}
}
Why value is overridden by default :
Its all about use case of functionality. Java implemented the most common use-case. And there are options for any specific use-case .
I have modified a validate method of form control. On this control I'm typing the product name.
In validate method I'm checking if this product name exists in the table. If it does not exists the error is thrown.
My issue is that after the error is thrown I want to clear control. Here is my code:
public boolean validate()
{
InventTable inventTable;
boolean ret = super();
select inventTable
where inventTable.nameAlias == this.text();
if (!inventTable.recid)
{
error("error");
this.text("");
}
return ret;
}
this.text(""); does not work. So how can I clear the control? The control is a field from my datasource.
In validate methods you do not need to clear the field. The system does that for you when validate returns false.
So instead of this.text('')) just return false.
But I doubt that the idea of users entering the full name is really useful at all.
If you use NameAlias as an alternate item number an even easier option exist.
Change the AliasFor property on the InventTable.NameAlias field to point to ItemId.
When entering in an ItemId and you enter a NameAlias instead, it is translated to the corresponding item id by the AX run-time. This happens everywhere an item id is entered and validated.
QComboBox keeps storing duplicate strings entered by the user, even if I call its member function QComboBox::setDuplicatesEnabled(false).
How can I store single copies of the strings even when the user inserts duplicates?
From Qt documentation:
duplicatesEnabled : bool
This property holds whether the user can enter duplicate items into the combobox.
Note that it is always possible to programmatically insert duplicate items into the combobox.
By default, this property is false (duplicates are not allowed).
Access functions:
bool duplicatesEnabled () const
void setDuplicatesEnabled ( bool enable )
As the documentation says:
This property holds whether the user can enter duplicate items into
the combobox. Note that it is always possible to programmatically
insert duplicate items into the combobox.
So this option doesn't affect string you set programmatically. You need to remove duplicates from your list manually.
For example, if you're storing your list in QStringList, duplicates can be easily removed using list = list.toSet().toList().
you need to check, if the userinput is valid (not duplicated or not) and catch the void editTextChanged ( const QString & text ) signal.
you could also derive your own class from QComboBox and overload the void keyPressEvent(QKeyEvent* event) // may be not the correct name
When we create a dialog, how do we get the selection criteria for the record (Select button) and how do we disable the select button on the Dialog ?
I will assume you use the RunBase framework.
For the dialog part of your question see Axapta Dialog Validation.
To show the query dialog, you must provide two methods:
public boolean showQueryValues()
{
return true;
}
and
public QueryRun queryRun()
{
return queryRun;
}
The queryRun method must return a valid non-null value.
The queryRun instance variable is usually assigned a value in the unpack and initParmDefault methods.
Take a look on the CustInterestCancel class for a concise example.
How to disable the select button: return false from showQueryValues.