This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ManagedBean | |
@RequestScoped | |
public class Bean { | |
@EJB | |
private ProductService productService; | |
// Rest of the code | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h:inputText id="username" value="#{bean.username}" required="true" /> | |
<h:message for="username" /> | |
<h:inputSecret id="password" value="#{bean.password}" required="true" /> | |
<h:message for="password" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h:inputText value="#{bean.name}" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h:commandButton value="Submit" action="#{bean.submit}" /> | |
<h:outputText value="#{bean.message}" rendered="#{not empty bean.message}" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ManagedBean | |
@RequestScoped | |
public class Bean { | |
private String username; | |
private String password; | |
// Getters and setters | |
public String login() { | |
// Business logic for login |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h:commandButton value="Submit" action="#{bean.submit}" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LoginForm extends ActionForm { | |
@RequiredFieldValidator(message = "Username is required.") | |
private String username; | |
@RequiredFieldValidator(message = "Password is required.") | |
private String password; | |
// Getters and setters | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomValidator implements Validator { | |
public void validate(Object object) throws ValidationException { | |
// Custom validation logic | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %> | |
<html:form action="/login"> | |
<html:text property="username" /> | |
<html:password property="password" /> | |
<html:submit value="Login" /> | |
</html:form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LoginAction extends Action { | |
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { | |
LoginForm loginForm = (LoginForm) form; | |
String username = loginForm.getUsername(); | |
String password = loginForm.getPassword(); | |
// Perform authentication and other business logic | |
return mapping.findForward("success"); | |
} |
NewerOlder