0

Is there any way to add the custom controller rendering in a placeholder in SXA?

Whenever I add the controller rendering inside the placeholder I keep getting errors for example Object not set to reference or something like that? I have the code for this specific controller rendering and it does work on other components but when I try to apply it on this new component inside placeholder it just does not work.

Any tips on why is this happening?

1
  • My guess is that you don't have defensive code in your controller to cope with a null/not set datasource item and its erroring before you are able to add a datasource to the rendering. Can you share some code or more detail around your issue?
    – Richard Seal
    Feb 17, 2022 at 19:39

1 Answer 1

0

I don't think this is the issue of the placeholder. The placeholder will work the same for all kinds of renderings.

It is important that the controller inherit from StandardController or from a class which inherit from StandardController.

The issues of Object not set to reference, may come if object is null and to handle this you need to add null reference check in your code.

Last, if your controller is not creating any error, then you have to add a static HTML in your view to check if the error is coming by adding any unexpected HTML code? If yes, then you need to correct this.

Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.