未识别JQuery AJAX JSF / jsf标签找不到FacesContext

问题描述

| 我在使用jquery ajax和jsf组合时遇到问题。我不太确定这是否是一个常见问题,是否可以解决,但希望能找到解决方案。 这是场景。我们正在使用jsf开发门户项目。因此,在页面上,我们必须按表中的行(有时约为300-400)加载大量数据,并且每一行都有一个需要打开弹出窗口的链接。因此,为了不影响页面性能,我打算延迟加载jsp(弹出内容)。所以想到去阿贾克斯。 jsp具有无法由ajax加载识别的jsf标签。我知道当jsp由ajax加载时,它将是一个普通/独立(un jsf \'tified)版本。 所以我的问题是:在这种情况下,如何使jsf(弹出内容)jsf固定化,以便jsf标签可见。 目前,我无法找到FacesContext。 我正在使用以下代码
jQuery.ajax({
    type: \"GET\",cache: false,contentType: \"text/html; charset=ISP-8859-1\",url: \'<%=renderResponse.encodeURL(renderRequest.getcontextpath()+ \"/tempfolder/tempLoader.jsp\") %>\',data:{param1:66,param2:88},success:function(msg) {    
        jQuery(\".loadContent\").html(msg);
        jQuery(\"#viewpopupdiv\").children().show();
    }
});
而我的jsp:
<%@taglib uri=\"http://java.sun.com/jsf/core\" prefix=\"f\"%>
<%@taglib uri=\"http://java.sun.com/portlet\" prefix=\"portlet\"%>
<%@taglib uri=\"http://www.ibm.com/jsf/html_extended\" prefix=\"hx\"%>
<%@taglib uri=\"http://java.sun.com/jsf/html\" prefix=\"h\"%>


<div id=\"view\"  style=\"text-align:left\">

<table class=\"viewpopupdiv\" style=\"width:480px;background-color:#efedea;border-width: thin; border-color: #ff6633; border-style:solid;\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">
        <tr>
            <td>
                <table style=\"width:100%\">
                    <tr>
                        <td>

                            <table style=\"width:100%;background-color:#424341;\">
                                <tr>
                                    <td class=\"editLineHeaderDarkLeft\">  
                                        <span class=\"\">Line ID</span> :&nbsp;<span class=\"headerValueForPopup\"><%=lineDetails.getdisplayableOrderLineId()%></span></td>
                                    <td class=\"editLineHeaderDarkCenter\">  
                                        <span class=\"\">Order Number</span>  :&nbsp;<span class=\"orderNumberHeaderValueForPopup\"><%=lineDetails.getdisplayableOrderHeaderId()%></span></td> 
                                    <td class=\"editLineHeaderDarkRight\"><div href=\"#\" onclick=\"closePopupForEditLine(\'closepopupdiv\')\"><img class=\"close\" src=\'<%=imgurL%>\' border=\"0\"></div>
                                    </td>
                                </tr>
                            </table>

<td class=\"editLineHeaderDarkLeft\">                              
<div class=\"chargeTypeDropListJQ\">  
                                        <h:selectOneMenu  value=\"#{popupBean.chargeTypeId}\" styleClass=\"selectOneMenu\">
                                            <f:selectItems value=\"#{popupBean.chargeType}\" />
                                        </h:selectOneMenu>
                                    </div>
</td>
                    </tr>  
                </table>
</td></tr></table></div>
    

解决方法

  找不到FacesContext 如果您在不调用ѭ2的情况下将JSF组件作为“普通香草” JSP运行JSP页面时,就会遇到此异常。它是创建creating3的负责人。请求URL必须与
FacesServlet
中的
<url-pattern>
相匹配,因为它在
web.xml
中定义,以使所有JSF标记正常运行。 假设网址格式为“ 7”,那么您需要更改
url: \'<%=renderResponse.encodeURL(renderRequest.getContextPath()+ \"/tempfolder/tempLoader.jsp\") %>\',
url: \'<%=renderResponse.encodeURL(renderRequest.getContextPath()+ \"/tempfolder/tempLoader.jsf\") %>\',