how to invoke this method in aura component? - salesforce-lightning

i have this apex method where i declare a map. How can I declare this map in the controller and make the records display and declare it in the component?

Related

Call custom functions in laravel backpack

I want to create a button next to each row in the Laravel Backpack list view to call a function that generates an excel (or print a PDF, or whatever). This function is in a helpers class that I have created. I don't see a way to do this, it seems that I can only create buttons that call functions within the model, isn't there a way to be able to call functions within a controller or within a class? I don't want to create certain functions within the model

SAPUI5 Call method's model from xml view

Is it possible to call a method from model?
For example I have extanded my JSON Model and add a function called hello_world.
In my XML view I want to call the method of this model from and event off a control like below :
<Select change="{cl_vehicule>}.hello_world">
<items>
<core:Item text="1" key="1"/>
<core:Item text="2" key="2"/>
</items>
</Select>
Is it possible ?
If yes how to ?
It's not possible for the following reasons:
1) change in your Select control is an event, so it has to be associated with a function. This is not the same thing as calling the function. Please notice that you do not add () after the method name when using a event
2) cl_vehicule in your example should be the name of an association between a control and model. Models have no name. The name you put before > in a data binding is specified in the manifest or in a setModel method call. In other words, the same model can be associated with different controls but using different names.
3) Using {} means that you are using method bindProperty or bindAggregation to that control. These methods are defined in ManagedObject class. Those cannot be used in events.
4) As UI5 uses MVC paradigm, a View should never contact a model directly
So, you should basically use the change event associating it with a function from your controller. In that function you have different ways of getting your extended model to call a method.

Delphi create button with image

I have problem with creating button with Image and Label inside it.
Here my code:
Class:
type
Folder = class(TButton)
AName:TLabel;
AImage:TImage;
constructor Create(Nme:String;Path:String;Handle:TForm);
end;
Constructor:
constructor Folder.Create(Nme:String;Path:String;Handle:TForm);
begin
AImage:=Timage.Create(Self);
AName:=TLabel.Create(Self);
AImage.Parent:=Self;
AName.Parent:=Self;
AName.Caption:=Nme;
AImage.Picture.LoadFromFile(Path);
end;`
And event where I create this button:
procedure TForm3.Button1Click(Sender: TObject);
var Fld:Folder;
begin
Fld:=Folder.Create('It','D:\image.bmp',Form3);
Fld.Parent:=Form3;
Fld.Width:=100;
Fld.Height:=100;
end;
But when I'm creating this button it causes acess violation!What I must to do with it?
Problem:
The problem is that you have declared a customized version of constructor, but you are not calling the parent constructor of TButton class.
You need to change the constructor like this:
constructor Folder.Create(Nme: String; Path: String; Handle: TForm);
begin
inherited Create(Handle); // <- Add this line
AImage := TImage.Create(Self);
AName := TLabel.Create(Self);
AImage.Parent := Self;
AName.Parent := Self;
AName.Caption := Nme;
AImage.Picture.LoadFromFile(Path);
end;
General advice:
You need to learn how to debug such problems yourself.
Put a breakpoint on line Fld:=Folder.Create('It','D:\image.bmp',Form3); and use Step Over F8 / Trace Into F7 from Run menu to check your code line by line.
You will see that once you reach the line AImage.Parent:=Self; the exception occurs. This is because Self, which points to your Folder object, was not initialized correctly, and is not a proper TButton descendant.
You need to learn how to do that to progress any further with Delphi, and you will very soon be able to solve such problems yourself.
Also if you need to write a custom component for Delphi, invest some time learning more about the way components work and are being used. I would recommend the following guides on component writing:
Official Component Writer’s Guide
Introduction to Component Building by Ray Konopka
Also consult a guide on Delphi Coding Style.
At first glance:
Class names should begin with T
Class fields should begin with F instead of A
constructor should be in public section and fields in private or protected
You should use spaces around parameters, after variables in declarations and around operators

How to pass select from one controller to another in Zend?

currently I'm using an output controller for simple HTML outputs. There is another report controller for output as PDF. Both controllers use the same SQL and are filtered by session data.
Is there a way to pass the Zend_Select object from the list controller to the report controller? So I don't have to assemble the select in each controller again.
As I remember it's not possible with the registry. But maybe there exists another elegant way?
you can use smth like a abstract base controller for the list and report controller, that would be helpful.

How to create instance to zend controller

I have a controller named class TestController which extends some Zend_Controller_Action. Now I would like to use create an instance of TestController in TestForms (a Zend_Form). I want to populate a Zend_Form_Element_Select dynamically.
Please suggest how I can do this. Thanx in advance.
Where are you instantiating the form - is it in the controller? Instead of having the form call an action on the controller to dynamically get the values, you should look at setting the values on the form after it has been instantiated.
A quick and dirty way of doing that would be to grab the values in the controller and assign it to the element via:
$values = $db->query('query');
$element = $form->getElement('dynamicSelect');
$element->setValue($values);
Of course having DB queries to a table in your controller isn't exactly best practice... Per philistyne's suggestion, I use a a form builder class to build forms dynamically from my models. I have mappers for each model, and I pass in the mapper to the form builder class so it can dynamically populate my select elements.
A couple of things to try (passing a controller into a form or instantiating from within one is not recommended):
Use a model to access the dynamic values you want to put into your Zend_Form_Element_Select.
If the form is complex, create a form builder class to take care of, and separate out, the heavy lifting of the form construction.
Create customised form elements by extending from Zend_Form_Element_(Radio, Select, etc etc) if you feel you need very fine control over the form element's construction/behaviour/appearance, but wish to be able to reuse that element elsewhere.