Unable to access widget through url for ajax call - unable to retrieve component properties

Lucia Long asked on January 14, 2020 09:26

Hi there,

I have a peculiar problem. I am making an Ajax call to URL to access SOAP response and provide source for my autocomplete. Part of the AJAX call requires me to provide url to access the controllers method. However when I try to access my widget through general route: /culture/{controller}/{action}, I am getting an error of: Unable to retrieve the component properties of type...

When I access page with widget via extended route of page builder: culture/landingpage/{nodeAlias}, the page displays and properties are also retrieved.

Would anybody have any suggestions?

Thank you.

Correct Answer

Dmitry Bastron answered on January 14, 2020 16:02

Hi Lucia,

The reason you are having this error is that your controller's method contains GetProperties() call which tries to get the widget properties from the request. If you make a direct call to a widget controller omitting the page the request will not conain data to get the widget properties. Basically, when you perform an Ajax call to /culture/{controller}/{action} URL the system has no idea how it should get the widget parameters.

Here is what you could do:

  • in the widget view you can include widget parameters required for Ajax call into some data attributes
  • in the widget controller you can create additional GET method that will accept these parameters and return the required response
  • in the Ajax call you are making include the parameters rendered in the first step

I hope it makes sense.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Lucia Long answered on January 15, 2020 09:01

Hi there,

thank you very much for your help. Great explanation and that definitely solves the problem with the properties. :-)

L.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.