Difference between returning null and “” from a JSF action The Next CEO of Stack OverflowJSF Navigation String, Null, Context Redirect & the method continuesJSF bean action method return string testupdate a bean property from the same jsfa4j jsFunction not triggering server side methodWhy does returning empty string from action method not recreate view?Problems navigating in a JSF Single Page Applicationp:commandButton not updating panelEditing a single row of mysql using JSFh:commandButton with an action and then page-navigation in JSF?Differences between HashMap and Hashtable?What is the difference between public, protected, package-private and private in Java?Difference between StringBuilder and StringBufferDifference between wait() and sleep()What is the difference between JSF, Servlet and JSP?Difference between HashMap, LinkedHashMap and TreeMapDifferences between action and actionListenerWhat's the difference between @Component, @Repository & @Service annotations in Spring?Making Distinctions Between Different Kinds of JSF Managed-BeansJSF bean action method return string test

Reference request: Grassmannian and Plucker coordinates in type B, C, D

Running a General Election and the European Elections together

Proper way to express "He disappeared them"

WOW air has ceased operation, can I get my tickets refunded?

How to invert MapIndexed on a ragged structure? How to construct a tree from rules?

Why this way of making earth uninhabitable in Interstellar?

Would a completely good Muggle be able to use a wand?

What connection does MS Office have to Netscape Navigator?

Is it okay to majorly distort historical facts while writing a fiction story?

How did people program for Consoles with multiple CPUs?

Is it possible to replace duplicates of a character with one character using tr

What happened in Rome, when the western empire "fell"?

Help understanding this unsettling image of Titan, Epimetheus, and Saturn's rings?

Is it professional to write unrelated content in an almost-empty email?

Unclear about dynamic binding

Math-accent symbol over parentheses enclosing accented symbol (amsmath)

How to scale a tikZ image which is within a figure environment

Does Germany produce more waste than the US?

Some questions about different axiomatic systems for neighbourhoods

No sign flipping while figuring out the emf of voltaic cell?

What did we know about the Kessel run before the prequels?

Solving system of ODEs with extra parameter

Would a grinding machine be a simple and workable propulsion system for an interplanetary spacecraft?

Example of a Mathematician/Physicist whose Other Publications during their PhD eclipsed their PhD Thesis



Difference between returning null and “” from a JSF action



The Next CEO of Stack OverflowJSF Navigation String, Null, Context Redirect & the method continuesJSF bean action method return string testupdate a bean property from the same jsfa4j jsFunction not triggering server side methodWhy does returning empty string from action method not recreate view?Problems navigating in a JSF Single Page Applicationp:commandButton not updating panelEditing a single row of mysql using JSFh:commandButton with an action and then page-navigation in JSF?Differences between HashMap and Hashtable?What is the difference between public, protected, package-private and private in Java?Difference between StringBuilder and StringBufferDifference between wait() and sleep()What is the difference between JSF, Servlet and JSP?Difference between HashMap, LinkedHashMap and TreeMapDifferences between action and actionListenerWhat's the difference between @Component, @Repository & @Service annotations in Spring?Making Distinctions Between Different Kinds of JSF Managed-BeansJSF bean action method return string test










38















From what I understand, when a JSF action returns "" (empty String) the user stays on the current page but the view is refreshed. However, when the action returns null the user still stays on the current page but the old view is reused. My question is:



  1. Is the above statement correct (accurate)?

  2. If yes, then what are the implications of this? Specifically, what effect does using one versus the other have on data on the page (values in JSF UI components, or data stored in a request-scope bean in a DataTable, for example)?

  3. In what situations should one be used over the other?









