使用backing bean來添加UIComponents 到頁面中?
下面是一個例子:
jsp1.jsp:
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%> <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%> <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <html> <f:view> <head> <title>jsp1</title> <link rel="stylesheet" type="text/css" href="./style.css" title="Style"/> </head> <body bgcolor="#ffffff"> TESTING... <h:form id="form1"> <h:panelGrid id="panelgridtest" binding="#{jsp1Bean.component}"/> </h:form> </body> </f:view> </html>
?
Jsp1Bean.java:
package?test; |
?
faces-config.xml:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd"> <faces-config> <navigation-rule> <from-view-id>/jsp1</from-view-id> <navigation-case> <from-action>submit</from-action> <to-view-id>/jsp1</to-view-id> <redirect/> </navigation-case> </navigation-rule> <managed-bean> <managed-bean-name>jsp1Bean</managed-bean-name> <managed-bean-class>test.Jsp1Bean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> </faces-config>