- Topic : Java Server Faces (JSF)
- Environment : J2EE 5.0, MyFaces 1.1.5
commandLink.jsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<!--
Source : www.javabeat.net
-->
<html>
<body>
<f:view>
<h:form id="commandLink">
<h:commandLink value="Test Link" action="#{commandLinkBean.linkIt}">
<f:param name="param1" value="ParamValue1" />
<f:param name="param2" value="ParamValue2" />
</h:commandLink>
</h:form>
</f:view>
</body>
</html> |
CommandLinkBean.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
/**
* Source : www.javabeat.net
* */
package net.javabeat.myfaces.nav;
public class CommandLinkBean {
private String param1;
private String param2;
public CommandLinkBean() {
}
public String getParam1() {
return param1;
}
public String getParam2() {
return param2;
}
public void setParam2(String param2) {
this.param2 = param2;
}
public void setParam1(String param1) {
this.param1 = param1;
}
public String linkIt(){
return "commandLink";
}
} |
faces-config.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
<managed-bean>
<managed-bean-name>
commandLinkBean
</managed-bean-name>
<managed-bean-class>
net.javabeat.myfaces.nav.CommandLinkBean
</managed-bean-class>
<managed-bean-scope>
request
</managed-bean-scope>
<managed-property>
<property-name>param1</property-name>
<value>#{param.param1}</value>
</managed-property>
<managed-property>
<property-name>param2</property-name>
<value>#{param.param2}</value>
</managed-property>
</managed-bean>
<navigation-rule>
<navigation-case>
<from-outcome>
commandLink
</from-outcome>
<to-view-id>
/pages/nav/commandLinkResult.jsp
</to-view-id>
</navigation-case>
</navigation-rule> |
commandLinkResult.jsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<!--
Source : www.javabeat.net
-->
<html>
<body>
<f:view>
<h:form id="commandLink">
<h:outputText value="#{commandLinkBean.param1}"/>
<h:outputText value="#{commandLinkBean.param2}"/>
</h:form>
</f:view>
</body>
</html> |






April 12, 2008
JSF