How to read Salesforce lightning components attributes from APEX

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
2
down vote

favorite












This use case is tricky.
We need to have a way to read Salesforce lightning component attributes from the APEX code.
We don't want to pass the attributes from the Salesforce lightning javascript but wanna try to read the component attributes from the backend code.



Is it possible?










share|improve this question

















  • 1




    Its actually very interesting question but my guess it is not possible to do something like that. LEX is like normal js framework and it is using standard client (web) server (backend apex) architecture. But maybe I am wrong and someone smarter would provide some more info about this topic
    – user1974566
    Sep 16 at 20:14







  • 1




    I agree with Charles. This seems like an X-Y problem. You might want to take a step back and explain what you're trying to do.
    – sfdcfox
    Sep 16 at 20:37










  • @sfdcfox Lightning components are stored as a JSON object... perhaps it's possible to query for them. But of course, as Charles says, we are probably trying to solve the wrong problem.
    – Caspar Harmer
    Sep 16 at 22:14











  • Of course, they would be in raw, unevaluated form... so many attributes would be invalid.
    – Caspar Harmer
    Sep 16 at 22:15
















up vote
2
down vote

favorite












This use case is tricky.
We need to have a way to read Salesforce lightning component attributes from the APEX code.
We don't want to pass the attributes from the Salesforce lightning javascript but wanna try to read the component attributes from the backend code.



Is it possible?










share|improve this question

















  • 1




    Its actually very interesting question but my guess it is not possible to do something like that. LEX is like normal js framework and it is using standard client (web) server (backend apex) architecture. But maybe I am wrong and someone smarter would provide some more info about this topic
    – user1974566
    Sep 16 at 20:14







  • 1




    I agree with Charles. This seems like an X-Y problem. You might want to take a step back and explain what you're trying to do.
    – sfdcfox
    Sep 16 at 20:37










  • @sfdcfox Lightning components are stored as a JSON object... perhaps it's possible to query for them. But of course, as Charles says, we are probably trying to solve the wrong problem.
    – Caspar Harmer
    Sep 16 at 22:14











  • Of course, they would be in raw, unevaluated form... so many attributes would be invalid.
    – Caspar Harmer
    Sep 16 at 22:15












up vote
2
down vote

favorite









up vote
2
down vote

favorite











This use case is tricky.
We need to have a way to read Salesforce lightning component attributes from the APEX code.
We don't want to pass the attributes from the Salesforce lightning javascript but wanna try to read the component attributes from the backend code.



Is it possible?










share|improve this question













This use case is tricky.
We need to have a way to read Salesforce lightning component attributes from the APEX code.
We don't want to pass the attributes from the Salesforce lightning javascript but wanna try to read the component attributes from the backend code.



Is it possible?







lightning-components






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Sep 16 at 20:01









newBike

1787




1787







  • 1




    Its actually very interesting question but my guess it is not possible to do something like that. LEX is like normal js framework and it is using standard client (web) server (backend apex) architecture. But maybe I am wrong and someone smarter would provide some more info about this topic
    – user1974566
    Sep 16 at 20:14







  • 1




    I agree with Charles. This seems like an X-Y problem. You might want to take a step back and explain what you're trying to do.
    – sfdcfox
    Sep 16 at 20:37










  • @sfdcfox Lightning components are stored as a JSON object... perhaps it's possible to query for them. But of course, as Charles says, we are probably trying to solve the wrong problem.
    – Caspar Harmer
    Sep 16 at 22:14











  • Of course, they would be in raw, unevaluated form... so many attributes would be invalid.
    – Caspar Harmer
    Sep 16 at 22:15












  • 1




    Its actually very interesting question but my guess it is not possible to do something like that. LEX is like normal js framework and it is using standard client (web) server (backend apex) architecture. But maybe I am wrong and someone smarter would provide some more info about this topic
    – user1974566
    Sep 16 at 20:14







  • 1




    I agree with Charles. This seems like an X-Y problem. You might want to take a step back and explain what you're trying to do.
    – sfdcfox
    Sep 16 at 20:37










  • @sfdcfox Lightning components are stored as a JSON object... perhaps it's possible to query for them. But of course, as Charles says, we are probably trying to solve the wrong problem.
    – Caspar Harmer
    Sep 16 at 22:14











  • Of course, they would be in raw, unevaluated form... so many attributes would be invalid.
    – Caspar Harmer
    Sep 16 at 22:15







