zoukankan      html  css  js  c++  java
  • JSF request参数传递

    转载自:http://blog.csdn.net/duankaige/article/details/6711044

    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>

  • 相关阅读:
    植物大战僵尸 辅助 总结
    C# 操作地址 从内存中读取写入数据(初级)
    c# math
    c# 获取屏幕图片
    从客户端(editorValue="<p>xxxx</p>")中检测到有潜在危险的 Request.Form 值。
    三种常见的SQL分页语句
    Windows Installer 服务无法启动!
    无法访问windows installer服务
    mssql2000数据库执行SQL语句来创建数据库以及数据表还有索引
    如何安装aspjpeg
  • 原文地址:https://www.cnblogs.com/zrui-xyu/p/4872341.html
Copyright © 2011-2022 走看看