The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Tim Holloway wrote:Why do you have a PropertyActionListener on the "Submit" button?
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Tim Holloway wrote:Terrible practice.
Backing bean properties are automatically set when an action is fired. You do not need any special tags or logic (except for the POJO set/get methods) for that to happen.
In fact, the standard JSF lifecycle works like this when a commandButton or commandLink is clicked:
1. The JSF form is submitted to the server.
2. JSF reads the input control values from that form and validates them.
3. IF AND ONLY IF ALL form input values are valid, JSF will use the backing bean's property "set" methods to update the backing bean.
4. Once the backing bean has been updated, the action method will be invoked.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Tim Holloway wrote:The downside of free help is that there's a limit on how closely I'm going to read any code that doesn't fit on a single screen. So I try and deduce what you're attempting based on common use cases.
I'm going to assume that you have a View with a backing bean and you want to navigate to a new View with a different backing bean. How to get a property of the first backing bean into the second backing bean?
Answer: Consider making the second bean's property a Managed Property. Managed Properties are indicated using the @ManagedProperty annotation (or its XML equivalent in faces-config). The ManagedProperty value is an EL expression, just like you code them on forms. So, for example:
There are certain considerations. For this to work properly, the injected bean must have a lifespan that includes the bean being injected into. Specifically, no RequestScope beans (Request scope is almost 100% useless in JSF anyway). Also, if the injected bean was created from a different View than the target bean, ViewScope won't work. Session and Application scope work the best.
JSF is very heavily based on Inversion of Control - the principle that stuff gets delivered to you from the framework instead of making you have to go out and get it yourself. If you don't understand IoC, then that's something you should study.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.