JSF request参数传递
来源:互联网 发布:alphacam软件 编辑:程序博客网 时间:2024/05/12 16:09
关键词 JSF Request 传参 BEAN Request属性注入
1:JSF页面之间传参
方法1:
<h:outputLink value="param2.jsf">
<h:outputText value="Test4"></h:outputText>
<f:param name="name" value="chen"></f:param>
<f:param name="id" value="123456"></f:param>
</h:outputLink>
方法2:
<h:outputLink value="param2.jsf?name=chen&id=123456">
<h:outputText value="Test4"></h:outputText>
</h:outputLink>
2:JSF页面之间取得参数
方法1:
<h:outputText value="#{param.name}"></h:outputText>
方法2:
<%=request.getParameter("name")%>
3:JSF页面到后台传参
<h:form>
<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>
</h:form>
4:JSF后台取得页面值
方法1:
HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
request.getParameter("name");
方法2:
Map varMap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
varMap.get("id");
方法3:
通过配置文件进行Bean的属性值注入,在Bean的方法中直接使用属性
<managed-bean>
<managed-bean-name>paramBean</managed-bean-name>
<managed-bean-class>com.spg.bean.ParamBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>id</property-name>
<property-class>java.lang.String</property-class>
<value>#{param.id} </value>
</managed-property>
</managed-bean>
当前位置举例及相关总结
1:JS中可以使用java代码。获得当前Bean、获得当前Bean中属性值的java代码。
try{
parent.historyIframe.addHistory('/glp_user/glp_user_view_ViewForm.faces?<%=FacesContext.getCurrentInstance().getApplication().createValueBinding("#{glpUserForm.historyUrlParameter}").getValue(FacesContext.getCurrentInstance())%>','<%=LocaleMessage.getMessage("glpUser.glp_user_view_ViewForm.heading")%>(<%=FacesContext.getCurrentInstance().getApplication().createValueBinding("#{glpUserForm.glpUser.userName}").getValue(FacesContext.getCurrentInstance()) %>)',"1")
}catch(e){}
2:通过配置文件属性注入,param可以将页面上存入request的值放入后台的属性中。
public String getHistoryUrlParameter(){
if(this.glpUserPrimaryKey ==null)
return "_key=" + this.glpUser.getUserId();
return "_key=" + this.glpUserPrimaryKey;
}
<managed-bean>
<managed-bean-name>glpUserForm</managed-bean-name>
<managed-bean-class>
cn.com.brilliance.begen.webapp.action.GlpUserForm
</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>glpUser</property-name>
<value>#{glpUser}</value>
</managed-property>
<managed-property>
<property-name>glpUserPrimaryKey</property-name>
<value>#{param._key}</value>
</managed-property>
</managed-bean>
- JSF request参数传递
- JSF request参数传递
- jsf传递参数
- JSF参数传递方式
- JSF的参数传递
- JSF参数传递方式说明
- Request参数传递ASP函数库
- pushlet 传递页面request参数
- request内置对象---参数传递
- pushlet 传递页面request参数
- JSF中传递参数的问题
- jsf页面之间中文参数传递设置
- 通过URL传递参数到JSF
- jsp中request传递参数汉字乱码
- jsp中request传递参数汉字乱码
- Multipart传递参数request收不到解决方法
- jsp中request传递参数汉字乱码
- jsp中request传递参数汉字乱码
- gstreamer Win32_Cross_Compiling_With_Mingw
- 函数ALV单元格编辑
- 问题小结
- xml语言初识1
- poj 2288
- JSF request参数传递
- JAVA操作execl
- poj 2470 Ambiguous permutations
- VS2003创建动态库的一点笔记
- Axis,axis2,Xfire以及cxf对比
- MFC中模态对话框的调用流程小解
- django framework 处理流程
- poj 2756 Autumn is a Genius
- Dell LATITUDE E5410笔记本Ubuntu无线网卡BCM43224驱动安装(原创)