I’ll try to explain my problem. I use the JSF 1.2 implementation of IBM in a very very rigid environment (company layer, and strict constraints -don’t add library etc.-).
I want to create a simple page for confirmation that can be reused (kind of generic).
For example :
1-page1.jsp > click on button
2-pageConfirmation.jsp > 2 buttons Yes or No
3-click on No > go back / 3bis-click on Yes > go to someAction then go to page2.jsp
So I wanted to store in session the things I need, where I come from, where I want to go. But here’s the problem : How can I invoke the action I want? The name is dynamic. Let’s suppose I’m in the controller after I click on “Yes”, I want to call the “myMethodAction” from its name which I stored in session. I thought about evaluating it using the expression-language api, but i’m blocked because I can’t access the ELContext, and am not allowed to use the el package (el-api.jar).
To sum-up, after the click, I’m trying to invoke an action/method and then redirect to a page, instead of calling a page.
Do anyone have some magic ideas? Or am I just totally wrong?
Thanks in advance.
You can create a fully independent managed bean
ConfirmationBeanand put it in the request scope. You can access it in the “parent” bean by under each the managed property injection facility or just create it yourself and put it in request map.The first way requires lot of work in
faces-config.xmlif you want to associate it with lot of other beans, so I don’t think this is very attractive.The second way only requires a bit of (reuseable) code in the action method. I’ll give an example:
and the
confirm.jsfshould have the “outcome” in a hidden field, e.g.the action method of
ConfirmationBeanshould look like:or if you’re a fan of ternary operators 😉