1




1




Its actually very interesting question but my guess it is not possible to do something like that. LEX is like normal js framework and it is using standard client (web) server (backend apex) architecture. But maybe I am wrong and someone smarter would provide some more info about this topic
– user1974566
Sep 16 at 20:14





Its actually very interesting question but my guess it is not possible to do something like that. LEX is like normal js framework and it is using standard client (web) server (backend apex) architecture. But maybe I am wrong and someone smarter would provide some more info about this topic
– user1974566
Sep 16 at 20:14





1




1




I agree with Charles. This seems like an X-Y problem. You might want to take a step back and explain what you're trying to do.
– sfdcfox
Sep 16 at 20:37




I agree with Charles. This seems like an X-Y problem. You might want to take a step back and explain what you're trying to do.
– sfdcfox
Sep 16 at 20:37












@sfdcfox Lightning components are stored as a JSON object... perhaps it's possible to query for them. But of course, as Charles says, we are probably trying to solve the wrong problem.
– Caspar Harmer
Sep 16 at 22:14





@sfdcfox Lightning components are stored as a JSON object... perhaps it's possible to query for them. But of course, as Charles says, we are probably trying to solve the wrong problem.
– Caspar Harmer
Sep 16 at 22:14













Of course, they would be in raw, unevaluated form... so many attributes would be invalid.
– Caspar Harmer
Sep 16 at 22:15




Of course, they would be in raw, unevaluated form... so many attributes would be invalid.
– Caspar Harmer
Sep 16 at 22:15










3 Answers
3






active

oldest

votes

















up vote
6
down vote













No. Those parameters are known only on the front end and never passed to the back at all. The whole idea of making calls to static functions in an Apex controller from Lightning is that behaviour should flow directly from the parameters passed in.



This seems like an X/Y problem. The question you are asking is confusing. What is the real problem you are trying to solve that makes you so reluctant to pass Lightning component parameters to Apex?






