日期:2014-05-16 浏览次数:20381 次
参考:http://pity1115.iteye.com/blog/336431
??????页面代码:???????
?
<h:commandLink value="Test2" action="#{paramBean.test}">
<f:param name="name" value="zhang"></f:param>
<f:param name="id" value="123456"></f:param>
</h:commandLink>
??? 后台取参方法:
?
//通过Request对象取值
HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
request.getParameter("name");
?
//通过RequestParameterMap取值
Map varMap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
varMap.get("id");
页面代码:
?
<h:commandButton action="#{paramBean.test3}" value="Test11" actionListener="#{paramBean.changeName}">
<f:attribute name="name" value="hujilie"/>
</h:commandButton>
? 后台取参方法:
?
? ?UIComponent component = e.getComponent();
Map<String, Object> map = component.getAttributes();
Object nameValue = map.get("name");
?
页面代码:
?
? ? ? ?<h:commandButton action="#{projectBean.searchProject}" value="show project">
<f:setPropertyActionListener value="peter" target="#{projectBean.name}"/>
</h:commandButton>
??
后台取参方法:JSF自动完成对属性的赋值;直接使用name属性
?
findProject(name);
可在页面之间传递任意java object(managed Bean)
页面代码:
?
<ui:include src="/pages/contents/process/processDefHead.xhtml" >
<ui:param name="piMgtBean" value="#{processInstanceMgtBean}" />
</ui:include>
?
JSF自动完成对属性的赋值;直接使用name属性(限定类型为String)
?
<a4j:commandButton value="Set Name to Alex" reRender="rep" >
<a4j:actionparam name="username" value="Alex" assignTo="#{userBean.name}"/>
</a4j:commandButton>
?