JSF中的h:commandLink如何传递参数 三种取值比较
2009-06-03 11:26
363 查看
声明本人刚学jsf三天 如有不足请指教....
本人总结了三种取得参数的方法
这是jsf中的代码
<h:commandLink action="#{}">
<h:outputText value="删除"></h:outputText>
<f:param id="id" name="id" value="123"></f:param> //假如要传递的参数为id
</h:commandLink>
这是BackBean中的代码 下边是如何在后台取得这个id参数的值
public class Person
{
public void verify(ActionEvent e)
{
/*这是第一种取得参数的方法
UIComponent com = e.getComponent();
UIParameter param = (UIParameter) com.findComponent("id");
Integer id = (Integer) param.getValue();
System.out.println(id);
*/
/*这是第二种取得参数值的方法
HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
int id = Integer.parseInt(request.getParameter("id"));
System.out.println(id);
*/
//这是第三种取得参数的方法
int id = Integer.parseInt(FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("id"));
System.out.println(id);
}
public String outcome()
{
return outcome;
}
}
代码没有贴完
本人总结了三种取得参数的方法
这是jsf中的代码
<h:commandLink action="#{}">
<h:outputText value="删除"></h:outputText>
<f:param id="id" name="id" value="123"></f:param> //假如要传递的参数为id
</h:commandLink>
这是BackBean中的代码 下边是如何在后台取得这个id参数的值
public class Person
{
public void verify(ActionEvent e)
{
/*这是第一种取得参数的方法
UIComponent com = e.getComponent();
UIParameter param = (UIParameter) com.findComponent("id");
Integer id = (Integer) param.getValue();
System.out.println(id);
*/
/*这是第二种取得参数值的方法
HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
int id = Integer.parseInt(request.getParameter("id"));
System.out.println(id);
*/
//这是第三种取得参数的方法
int id = Integer.parseInt(FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("id"));
System.out.println(id);
}
public String outcome()
{
return outcome;
}
}
代码没有贴完
相关文章推荐
- JSF中的h:commandLink如何传递参数 三种取值比较
- JSF中的h:commandLink如何传递参数 三种取值比较
- 如何使用URL字符串来传递参数到JSF程序中?
- servlet(三)-如何使用传参-三种转发方式、传递参数以及对象中数据的范围
- servlet(三)-如何使用传参-三种转发方式、传递参数以及对象中数据的范围
- salesforce commandLink commandButton中通过param传递参数
- 指针参数是如何传递内存的
- Apache AB 如何传递参数
- spring mvc 如何传递集合参数(list,数组)
- 如何解决网页的参数传递问题
- C++函数参数和返回值三种传递方式:值传递、指针传递和引用传递(着重理解)
- python:大量参数如何传递
- c++中参数传递的三种方式,以及用法。传值,传址,传引用
- 如何传递指向结构数组的指针 (函数参数)
- Code19 使用C#实现如何在运行时传递参数给水晶报表
- CodeBlocks下如何给main函数传递参数
- settimeout如何调用方法的时候,传递参数
- @Param 注解在Mybatis中的使用 以及传递参数的三种方式
- 第二周项目1-C/C++语言中函数参数传递的三种方式
- [MapReduce] 如何向map和reduce脚本传递参数,加载文件和目录