share|improve this question




























    38















    From what I understand, when a JSF action returns "" (empty String) the user stays on the current page but the view is refreshed. However, when the action returns null the user still stays on the current page but the old view is reused. My question is:



    1. Is the above statement correct (accurate)?

    2. If yes, then what are the implications of this? Specifically, what effect does using one versus the other have on data on the page (values in JSF UI components, or data stored in a request-scope bean in a DataTable, for example)?

    3. In what situations should one be used over the other?









    share|improve this question


























      38












      38








      38


      8






      From what I understand, when a JSF action returns "" (empty String) the user stays on the current page but the view is refreshed. However, when the action returns null the user still stays on the current page but the old view is reused. My question is:



      1. Is the above statement correct (accurate)?

      2. If yes, then what are the implications of this? Specifically, what effect does using one versus the other have on data on the page (values in JSF UI components, or data stored in a request-scope bean in a DataTable, for example)?

      3. In what situations should one be used over the other?









      share|improve this question
















      From what I understand, when a JSF action returns "" (empty String) the user stays on the current page but the view is refreshed. However, when the action returns null the user still stays on the current page but the old view is reused. My question is:



      1. Is the above statement correct (accurate)?

      2. If yes, then what are the implications of this? Specifically, what effect does using one versus the other have on data on the page (values in JSF UI components, or data stored in a request-scope bean in a DataTable, for example)?

      3. In what situations should one be used over the other?






      java jsf navigation






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 5 '12 at 14:47









      Perception

      68.9k10150174




      68.9k10150174










      asked Jan 5 '12 at 14:31









      Brent CBrent C

      5251713




      5251713






















          1 Answer
          1






          active

          oldest

          votes


















          32















          Is the above statement correct (accurate)?




          Yes. Instead of returning null you can also just return void.





          If yes, then what are the implications of this? Specifically, what effect does using one versus the other have on data on the page (values in JSF UI components, or data stored in a request-scope bean in a DataTable, for example)?




          Nothing on request scoped beans. It has only effect on JSF2 view scoped beans. On returning null or void, the view scoped bean instance will be retained in the next request, else it will be recreated.





          In what situations should one be used over the other?




          If you want to retain the JSF2 view scoped bean in the subsequent request.



          See also:



          • Communication in JSF 2.0 - Managed bean scopes





          share|improve this answer























          • So if I am using JSF 1.2 without a view-scope, then it is safe to say there is really no difference?

            – Brent C
            Jan 5 '12 at 14:42






          • 1





            Functionally, no. But technically there's a difference which you already found out yourself. Creating a new view has a minor cost. Just always return null or void on postbacks to the same view.

            – BalusC
            Jan 5 '12 at 14:49











          • FYI: Application Actions have the following constraints in the JSF2 spec: 1. The method must be public. 2. The method must take no parameters. 3. The method must return Object. I recall at least one navigation API implementation blowing up if you tried to use a void return type, but can't remember which vendor/version.

            – McDowell
            Jan 5 '12 at 16:13











          • @McDowell: in reality, anything which can be represented by a MethodExpression is a legal action method, even the ones taking parameters as possible in EL 2.2. That spec cite is perhaps a leftover from JSF 1.0.

            – BalusC
            Jan 5 '12 at 16:27












          • Is this difference in treating of response value covered in spec or it is just implementation thing?

            – Tibor Blenessy
            Sep 30 '14 at 11:38











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          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',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f8744162%2fdifference-between-returning-null-and-from-a-jsf-action%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          32















          Is the above statement correct (accurate)?




          Yes. Instead of returning null you can also just return void.





          If yes, then what are the implications of this? Specifically, what effect does using one versus the other have on data on the page (values in JSF UI components, or data stored in a request-scope bean in a DataTable, for example)?




          Nothing on request scoped beans. It has only effect on JSF2 view scoped beans. On returning null or void, the view scoped bean instance will be retained in the next request, else it will be recreated.





          In what situations should one be used over the other?




          If you want to retain the JSF2 view scoped bean in the subsequent request.



          See also:



          • Communication in JSF 2.0 - Managed bean scopes





          share|improve this answer























          • So if I am using JSF 1.2 without a view-scope, then it is safe to say there is really no difference?

            – Brent C
            Jan 5 '12 at 14:42






          • 1





            Functionally, no. But technically there's a difference which you already found out yourself. Creating a new view has a minor cost. Just always return null or void on postbacks to the same view.

            – BalusC
            Jan 5 '12 at 14:49











          • FYI: Application Actions have the following constraints in the JSF2 spec: 1. The method must be public. 2. The method must take no parameters. 3. The method must return Object. I recall at least one navigation API implementation blowing up if you tried to use a void return type, but can't remember which vendor/version.

            – McDowell
            Jan 5 '12 at 16:13











          • @McDowell: in reality, anything which can be represented by a MethodExpression is a legal action method, even the ones taking parameters as possible in EL 2.2. That spec cite is perhaps a leftover from JSF 1.0.

            – BalusC
            Jan 5 '12 at 16:27












          • Is this difference in treating of response value covered in spec or it is just implementation thing?

            – Tibor Blenessy
            Sep 30 '14 at 11:38















          32















          Is the above statement correct (accurate)?




          Yes. Instead of returning null you can also just return void.





          If yes, then what are the implications of this? Specifically, what effect does using one versus the other have on data on the page (values in JSF UI components, or data stored in a request-scope bean in a DataTable, for example)?




          Nothing on request scoped beans. It has only effect on JSF2 view scoped beans. On returning null or void, the view scoped bean instance will be retained in the next request, else it will be recreated.





          In what situations should one be used over the other?




          If you want to retain the JSF2 view scoped bean in the subsequent request.



          See also:



          • Communication in JSF 2.0 - Managed bean scopes





          share|improve this answer























          • So if I am using JSF 1.2 without a view-scope, then it is safe to say there is really no difference?

            – Brent C
            Jan 5 '12 at 14:42






          • 1





            Functionally, no. But technically there's a difference which you already found out yourself. Creating a new view has a minor cost. Just always return null or void on postbacks to the same view.

            – BalusC
            Jan 5 '12 at 14:49











          • FYI: Application Actions have the following constraints in the JSF2 spec: 1. The method must be public. 2. The method must take no parameters. 3. The method must return Object. I recall at least one navigation API implementation blowing up if you tried to use a void return type, but can't remember which vendor/version.

            – McDowell
            Jan 5 '12 at 16:13











          • @McDowell: in reality, anything which can be represented by a MethodExpression is a legal action method, even the ones taking parameters as possible in EL 2.2. That spec cite is perhaps a leftover from JSF 1.0.

            – BalusC
            Jan 5 '12 at 16:27












          • Is this difference in treating of response value covered in spec or it is just implementation thing?

            – Tibor Blenessy
            Sep 30 '14 at 11:38













          32












          32








          32








          Is the above statement correct (accurate)?




          Yes. Instead of returning null you can also just return void.





          If yes, then what are the implications of this? Specifically, what effect does using one versus the other have on data on the page (values in JSF UI components, or data stored in a request-scope bean in a DataTable, for example)?




          Nothing on request scoped beans. It has only effect on JSF2 view scoped beans. On returning null or void, the view scoped bean instance will be retained in the next request, else it will be recreated.





          In what situations should one be used over the other?




          If you want to retain the JSF2 view scoped bean in the subsequent request.



          See also:



          • Communication in JSF 2.0 - Managed bean scopes





          share|improve this answer














          Is the above statement correct (accurate)?




          Yes. Instead of returning null you can also just return void.





          If yes, then what are the implications of this? Specifically, what effect does using one versus the other have on data on the page (values in JSF UI components, or data stored in a request-scope bean in a DataTable, for example)?




          Nothing on request scoped beans. It has only effect on JSF2 view scoped beans. On returning null or void, the view scoped bean instance will be retained in the next request, else it will be recreated.





          In what situations should one be used over the other?




          If you want to retain the JSF2 view scoped bean in the subsequent request.



          See also:



          • Communication in JSF 2.0 - Managed bean scopes






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 5 '12 at 14:33









          BalusCBalusC

          857k30031743237




          857k30031743237












          • So if I am using JSF 1.2 without a view-scope, then it is safe to say there is really no difference?

            – Brent C
            Jan 5 '12 at 14:42






          • 1





            Functionally, no. But technically there's a difference which you already found out yourself. Creating a new view has a minor cost. Just always return null or void on postbacks to the same view.

            – BalusC
            Jan 5 '12 at 14:49











          • FYI: Application Actions have the following constraints in the JSF2 spec: 1. The method must be public. 2. The method must take no parameters. 3. The method must return Object. I recall at least one navigation API implementation blowing up if you tried to use a void return type, but can't remember which vendor/version.

            – McDowell
            Jan 5 '12 at 16:13











          • @McDowell: in reality, anything which can be represented by a MethodExpression is a legal action method, even the ones taking parameters as possible in EL 2.2. That spec cite is perhaps a leftover from JSF 1.0.

            – BalusC
            Jan 5 '12 at 16:27












          • Is this difference in treating of response value covered in spec or it is just implementation thing?

            – Tibor Blenessy
            Sep 30 '14 at 11:38

















          • So if I am using JSF 1.2 without a view-scope, then it is safe to say there is really no difference?

            – Brent C
            Jan 5 '12 at 14:42






          • 1





            Functionally, no. But technically there's a difference which you already found out yourself. Creating a new view has a minor cost. Just always return null or void on postbacks to the same view.

            – BalusC
            Jan 5 '12 at 14:49











          • FYI: Application Actions have the following constraints in the JSF2 spec: 1. The method must be public. 2. The method must take no parameters. 3. The method must return Object. I recall at least one navigation API implementation blowing up if you tried to use a void return type, but can't remember which vendor/version.

            – McDowell
            Jan 5 '12 at 16:13











          • @McDowell: in reality, anything which can be represented by a MethodExpression is a legal action method, even the ones taking parameters as possible in EL 2.2. That spec cite is perhaps a leftover from JSF 1.0.

            – BalusC
            Jan 5 '12 at 16:27












          • Is this difference in treating of response value covered in spec or it is just implementation thing?

            – Tibor Blenessy
            Sep 30 '14 at 11:38
















          So if I am using JSF 1.2 without a view-scope, then it is safe to say there is really no difference?

          – Brent C
          Jan 5 '12 at 14:42





          So if I am using JSF 1.2 without a view-scope, then it is safe to say there is really no difference?

          – Brent C
          Jan 5 '12 at 14:42




          1




          1





          Functionally, no. But technically there's a difference which you already found out yourself. Creating a new view has a minor cost. Just always return null or void on postbacks to the same view.

          – BalusC
          Jan 5 '12 at 14:49





          Functionally, no. But technically there's a difference which you already found out yourself. Creating a new view has a minor cost. Just always return null or void on postbacks to the same view.

          – BalusC
          Jan 5 '12 at 14:49













          FYI: Application Actions have the following constraints in the JSF2 spec: 1. The method must be public. 2. The method must take no parameters. 3. The method must return Object. I recall at least one navigation API implementation blowing up if you tried to use a void return type, but can't remember which vendor/version.

          – McDowell
          Jan 5 '12 at 16:13





          FYI: Application Actions have the following constraints in the JSF2 spec: 1. The method must be public. 2. The method must take no parameters. 3. The method must return Object. I recall at least one navigation API implementation blowing up if you tried to use a void return type, but can't remember which vendor/version.

          – McDowell
          Jan 5 '12 at 16:13













          @McDowell: in reality, anything which can be represented by a MethodExpression is a legal action method, even the ones taking parameters as possible in EL 2.2. That spec cite is perhaps a leftover from JSF 1.0.

          – BalusC
          Jan 5 '12 at 16:27






          @McDowell: in reality, anything which can be represented by a MethodExpression is a legal action method, even the ones taking parameters as possible in EL 2.2. That spec cite is perhaps a leftover from JSF 1.0.

          – BalusC
          Jan 5 '12 at 16:27














          Is this difference in treating of response value covered in spec or it is just implementation thing?

          – Tibor Blenessy
          Sep 30 '14 at 11:38





          Is this difference in treating of response value covered in spec or it is just implementation thing?

          – Tibor Blenessy
          Sep 30 '14 at 11:38



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f8744162%2fdifference-between-returning-null-and-from-a-jsf-action%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to get text form Clipboard with JavaScript in Firefox 56?How to validate an email address in JavaScript?How do JavaScript closures work?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I copy to the clipboard in JavaScript?How do I include a JavaScript file in another JavaScript file?Get the current URL with JavaScript?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?

          Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

          List of MPs elected to the English parliament in 1640 (April) Contents List of constituencies and members See also Notes References Navigation menueNational Archives – The Glynde Place ArchivesCobbett's Parliamentary history of England, from the Norman Conquest in 1066 to the year 1803'Aldermen in Parliament', The Aldermen of the City of London: Temp. Henry III – 1912onepage&q&f&#61, false 229