Skip to content

Instantly share code, notes, and snippets.

View techisbeautiful's full-sized avatar

techisbeautiful

View GitHub Profile
@techisbeautiful
techisbeautiful / Bean.java
Created June 10, 2023 09:54
Integration with Java EE Ecosystem
@ManagedBean
@RequestScoped
public class Bean {
@EJB
private ProductService productService;
// Rest of the code
}
@techisbeautiful
techisbeautiful / validation.xml
Created June 10, 2023 09:54
Support for Multiple Input Types and Validation
<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" />
@techisbeautiful
techisbeautiful / state.xml
Created June 10, 2023 09:53
Server-Side State Management
<h:inputText value="#{bean.name}" />
@techisbeautiful
techisbeautiful / model.xml
Created June 10, 2023 09:52
Event-Driven Programming Model
<h:commandButton value="Submit" action="#{bean.submit}" />
<h:outputText value="#{bean.message}" rendered="#{not empty bean.message}" />
@techisbeautiful
techisbeautiful / Bean.java
Created June 10, 2023 09:50
MVC Architecture
@ManagedBean
@RequestScoped
public class Bean {
private String username;
private String password;
// Getters and setters
public String login() {
// Business logic for login
@techisbeautiful
techisbeautiful / ui.xml
Created June 10, 2023 09:50
Rich Component Library
<h:commandButton value="Submit" action="#{bean.submit}" />
@techisbeautiful
techisbeautiful / LoginForm.java
Created June 3, 2023 08:41
Robust Validation and Error Handling
public class LoginForm extends ActionForm {
@RequiredFieldValidator(message = "Username is required.")
private String username;
@RequiredFieldValidator(message = "Password is required.")
private String password;
// Getters and setters
}
@techisbeautiful
techisbeautiful / CustomValidator.java
Created June 3, 2023 08:38
Extensibility and Customization
public class CustomValidator implements Validator {
public void validate(Object object) throws ValidationException {
// Custom validation logic
}
}
@techisbeautiful
techisbeautiful / rapid.jsp
Created June 3, 2023 08:34
Rapid Development
<%@ 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>
@techisbeautiful
techisbeautiful / LoginAction.java
Created June 3, 2023 08:32
Controller (Struts Action)
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");
}