- Topic : Java Server Faces (JSF)
- Environment : J2EE 5.0, MyFaces 1.1.5
- Discuss Here
commandLink.jsp
<!--
Source : www.javabeat.net
-->
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<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
/**
* 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
<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
<!--
Source : www.javabeat.net
-->
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<html>
<body>
<f:view>
<h:form id="commandLink">
<h:outputText value="#{commandLinkBean.param1}"/>
<h:outputText value="#{commandLinkBean.param2}"/>
</h:form>
</f:view>
</body>
</html>
|