Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As to the concrete question, just split the bean in 2 separate beans. As you're apparently managing beans by Spring instead of by JSF or CDI for some unclear reason, you can use <code>@Autowired</code> to inject the one bean as a property of the other bean. </p> <pre><code>@Named @Scope("request") public class Login implements Serializable { private List&lt;Role&gt; roles; @AutoWired private User user; public String submit() { UserTable userTable = user.getTable(); // ... } // ... } </code></pre> <pre class="lang-java prettyprint-override"><code>@Named @Scope("session") public class User implements Serializable { private UserTable table; // ... } </code></pre> <p>If you were managing the beans by JSF <code>@ManagedBean</code>, you could use <code>@ManagedProperty</code> for that. If you were managing the beans by CDI <code>@Named</code>, you could use <code>@Inject</code> for that.</p> <hr> <p>Coming back to the concrete functional requirement,</p> <blockquote> <p>And I feel like roleList should not be in session scope, since it will be populated in a combo box during registration page only. I guess request scope is enough.</p> </blockquote> <p>That's a pretty weak reason. If it were me, I'd have placed it in the application scope. The role list is the same for every single request/session anyway, right? You don't need to reload/repopulate it on every request then, unless you've a really, really low memory footprint.</p> <h3>See also:</h3> <ul> <li><a href="https://stackoverflow.com/questions/7031885/how-to-choose-the-right-bean-scope/7031941#7031941">How to choose the right bean scope?</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload