Showing posts with label action. Show all posts
Showing posts with label action. Show all posts

Saturday, October 30, 2010

ADF UI - Navigating to next jsf page programmatically (instead of specifying 'action' declaratively)

The below code shows how to programmatically navigate to next jsf page in taskflow. Mainly this is used for conditional navigation i.e., based on some logic we can dynamically decide which page needs to be shown to the user.

public void submitClicked(ActionEvent actionEvent) { navigate(actionEvent, "submit"); }

Code for navigate() method:
protected void navigate(FacesEvent event, String outcome) { RichRegion regionComponent = null; for (UIComponent uic = event.getComponent().getParent(); uic != null; uic = uic.getParent()) { if (uic instanceof RichRegion) { regionComponent = (RichRegion) uic; break; } } if (regionComponent != null) { FacesContext fc = FacesContext.getCurrentInstance(); ExpressionFactory ef = fc.getApplication().getExpressionFactory(); ELContext elc = fc.getELContext(); MethodExpression me = ef.createMethodExpression(elc, outcome, String.class, new Class[] { }); regionComponent .queueActionEventInRegion(me, null, null, false, -1, -1, event.getPhaseId()); } }
In the above code, 'submit' is the 'action' attribute based on which the next jsff page in the flow will be decided.
Related Posts with Thumbnails