How to use a setter? - windev

I'm trying to change a property of a class with a setter method. But when I want to use the setter, I'm getting an error.
I generated the setter method automatically by using Windev;
PROCÉDURE PUBLIQUE p_NuméroBDD(nValeur est un entier)
:m_NuméroBDD=nValeur
When I want to use the setter:
:m_pclHoraires.p_NuméroBDD(:m_nNuméroBDD)
It says, unknown procedure

Did you try this ?
:m_pclHoraires.p_NuméroBDD = nNuméroBDD

Properties in Windev are quite similar to C# properties :
When you create getters and setters, you are able to use them as members, not as methods.
So as said previously, the correct way to call your setter is to set object.p_NuméroBDD with your value.

Related

Symfony form, setters and anemic objects

I'm reading the Domain Driver Design book and there is a recommendation to do the methods followed by domain behaviors and not just getters and setters (anemic objects).
But to map an entity on Symfony forms, if I don't put the setter, the form cannot fill the field.
It shows me the error:
Could not determine access type for property "myField" in class "MyNamespace\MyClass".
How do you guys deal with that? There is a way do map the field without the setters or the data transformer?
As I know Doctrine does not use the setters to fill the object.
Thank you guys!
As ostrolucky pointed out here you can pass the property_path option, read more here.
You can use value objects instead https://webmozart.io/blog/2015/09/09/value-objects-in-symfony-forms/

Doctrine getArrayResult() returns database value while entity getter processes value

For example:
public function getField() {
return ucfirst($this->field);
}
Given that an entity has getters that do some changes on the database value before returning it, how can those changes also be applied when using the getArrayResult() method ?
For example, Laravel has accessors (http://laravel.com/docs/5.0/eloquent#accessors-and-mutators). The entity getter can be used in the same way.
When using getArrayResult(), the value for the "field" will not have the first character capitalized.
Thank you!
Well, it's the same behaviour as laravel almost :)
Take a look at Hydrators
.
Hydrators are the processors that bind your raw db output to various data types in doctrine. Thus you have Doctrine_Core::HYDRATE_RECORD which is the standard hydrator(aka the thing called when you use $query->getResult()).
If you use $query->getArrayResult(), it uses the Doctrine_Core::HYDRATE_ARRAY Hydrator.
If you need a more detailed description, please let me know.

Is the default constructor created if I provide another one?

I haven't found anything about this.
In PL/SQL, if I provide a constructor for an object, the default one will still be created, or it's like in C++ or Java?
Yes, the default constructor is still there. Incidently, if you create another constructor with the same name and arguments you'll get an error PLS-307: too many declarations of ... when you try to use it.

How can you get a type of a control at runtime?

If any control (e.g. a DataGrid) is cast to UIComponent, how can you get its type at runtime?
Is this possible in Actionscript?
You can use getQualifiedClassName() to get class name by the value as a string. You can use describeType() to get the full information about class. And you can use constructor property to get class itself (to instantiate new instance by existing instance). Finally you can use is operator to compare to the limited set of classes. Less recommended usage of typeof operator which is rather obsolete.
To select the right way we need to know your particular problem.

Getting the target when using bindable getter in flex

I have the following files:
model.as
clint.mxml
in clint.mxml I have the following line:
<s:Group id='clint1' x="model.locationX">
...
in the model.as I have a getter:
[bindable(event="locationXChanged"))
function get locationX () : int {
return ...
}
My problem is that I need to know within the getter locationX that the id of the object that is getting the id is clint1 (The object id in the mxml).
The result of a getter should not depend on which object it is called from. I guess your getter should not be a getter and should maybe take a clintId as argument.
You can use this to refer to the current component. You can use 'this.id' to find out the component's name. More info on id property.
However, I'm getting mixed signals from your question and the question's title. Are you asking for the id of the binding target inside the binding source? Implementing that would add dependencies to your components thus harming their ability for reuse.

Resources