0

I have a request scoped JSF 2 backing bean corresponding to a facelet. The facelet has a command button that calls another JSF 2 request scoped backing bean.

When I click on the commandbutton, is there a way to not call the first bean's constructor and post constructor? If that is not possible with a request scoped bean, can I use h:link or something similar to invoke the action method in secondBean? Also, how do I pass the parameter in the action method below (as the ELs cannot be nested)

<h:outputText value={firstBean.variable1.variable2} />

<p:commandButton action="#{secondBean.actionMethod(firstBean.variable1.variable2)}" ajax="false" value="Move Forward" />
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
user972391
  • 321
  • 1
  • 4
  • 20
  • Is this acceptable as dupe? http://stackoverflow.com/q/8459903 – BalusC Aug 28 '15 at 15:01
  • @BalusC hi Balusc, even if it is a ViewScoped bean and if I follow your pattern as mentioned in the link above, will the ViewScoped bean coverter get called again if the details page has a different backing bean? – user972391 Sep 01 '15 at 17:58
  • Not if it's a GET link as shown in the example. Have you tried it? – BalusC Sep 01 '15 at 18:23
  • @BalusC, I am talking about the /products/edit.xhtml page. Once the page loads initially, the constructor is called. However, after I click on the "Edit" button, since it is a command button that fires a post request, the Constructor (and PostConstruct) will be called again? Why would we need that? – user972391 Sep 01 '15 at 20:37
  • Did you miss the fact that the example bean in question is `@ViewScoped`? I cite: *"the bean should preferably be view scoped"*. See also the 1st link "How to choose right bean scope" over there. – BalusC Sep 01 '15 at 20:38
  • @BalusC, thanks for the answer. Please mark it as a duplicate, thanks – user972391 Sep 03 '15 at 20:52

0 Answers0