Building JSF application with Exadel IDE

«»

Action of the command

In JSF there are two principal ways for defining the navigation as a result of an user click on a given link (commandLink’s JSF component) or button (commandButton):

  • Static outcome . When the navigation is known in compilation time (don’t depends on runtime values) we can simple hard coded the outcome of the action property of a commandLink or commandButton components.
  • By means of a bean’s method . Other scenarios, require dynamic information, which may depend on variable factors, the user’s input for example, for these cases we need to implement a method that defines which way to go with the given input.

In our example we based our decision based on the user’s name in the checkLogin method of the User’s bean as we illustrate here:

1
2
3
4
5
6
7
public String checkLogin(String login, String password) {
			String result = "error";
			if (userExists(login, password) && userPermission(login, ‘LOGIN_USER’)) {
				result = "success";
			}
			return result;
		}

Notice the correspondence between the return values of this method and the navigation rules defined in faces-config.xml. In the next section, we bind this method with the commandButton that whether accept or reject the user’s login.

email

«»

Comments

comments