JSF中传递参数的问题

来源:互联网 发布:电话销售数据在哪里买 编辑:程序博客网 时间:2024/06/02 11:03

public static String getRequestParameter(String name) {
  return (String)FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get(name);
}

 

 

Q:<h:commandButton   action="#{mousikomiList.deleteAction}"   value="delete">  
  <f:param   name="Deleteid"     value="#{mousi.id}"/>  
  </h:commandButton>  
  我在程序中有上面的一段代码,但是在backbean中得不到参数Deleteid.把上边commandButton   修改成commandLink后就可以传递参数了,请问怎样才能让commandButton也这样传递参数呢   ?
A:  write   the   tag   :<h:inputHidden   id="DeleteId"   value="#{mousi.id}"   />  
  in   your   HForm.   

 

JSF参数传递问题

困扰我好几天了,费了我不少脑细胞,最终的方法总结:
sample.jsp
<h:commandLink actionListener="myobj.process" action="success">
<h:outputText value="Do it and return"/>
<f:param name="productId" value="#{param.productId}"/>
</h:commandLink>
 
Myobj.java
public void process(ActionEvent event){
// 获取参数
FacesContext ctx = FacesContext.getCurrentInstance();
int productId = Integer.parseInt((String)ctx.getExternalContext().getRequestParameterMap().get("productId"));
// process ...
}
 
最郁闷的是:开始一直用commandButton,结果param一直没法传递,最后查证,要传递param,必须使用commandLink!