Reputation: 775
I woud like to use the redirection and action at the same using DefaultMenuItem
My code is
MenuModel menuModel = new DefaultMenuModel();
DefaultSubMenu menu = new DefaultSubMenu("menu");
DefaultMenuItem item = new DefaultMenuItem("new Menu");
item.setCommand("redirection"); // redirection is configured in faces-config.xml
item.setCommand("#{myBean.init}");
menu.addElement(item)
menuModel.addElement(menu);
but it does not work
(it worked previsouly when there was no
item.setCommand("#{myBean.init}");
)
Apparently, having two setCommand gives some problems
but I need the inialization when I click on the button.
Could you help me ?
Upvotes: 1
Views: 2588
Reputation: 17461
item.setCommand("#{myBean.init}");
In your manage bean myBean
you can have init
method like
public String init(){
//do your business logic.
return "idToBeNavigatedTo";
}
Above will process your business Logic and redirect
to url
which is mapped for the action id you return in faces-config.xml
Upvotes: 3