share|improve this answer



























    up vote
    0
    down vote













    It is impossible in normal flow also because Lightning side, once spinned up on a page load, determines then when and how to call Apex code using Ajax calls or navigating to another page. Between calls, Apex has no chance to know what happening on Lightning side. This is how classic client-server and unidirectional SPA applications work.



    To implement something you talking about, you have to have a hypothetical constantly running background process on Apex, that will connect via always-live bidirectional channel like websocket to another hypothetical JavaScript daemon running on Lightning front-end session (btw each user in each browser will have a different session so different instance of a daemon), and this daemon will be somehow invisible to the Lightning components (your intention was to hide such an activity from the components itself - right?) and querying their attributes the same time.



    Well, you can implement e.g a Chrome browser extension with a spying content script. This content script will hack into Lightning components structure in real time, and send its contents to some your server side when queried. But this is tricky, and again, server-initiated query needs technologies like websocket or long polling.



    You can try to make the same hacks from a special lightning component or from a loaded static JS library instead of Chrome extension, but I suspect you might encounter security limitations from LockerService.






    share|improve this answer





























      up vote
      0
      down vote













      What would be the use case of this (personally I can not think of any)? Possibly would help a bit more to find the correct solution to your problem. Seems like a case of over-engineering ;)






      share|improve this answer








      New contributor




      James Dinnes is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.

















        Your Answer







        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "459"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        convertImagesToLinks: false,
        noModals: false,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













         

        draft saved


        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f232681%2fhow-to-read-salesforce-lightning-components-attributes-from-apex%23new-answer', 'question_page');

        );

        Post as a guest






























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        6
        down vote













        No. Those parameters are known only on the front end and never passed to the back at all. The whole idea of making calls to static functions in an Apex controller from Lightning is that behaviour should flow directly from the parameters passed in.



        This seems like an X/Y problem. The question you are asking is confusing. What is the real problem you are trying to solve that makes you so reluctant to pass Lightning component parameters to Apex?






        share|improve this answer
























          up vote
          6
          down vote













          No. Those parameters are known only on the front end and never passed to the back at all. The whole idea of making calls to static functions in an Apex controller from Lightning is that behaviour should flow directly from the parameters passed in.



          This seems like an X/Y problem. The question you are asking is confusing. What is the real problem you are trying to solve that makes you so reluctant to pass Lightning component parameters to Apex?






          share|improve this answer






















            up vote
            6
            down vote










            up vote
            6
            down vote









            No. Those parameters are known only on the front end and never passed to the back at all. The whole idea of making calls to static functions in an Apex controller from Lightning is that behaviour should flow directly from the parameters passed in.



            This seems like an X/Y problem. The question you are asking is confusing. What is the real problem you are trying to solve that makes you so reluctant to pass Lightning component parameters to Apex?






            share|improve this answer












            No. Those parameters are known only on the front end and never passed to the back at all. The whole idea of making calls to static functions in an Apex controller from Lightning is that behaviour should flow directly from the parameters passed in.



            This seems like an X/Y problem. The question you are asking is confusing. What is the real problem you are trying to solve that makes you so reluctant to pass Lightning component parameters to Apex?







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Sep 16 at 20:16









            Charles T

            5,4901618




            5,4901618






















                up vote
                0
                down vote













                It is impossible in normal flow also because Lightning side, once spinned up on a page load, determines then when and how to call Apex code using Ajax calls or navigating to another page. Between calls, Apex has no chance to know what happening on Lightning side. This is how classic client-server and unidirectional SPA applications work.



                To implement something you talking about, you have to have a hypothetical constantly running background process on Apex, that will connect via always-live bidirectional channel like websocket to another hypothetical JavaScript daemon running on Lightning front-end session (btw each user in each browser will have a different session so different instance of a daemon), and this daemon will be somehow invisible to the Lightning components (your intention was to hide such an activity from the components itself - right?) and querying their attributes the same time.



                Well, you can implement e.g a Chrome browser extension with a spying content script. This content script will hack into Lightning components structure in real time, and send its contents to some your server side when queried. But this is tricky, and again, server-initiated query needs technologies like websocket or long polling.



                You can try to make the same hacks from a special lightning component or from a loaded static JS library instead of Chrome extension, but I suspect you might encounter security limitations from LockerService.






                share|improve this answer


























                  up vote
                  0
                  down vote













                  It is impossible in normal flow also because Lightning side, once spinned up on a page load, determines then when and how to call Apex code using Ajax calls or navigating to another page. Between calls, Apex has no chance to know what happening on Lightning side. This is how classic client-server and unidirectional SPA applications work.



                  To implement something you talking about, you have to have a hypothetical constantly running background process on Apex, that will connect via always-live bidirectional channel like websocket to another hypothetical JavaScript daemon running on Lightning front-end session (btw each user in each browser will have a different session so different instance of a daemon), and this daemon will be somehow invisible to the Lightning components (your intention was to hide such an activity from the components itself - right?) and querying their attributes the same time.



                  Well, you can implement e.g a Chrome browser extension with a spying content script. This content script will hack into Lightning components structure in real time, and send its contents to some your server side when queried. But this is tricky, and again, server-initiated query needs technologies like websocket or long polling.



                  You can try to make the same hacks from a special lightning component or from a loaded static JS library instead of Chrome extension, but I suspect you might encounter security limitations from LockerService.






                  share|improve this answer
























                    up vote
                    0
                    down vote










                    up vote
                    0
                    down vote









                    It is impossible in normal flow also because Lightning side, once spinned up on a page load, determines then when and how to call Apex code using Ajax calls or navigating to another page. Between calls, Apex has no chance to know what happening on Lightning side. This is how classic client-server and unidirectional SPA applications work.



                    To implement something you talking about, you have to have a hypothetical constantly running background process on Apex, that will connect via always-live bidirectional channel like websocket to another hypothetical JavaScript daemon running on Lightning front-end session (btw each user in each browser will have a different session so different instance of a daemon), and this daemon will be somehow invisible to the Lightning components (your intention was to hide such an activity from the components itself - right?) and querying their attributes the same time.



                    Well, you can implement e.g a Chrome browser extension with a spying content script. This content script will hack into Lightning components structure in real time, and send its contents to some your server side when queried. But this is tricky, and again, server-initiated query needs technologies like websocket or long polling.



                    You can try to make the same hacks from a special lightning component or from a loaded static JS library instead of Chrome extension, but I suspect you might encounter security limitations from LockerService.






                    share|improve this answer














                    It is impossible in normal flow also because Lightning side, once spinned up on a page load, determines then when and how to call Apex code using Ajax calls or navigating to another page. Between calls, Apex has no chance to know what happening on Lightning side. This is how classic client-server and unidirectional SPA applications work.



                    To implement something you talking about, you have to have a hypothetical constantly running background process on Apex, that will connect via always-live bidirectional channel like websocket to another hypothetical JavaScript daemon running on Lightning front-end session (btw each user in each browser will have a different session so different instance of a daemon), and this daemon will be somehow invisible to the Lightning components (your intention was to hide such an activity from the components itself - right?) and querying their attributes the same time.



                    Well, you can implement e.g a Chrome browser extension with a spying content script. This content script will hack into Lightning components structure in real time, and send its contents to some your server side when queried. But this is tricky, and again, server-initiated query needs technologies like websocket or long polling.



                    You can try to make the same hacks from a special lightning component or from a loaded static JS library instead of Chrome extension, but I suspect you might encounter security limitations from LockerService.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Sep 25 at 3:59

























                    answered Sep 24 at 21:23









                    Denis Volokhovskiy

                    112




                    112




















                        up vote
                        0
                        down vote













                        What would be the use case of this (personally I can not think of any)? Possibly would help a bit more to find the correct solution to your problem. Seems like a case of over-engineering ;)






                        share|improve this answer








                        New contributor




                        James Dinnes is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.





















                          up vote
                          0
                          down vote













                          What would be the use case of this (personally I can not think of any)? Possibly would help a bit more to find the correct solution to your problem. Seems like a case of over-engineering ;)






                          share|improve this answer








                          New contributor




                          James Dinnes is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.



















                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote









                            What would be the use case of this (personally I can not think of any)? Possibly would help a bit more to find the correct solution to your problem. Seems like a case of over-engineering ;)






                            share|improve this answer








                            New contributor




                            James Dinnes is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            What would be the use case of this (personally I can not think of any)? Possibly would help a bit more to find the correct solution to your problem. Seems like a case of over-engineering ;)







                            share|improve this answer








                            New contributor




                            James Dinnes is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            share|improve this answer



                            share|improve this answer






                            New contributor




                            James Dinnes is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            answered Sep 25 at 7:33









                            James Dinnes

                            11




                            11




                            New contributor




                            James Dinnes is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.





                            New contributor





                            James Dinnes is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.






                            James Dinnes is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.



























                                 

                                draft saved


                                draft discarded















































                                 


                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f232681%2fhow-to-read-salesforce-lightning-components-attributes-from-apex%23new-answer', 'question_page');

                                );

                                Post as a guest













































































                                Popular posts from this blog

                                How to check contact read email or not when send email to Individual?

                                Bahrain

                                Postfix configuration issue with fips on centos 7; mailgun relay